智能表单修复

This commit is contained in:
慕下 2024-09-09 15:15:50 +08:00
parent 72772ec4a1
commit fae8abba86
6 changed files with 23 additions and 20 deletions

View File

@ -31,15 +31,17 @@ public class DynamicDataController {
//保存数据
@PostMapping("/saveDynamicData")
public CommonResult<String> saveDynamicData(@RequestBody Map<String, Object> requestData, HttpServletRequest httpServletRequest) {
dynamicDataService.doSaveDynamicData(requestData,httpServletRequest);
public CommonResult<String> saveDynamicData(@RequestBody Map<String, Object> requestData, @RequestHeader("Tenant-Id") String userAgent) {
dynamicDataService.doSaveDynamicData(requestData,userAgent);
return success("保存成功");
}
//查询全部数据
@GetMapping("/selectDynamicData")
public CommonResult<List<DynamicData>> selectDynamicData(HttpServletRequest httpServletRequest) {
return success(dynamicDataService.doSelectDynamicData(httpServletRequest));
public CommonResult<List<DynamicData>> selectDynamicData(@RequestHeader("Tenant-Id") String userAgent) {
// System.out.println("--------------"+userAgent);
// return success(null);
return success(dynamicDataService.doSelectDynamicData(userAgent));
}
//根据id查询数据
@GetMapping("/selectDynamicDataById")

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 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<DynamicData,String> {
@Query("{'tenantName': {'$eq': ?0}}")
List<DynamicData> findByTenantName(String tenantName);
@Query("{'_id': {'$eq': ?0}}")
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 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<DynamicForm,String> {
Long countAllByDynamicDataId(String dynamicDataId);
List<DynamicForm> findByDynamicDataId(String id);

View File

@ -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<String, Object> requestData, HttpServletRequest httpServletRequest){
public DynamicData doSaveDynamicData(Map<String, Object> 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<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) {
//查询对应卡片链接采集到数据的数量
Long count = dynamicFormRepository.countAllByDynamicDataId(dynamicDatum.getId());

View File

@ -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;

View File

@ -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) {