优化代码
This commit is contained in:
parent
d063bedba4
commit
049ebd0d6f
|
|
@ -3,6 +3,7 @@ package com.electromagnetic.industry.software.manage.controller;
|
|||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.AddImportTableDataDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateImportTableDataDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.ImportTableService;
|
||||
|
|
@ -23,13 +24,14 @@ public class ImportTableController {
|
|||
public ElectromagneticResult<?> query(@RequestParam String tableInfoId, @RequestParam Integer pageSize, @RequestParam Integer pageNum) {
|
||||
pageNum = Optional.ofNullable(pageNum).orElse(1);
|
||||
pageSize = Optional.ofNullable(pageSize).orElse(10);
|
||||
return importTableService.selectTableDataByTableInfoId(pageNum, pageSize, tableInfoId);
|
||||
return ElectromagneticResultUtil.success(importTableService.selectTableDataByTableInfoId(pageNum, pageSize, tableInfoId));
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@UserOperation(value = "新增结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||
public ElectromagneticResult<?> add(@RequestBody AddImportTableDataDTO addImportTableDataDTO) {
|
||||
return importTableService.addTableData(addImportTableDataDTO.getTableInfoId(), addImportTableDataDTO.getTableData());
|
||||
return ElectromagneticResultUtil.success(importTableService.addTableData(addImportTableDataDTO.getTableInfoId(), addImportTableDataDTO.getTableData()));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/remove")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
||||
|
||||
|
|
@ -7,7 +8,7 @@ import java.util.Map;
|
|||
|
||||
public interface ImportTableService {
|
||||
|
||||
ElectromagneticResult<?> addTableInfo(String relatedId, Map<Integer, Object> tableHeader);
|
||||
String addTableInfo(String relatedId, Map<Integer, Object> tableHeader);
|
||||
|
||||
ElectromagneticResult<?> removeTableInfoByRelatedId(String relatedId);
|
||||
|
||||
|
|
@ -19,13 +20,13 @@ public interface ImportTableService {
|
|||
|
||||
ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId);
|
||||
|
||||
ElectromagneticResult<?> addTableData(String tableInfoId, String tableData);
|
||||
String addTableData(String tableInfoId, String tableData);
|
||||
|
||||
ElectromagneticResult<?> removeTableDataById(String id);
|
||||
|
||||
ElectromagneticResult<?> updateTableData(String id, String tableHeader);
|
||||
|
||||
ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);
|
||||
RespPageVO selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1525,14 +1525,25 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode) {
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入工程
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
@Override
|
||||
// @Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> importPrj(MultipartFile file, String templateCode) {
|
||||
public ElectromagneticResult<?> importPrj1(MultipartFile file, String templateCode) {
|
||||
try {
|
||||
// 创建工程
|
||||
String prjId = updateImportPrj2Db(file);
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ public class ImportTableServiceImpl implements ImportTableService {
|
|||
private ImportTableInfoMapper importTableInfoMapper;
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> addTableInfo(String relatedId, Map<Integer, Object> tableHeader) {
|
||||
public String addTableInfo(String relatedId, Map<Integer, Object> tableHeader) {
|
||||
String id = IdWorker.getSnowFlakeIdString();
|
||||
ImportTableInfo importTableInfo = new ImportTableInfo()
|
||||
.setId(id)
|
||||
.setTableHeader(JSONUtil.toJsonStr(tableHeader))
|
||||
.setRelatedId(relatedId);
|
||||
importTableInfoMapper.insert(importTableInfo);
|
||||
return ElectromagneticResultUtil.success(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -95,11 +95,11 @@ public class ImportTableServiceImpl implements ImportTableService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> addTableData(String tableInfoId, String tableData) {
|
||||
public String addTableData(String tableInfoId, String tableData) {
|
||||
String id = IdWorker.getSnowFlakeIdString();
|
||||
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(tableData);
|
||||
importTableDataMapper.insert(importTableData);
|
||||
return ElectromagneticResultUtil.success(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -120,17 +120,17 @@ public class ImportTableServiceImpl implements ImportTableService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId) {
|
||||
public RespPageVO selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId) {
|
||||
Page<ImportTableData> importTableData = importTableDataMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.lambdaQuery(ImportTableData.class)
|
||||
.eq(ImportTableData::getTableInfoId, tableInfoId)
|
||||
.eq(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||
.orderByAsc(ImportTableData::getCreatedTime));
|
||||
long total = importTableData.getTotal();
|
||||
if (0 == total) {
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, List.of()));
|
||||
return new RespPageVO<>(total, List.of());
|
||||
}
|
||||
List<ImportTablePageDataVO> pageVo = BeanUtil.copyToList(importTableData.getRecords(), ImportTablePageDataVO.class);
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, pageVo));
|
||||
return new RespPageVO<>(total, pageVo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue