Merge pull request '后台配置文件调整' (#11) from zzw-one into master
All checks were successful
continuous-integration/drone Build is passing

Reviewed-on: #11
This commit is contained in:
root 2024-09-13 15:37:34 +08:00
commit 072e0f8fd3
8 changed files with 30 additions and 23 deletions

View File

@ -128,7 +128,7 @@ public class YudaoWebSecurityConfigurerAdapter {
// 全局共享规则 // 全局共享规则
.authorizeRequests() .authorizeRequests()
// 1.1 静态资源可匿名访问 // 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 无需认证 // 1.2 设置 @PermitAll 无需认证
.antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).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() .antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.promotion.controller.admin.dynamic; package cn.iocoder.yudao.module.promotion.controller.admin.dynamic;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.DynamicData;
import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm; import cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicForm;
import cn.iocoder.yudao.module.promotion.service.dynamic.DynamicDataService; 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.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -31,24 +33,28 @@ public class DynamicDataController {
//保存数据 //保存数据
@PostMapping("/saveDynamicData") @PostMapping("/saveDynamicData")
public CommonResult<String> saveDynamicData(@RequestBody Map<String, Object> requestData, HttpServletRequest httpServletRequest) { public CommonResult<String> saveDynamicData(@RequestBody Map<String, Object> requestData, @RequestHeader("Tenant-Id") String userAgent) {
dynamicDataService.doSaveDynamicData(requestData,httpServletRequest); dynamicDataService.doSaveDynamicData(requestData,userAgent);
return success("保存成功"); return success("保存成功");
} }
//查询全部数据 //查询全部数据
@GetMapping("/selectDynamicData") @GetMapping("/selectDynamicData")
public CommonResult<List<DynamicData>> selectDynamicData(HttpServletRequest httpServletRequest) { public CommonResult<List<DynamicData>> selectDynamicData(@RequestHeader("Tenant-Id") String userAgent) {
return success(dynamicDataService.doSelectDynamicData(httpServletRequest)); // System.out.println("--------------"+userAgent);
// return success(null);
return success(dynamicDataService.doSelectDynamicData(userAgent));
} }
//根据id查询数据 //根据id查询数据
@GetMapping("/selectDynamicDataById") @GetMapping("/selectDynamicDataById")
@PermitAll
public CommonResult<DynamicData> selectDynamicDataById(String id){ public CommonResult<DynamicData> selectDynamicDataById(String id){
return success(dynamicDataService.doSelectDynamicDataById(id)); return success(dynamicDataService.doSelectDynamicDataById(id));
} }
//采集数据 //采集数据
@PostMapping("/collectData") @PostMapping("/collectData")
@PermitAll
public CommonResult<String> collectData(@RequestBody DynamicForm dynamicForm){ public CommonResult<String> collectData(@RequestBody DynamicForm dynamicForm){
dynamicFormService.doCollectData(dynamicForm); dynamicFormService.doCollectData(dynamicForm);
return success("保存成功"); return success("保存成功");

View File

@ -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 cn.iocoder.yudao.module.promotion.dal.dataobject.dynamic.DynamicData;
import org.apache.ibatis.annotations.Mapper;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query; import org.springframework.data.mongodb.repository.Query;
@ -9,9 +8,10 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
//@Repository @Repository
@Mapper //@Mapper
public interface DynamicDataRepository extends MongoRepository<DynamicData,String> { public interface DynamicDataRepository extends MongoRepository<DynamicData,String> {
@Query("{'tenantName': {'$eq': ?0}}")
List<DynamicData> findByTenantName(String tenantName); List<DynamicData> findByTenantName(String tenantName);
@Query("{'_id': {'$eq': ?0}}") @Query("{'_id': {'$eq': ?0}}")
DynamicData doFindById(ObjectId id); DynamicData doFindById(ObjectId id);

View File

@ -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 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.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
//@Repository @Repository
@Mapper //@Mapper
public interface DynamicFormRepository extends MongoRepository<DynamicForm,String> { public interface DynamicFormRepository extends MongoRepository<DynamicForm,String> {
Long countAllByDynamicDataId(String dynamicDataId); Long countAllByDynamicDataId(String dynamicDataId);
List<DynamicForm> findByDynamicDataId(String id); List<DynamicForm> findByDynamicDataId(String id);

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.promotion.service.dynamic; 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.dataobject.dynamic.DynamicData;
import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicDataRepository; import cn.iocoder.yudao.module.promotion.dal.repository.DynamicDataRepository;
import cn.iocoder.yudao.module.promotion.dal.mysql.repository.DynamicFormRepository; import cn.iocoder.yudao.module.promotion.dal.repository.DynamicFormRepository;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,7 +24,7 @@ public class DynamicDataService {
private DynamicFormRepository dynamicFormRepository; private DynamicFormRepository dynamicFormRepository;
//保存数据 //保存数据
public DynamicData doSaveDynamicData(Map<String, Object> requestData, HttpServletRequest httpServletRequest){ public DynamicData doSaveDynamicData(Map<String, Object> requestData, String userAgent){
DynamicData dynamicData = new DynamicData(); DynamicData dynamicData = new DynamicData();
//构造数据结构 //构造数据结构
String title = (String)requestData.get("title"); String title = (String)requestData.get("title");
@ -41,20 +41,20 @@ public class DynamicDataService {
requestData.put(s,null); requestData.put(s,null);
} }
requestData.remove("inputarr"); requestData.remove("inputarr");
dynamicData.setCreatePeople(getLoginUserId(httpServletRequest).toString()); dynamicData.setCreatePeople(getLoginUserId().toString());
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter); String formattedDate = currentDate.format(formatter);
dynamicData.setCreateTime(formattedDate); dynamicData.setCreateTime(formattedDate);
dynamicData.setData(requestData); dynamicData.setData(requestData);
dynamicData.setTenantName(httpServletRequest.getHeader("Tenant")); dynamicData.setTenantName(userAgent);
return dynamicDataRepository.save(dynamicData);//插入dynamicData数据 return dynamicDataRepository.save(dynamicData);//插入dynamicData数据
} }
//查询全部数据 //查询全部数据
public List<DynamicData> doSelectDynamicData(HttpServletRequest httpServletRequest){ public List<DynamicData> doSelectDynamicData(String httpServletRequest){
//查询对应租户下的卡片列表数据 //查询对应租户下的卡片列表数据
List<DynamicData> dynamicData = dynamicDataRepository.findByTenantName(httpServletRequest.getHeader("Tenant")); List<DynamicData> dynamicData = dynamicDataRepository.findByTenantName(httpServletRequest);
for (DynamicData dynamicDatum : dynamicData) { for (DynamicData dynamicDatum : dynamicData) {
//查询对应卡片链接采集到数据的数量 //查询对应卡片链接采集到数据的数量
Long count = dynamicFormRepository.countAllByDynamicDataId(dynamicDatum.getId()); Long count = dynamicFormRepository.countAllByDynamicDataId(dynamicDatum.getId());

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.promotion.service.dynamic; 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.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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.server;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; 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} @SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) @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 class YudaoServerApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -203,8 +203,8 @@ wx:
# secret: 333ae72f41552af1e998fe1f54e1584a # secret: 333ae72f41552af1e998fe1f54e1584a
# appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 # appid: wx63c280fe3248a3e7 # wenhualian的接口测试号
# secret: 6f270509224a7ae1296bbf1c8cb97aed # secret: 6f270509224a7ae1296bbf1c8cb97aed
appid: wxe88f237df9dae1e9 # 众悦科技 appid: wxa66f2777a5656baf # 众悦科技
secret: 18182ef4aacdefd65b5c8063f7b5254e secret: 2fd77fed89c7722fc6f586093edb1370
# appid: wxc4598c446f8a9cb3 # 测试号Kongdy 提供的) # appid: wxc4598c446f8a9cb3 # 测试号Kongdy 提供的)
# secret: 4a1a04e07f6a4a0751b39c3064a92c8b # secret: 4a1a04e07f6a4a0751b39c3064a92c8b
config-storage: config-storage: