From 72772ec4a1fc99e97af5789ced1d31e42cad2067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=85=95=E4=B8=8B?= <484014559@qq.com> Date: Mon, 9 Sep 2024 15:01:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-server/src/main/resources/application-local.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index fe9980c..168d268 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -203,8 +203,8 @@ wx: # secret: 333ae72f41552af1e998fe1f54e1584a # appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 # secret: 6f270509224a7ae1296bbf1c8cb97aed - appid: wxe88f237df9dae1e9 # 众悦科技 - secret: 18182ef4aacdefd65b5c8063f7b5254e + appid: wxa66f2777a5656baf # 众悦科技 + secret: 2fd77fed89c7722fc6f586093edb1370 # appid: wxc4598c446f8a9cb3 # 测试号(Kongdy 提供的) # secret: 4a1a04e07f6a4a0751b39c3064a92c8b config-storage: From fae8abba8607fa7c828c827dce4a71d3e320f244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=85=95=E4=B8=8B?= <484014559@qq.com> Date: Mon, 9 Sep 2024 15:15:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/dynamic/DynamicDataController.java | 10 ++++++---- .../repository/DynamicDataRepository.java | 8 ++++---- .../repository/DynamicFormRepository.java | 7 +++---- .../service/dynamic/DynamicDataService.java | 14 +++++++------- .../service/dynamic/DynamicFormService.java | 2 +- .../yudao/server/YudaoServerApplication.java | 2 ++ 6 files changed, 23 insertions(+), 20 deletions(-) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/{mysql => }/repository/DynamicDataRepository.java (80%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/{mysql => }/repository/DynamicFormRepository.java (76%) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java index d48cb09..8897777 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java @@ -31,15 +31,17 @@ public class DynamicDataController { //保存数据 @PostMapping("/saveDynamicData") - public CommonResult saveDynamicData(@RequestBody Map requestData, HttpServletRequest httpServletRequest) { - dynamicDataService.doSaveDynamicData(requestData,httpServletRequest); + public CommonResult saveDynamicData(@RequestBody Map requestData, @RequestHeader("Tenant-Id") String userAgent) { + dynamicDataService.doSaveDynamicData(requestData,userAgent); return success("保存成功"); } //查询全部数据 @GetMapping("/selectDynamicData") - public CommonResult> selectDynamicData(HttpServletRequest httpServletRequest) { - return success(dynamicDataService.doSelectDynamicData(httpServletRequest)); + public CommonResult> selectDynamicData(@RequestHeader("Tenant-Id") String userAgent) { +// System.out.println("--------------"+userAgent); +// return success(null); + return success(dynamicDataService.doSelectDynamicData(userAgent)); } //根据id查询数据 @GetMapping("/selectDynamicDataById") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicDataRepository.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicDataRepository.java similarity index 80% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicDataRepository.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicDataRepository.java index f92dbfc..f088cb5 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicDataRepository.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicDataRepository.java @@ -1,7 +1,6 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.repository; +package cn.iocoder.yudao.module.promotion.dal.repository; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData; -import org.apache.ibatis.annotations.Mapper; import org.bson.types.ObjectId; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.Query; @@ -9,9 +8,10 @@ import org.springframework.stereotype.Repository; import java.util.List; -//@Repository -@Mapper +@Repository +//@Mapper public interface DynamicDataRepository extends MongoRepository { + @Query("{'tenantName': {'$eq': ?0}}") List findByTenantName(String tenantName); @Query("{'_id': {'$eq': ?0}}") DynamicData doFindById(ObjectId id); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicFormRepository.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicFormRepository.java similarity index 76% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicFormRepository.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicFormRepository.java index 7aa22af..7d31dcb 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/repository/DynamicFormRepository.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/repository/DynamicFormRepository.java @@ -1,14 +1,13 @@ -package cn.iocoder.yudao.module.promotion.dal.mysql.repository; +package cn.iocoder.yudao.module.promotion.dal.repository; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm; -import org.apache.ibatis.annotations.Mapper; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.stereotype.Repository; import java.util.List; -//@Repository -@Mapper +@Repository +//@Mapper public interface DynamicFormRepository extends MongoRepository { Long countAllByDynamicDataId(String dynamicDataId); List findByDynamicDataId(String id); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicDataService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicDataService.java index 08503cf..1a54664 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicDataService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicDataService.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.promotion.service.dynamic; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData; -import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicDataRepository; -import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicFormRepository; +import cn.iocoder.yudao.module.promotion.dal.repository.DynamicDataRepository; +import cn.iocoder.yudao.module.promotion.dal.repository.DynamicFormRepository; import org.bson.types.ObjectId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,7 +24,7 @@ public class DynamicDataService { private DynamicFormRepository dynamicFormRepository; //保存数据 - public DynamicData doSaveDynamicData(Map requestData, HttpServletRequest httpServletRequest){ + public DynamicData doSaveDynamicData(Map requestData, String userAgent){ DynamicData dynamicData = new DynamicData(); //构造数据结构 String title = (String)requestData.get("title"); @@ -41,20 +41,20 @@ public class DynamicDataService { requestData.put(s,null); } requestData.remove("inputarr"); - dynamicData.setCreatePeople(getLoginUserId(httpServletRequest).toString()); + dynamicData.setCreatePeople(getLoginUserId().toString()); LocalDate currentDate = LocalDate.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); String formattedDate = currentDate.format(formatter); dynamicData.setCreateTime(formattedDate); dynamicData.setData(requestData); - dynamicData.setTenantName(httpServletRequest.getHeader("Tenant")); + dynamicData.setTenantName(userAgent); return dynamicDataRepository.save(dynamicData);//插入dynamicData数据 } //查询全部数据 - public List doSelectDynamicData(HttpServletRequest httpServletRequest){ + public List doSelectDynamicData(String httpServletRequest){ //查询对应租户下的卡片列表数据 - List dynamicData = dynamicDataRepository.findByTenantName(httpServletRequest.getHeader("Tenant")); + List dynamicData = dynamicDataRepository.findByTenantName(httpServletRequest); for (DynamicData dynamicDatum : dynamicData) { //查询对应卡片链接采集到数据的数量 Long count = dynamicFormRepository.countAllByDynamicDataId(dynamicDatum.getId()); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicFormService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicFormService.java index aacd879..14b69cc 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicFormService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/dynamic/DynamicFormService.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.promotion.service.dynamic; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm; -import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicFormRepository; +import cn.iocoder.yudao.module.promotion.dal.repository.DynamicFormRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java index 57db3f9..27f5498 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; /** * 项目的启动类 @@ -14,6 +15,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; */ @SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} @SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) +@EnableMongoRepositories(basePackages = "cn.iocoder.yudao.module.promotion.dal.repository") public class YudaoServerApplication { public static void main(String[] args) { From 426ca8ebba54d51f2df77e9251893ea069597518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=85=95=E4=B8=8B?= <484014559@qq.com> Date: Mon, 9 Sep 2024 17:05:50 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/YudaoWebSecurityConfigurerAdapter.java | 2 +- .../controller/admin/dynamic/DynamicDataController.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index 90822de..3b9f500 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -128,7 +128,7 @@ public class YudaoWebSecurityConfigurerAdapter { // ①:全局共享规则 .authorizeRequests() // 1.1 静态资源,可匿名访问 - .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() + .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js","/intelligentForm/selectDynamicDataById","/intelligentForm/selectDynamicDataById").permitAll() // 1.2 设置 @PermitAll 无需认证 .antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll() .antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll() diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java index 8897777..4862da9 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/dynamic/DynamicDataController.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.dynamic; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm; import cn.iocoder.yudao.module.promotion.service.dynamic.DynamicDataService; @@ -9,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.web.bind.annotation.*; +import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; @@ -45,12 +47,14 @@ public class DynamicDataController { } //根据id查询数据 @GetMapping("/selectDynamicDataById") + @PermitAll public CommonResult selectDynamicDataById(String id){ return success(dynamicDataService.doSelectDynamicDataById(id)); } //采集数据 @PostMapping("/collectData") + @PermitAll public CommonResult collectData(@RequestBody DynamicForm dynamicForm){ dynamicFormService.doCollectData(dynamicForm); return success("保存成功");