开发完相关代码,等待测试
This commit is contained in:
parent
ca8b954dce
commit
647f68c2bb
|
|
@ -0,0 +1,47 @@
|
|||
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.manage.pojo.req.AddImportTableDataDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateImportTableDataDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.ImportTableService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/struct/table")
|
||||
public class ImportTableController {
|
||||
|
||||
@Resource
|
||||
private ImportTableService importTableService;
|
||||
|
||||
@GetMapping("/query")
|
||||
@UserOperation(value = "查询结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||
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);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@UserOperation(value = "新增结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||
public ElectromagneticResult<?> add(@RequestBody AddImportTableDataDTO addImportTableDataDTO) {
|
||||
return importTableService.addTableData(addImportTableDataDTO.getTableInfoId(), addImportTableDataDTO.getTableData());
|
||||
}
|
||||
|
||||
@GetMapping("/remove")
|
||||
@UserOperation(value = "删除结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||
public ElectromagneticResult<?> remove(@RequestParam String id) {
|
||||
return importTableService.removeTableDataById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@UserOperation(value = "更新结构化数据", modelName = UserOperationModuleEnum.STRUCT_DATA)
|
||||
public ElectromagneticResult<?> update(@RequestBody UpdateImportTableDataDTO updateImportTableDataDTO) {
|
||||
return importTableService.updateTableData(updateImportTableDataDTO.getId(), updateImportTableDataDTO.getTableData());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableData;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ImportTableDataMapper extends BaseMapper<ImportTableData> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.electromagnetic.industry.software.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ImportTableInfoMapper extends BaseMapper<ImportTableInfo> {
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("import_table_data")
|
||||
@Accessors(chain = true)
|
||||
public class ImportTableData extends BaseModel {
|
||||
|
||||
private String id;
|
||||
|
||||
private String tableInfoId;
|
||||
|
||||
private String data;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("import_table_info")
|
||||
@Accessors(chain = true)
|
||||
public class ImportTableInfo extends BaseModel {
|
||||
|
||||
private String id;
|
||||
|
||||
private String tableHeader;
|
||||
|
||||
private String relatedId;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class AddImportTableDataDTO {
|
||||
|
||||
private String tableInfoId;
|
||||
private Map<Integer, Object> tableData;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class UpdateImportTableDataDTO {
|
||||
private String id;
|
||||
private Map<Integer, Object> tableData;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ImportTablePageDataVO {
|
||||
private String id;
|
||||
|
||||
private String tableInfoId;
|
||||
|
||||
private String data;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.electromagnetic.industry.software.manage.service;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ImportTableService {
|
||||
|
||||
ElectromagneticResult<?> addTableInfo(String relatedId, Map<Integer, Object> tableHeader);
|
||||
|
||||
ElectromagneticResult<?> removeTableInfoByRelatedId(String relatedId);
|
||||
|
||||
ImportTableInfo selectByIdRelatedId(String relatedId);
|
||||
|
||||
ElectromagneticResult<?> removeTableInfoById(String id);
|
||||
|
||||
ElectromagneticResult<?> updateTableInfo();
|
||||
|
||||
ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId);
|
||||
|
||||
ElectromagneticResult<?> addTableData(String tableInfoId, Map<Integer, Object> tableData);
|
||||
|
||||
ElectromagneticResult<?> removeTableDataById(String id);
|
||||
|
||||
ElectromagneticResult<?> updateTableData(String id, Map<Integer, Object> tableHeader);
|
||||
|
||||
ElectromagneticResult<?> selectTableDataByTableInfoId(Integer pageNum, Integer pageSize, String tableInfoId);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ import com.electromagnetic.industry.software.common.enums.FilePermission;
|
|||
import com.electromagnetic.industry.software.common.enums.*;
|
||||
import com.electromagnetic.industry.software.common.exception.BizException;
|
||||
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
|
||||
import com.electromagnetic.industry.software.common.pojo.ImportTableInfoVO;
|
||||
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.*;
|
||||
|
|
@ -88,6 +89,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
private RolePermissionService rolePermissionService;
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
@Resource
|
||||
private ImportTableService importTableService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询文件列表
|
||||
|
|
@ -97,6 +101,22 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
*/
|
||||
@Override
|
||||
public ElectromagneticResult<?> queryEdFileInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
||||
ImportTableInfo importTableInfo = queryTableInfo(pars, dataOwnCode);
|
||||
if (Objects.nonNull(Optional.ofNullable(importTableInfo).map(ImportTableInfo::getTableHeader).orElse(null))) {
|
||||
ImportTableInfoVO importTableInfoVO = BeanUtil.toBean(importTableInfo, ImportTableInfoVO.class);
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(importTableInfoVO));
|
||||
}
|
||||
return queryInfo(pars, dataOwnCode);
|
||||
}
|
||||
|
||||
private ImportTableInfo queryTableInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
||||
String relatedId = pars.getParentId();
|
||||
return importTableService.selectByIdRelatedId(relatedId);
|
||||
}
|
||||
|
||||
|
||||
private ElectromagneticResult<?> queryInfo(FileInfoQueryDTO pars, int dataOwnCode) {
|
||||
|
||||
if (DataOwnEnum.isSysCode(dataOwnCode)) {
|
||||
String parentId = pars.getParentId();
|
||||
List<String> accessibleTree = permissionService.getAccessibleTree();
|
||||
|
|
@ -170,6 +190,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, records));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新建文件夹
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||
import com.electromagnetic.industry.software.common.pojo.RespPageVO;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||
import com.electromagnetic.industry.software.manage.mapper.ImportTableDataMapper;
|
||||
import com.electromagnetic.industry.software.manage.mapper.ImportTableInfoMapper;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableData;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.ImportTableInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.ImportTablePageDataVO;
|
||||
import com.electromagnetic.industry.software.manage.service.ImportTableService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ImportTableServiceImpl implements ImportTableService {
|
||||
|
||||
@Resource
|
||||
private ImportTableDataMapper importTableDataMapper;
|
||||
@Resource
|
||||
private ImportTableInfoMapper importTableInfoMapper;
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> removeTableInfoByRelatedId(String relatedId) {
|
||||
// 删除table_info相关信息
|
||||
LambdaQueryWrapper<ImportTableInfo> wrapper = Wrappers.lambdaQuery(ImportTableInfo.class)
|
||||
.select(ImportTableInfo::getId)
|
||||
.eq(ImportTableInfo::getRelatedId, relatedId)
|
||||
.eq(ImportTableInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
List<String> ids = importTableInfoMapper.selectList(wrapper).stream().map(ImportTableInfo::getId).toList();
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
importTableInfoMapper.update(new ImportTableInfo(), Wrappers.<ImportTableInfo>lambdaUpdate()
|
||||
.set(ImportTableInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.in(ImportTableInfo::getId, ids));
|
||||
// 删除table_data相关信息
|
||||
importTableDataMapper.update(new ImportTableData(), Wrappers.<ImportTableData>lambdaUpdate()
|
||||
.in(ImportTableData::getTableInfoId, ids)
|
||||
.set(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImportTableInfo selectByIdRelatedId(String relatedId) {
|
||||
return importTableInfoMapper.selectOne(Wrappers.<ImportTableInfo>lambdaQuery()
|
||||
.eq(ImportTableInfo::getRelatedId, relatedId)
|
||||
.eq(ImportTableInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> removeTableInfoById(String id) {
|
||||
importTableInfoMapper.update(new ImportTableInfo(), Wrappers.<ImportTableInfo>lambdaUpdate()
|
||||
.set(ImportTableInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||
.eq(ImportTableInfo::getId, id));
|
||||
importTableDataMapper.update(new ImportTableData(), Wrappers.<ImportTableData>lambdaUpdate()
|
||||
.eq(ImportTableData::getTableInfoId, id)
|
||||
.set(ImportTableData::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> updateTableInfo() {
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> selectTableInfoByRelatedId(String relatedId) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> addTableData(String tableInfoId, Map<Integer, Object> tableData) {
|
||||
String id = IdWorker.getSnowFlakeIdString();
|
||||
ImportTableData importTableData = new ImportTableData().setId(id).setTableInfoId(tableInfoId).setData(JSONUtil.toJsonStr(tableData));
|
||||
importTableDataMapper.insert(importTableData);
|
||||
return ElectromagneticResultUtil.success(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> removeTableDataById(String id) {
|
||||
importTableDataMapper.update(new ImportTableData(), Wrappers.<ImportTableData>lambdaUpdate()
|
||||
.eq(ImportTableData::getId, id)
|
||||
.set(ImportTableData::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> updateTableData(String id, Map<Integer, Object> tableHeader) {
|
||||
importTableDataMapper.update(new ImportTableData(), Wrappers.<ImportTableData>lambdaUpdate()
|
||||
.eq(ImportTableData::getId, id)
|
||||
.set(ImportTableData::getData, JSONUtil.toJsonStr(tableHeader)));
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectromagneticResult<?> 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));
|
||||
long total = importTableData.getTotal();
|
||||
if (0 == total) {
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, List.of()));
|
||||
}
|
||||
List<ImportTablePageDataVO> pageVo = BeanUtil.copyToList(importTableData.getRecords(), ImportTablePageDataVO.class);
|
||||
return ElectromagneticResultUtil.success(new RespPageVO<>(total, pageVo));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ public enum UserOperationModuleEnum {
|
|||
|
||||
USER("user", "人员管理"),
|
||||
|
||||
STRUCT_DATA("struct_data", "结构化数据"),
|
||||
|
||||
TAG("tag", "标签管理"),
|
||||
LOG("log", "操作记录审计"),
|
||||
TMP("tmp", "临时文件"),
|
||||
|
|
@ -26,6 +28,7 @@ public enum UserOperationModuleEnum {
|
|||
FILE_FORMAT("file_format", "文件格式"),
|
||||
FILE_RELATION("file_relation", "文件关系");
|
||||
|
||||
|
||||
public final String key;
|
||||
public final String desc;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.electromagnetic.industry.software.common.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ImportTableInfoVO {
|
||||
String id;
|
||||
String tableHeader;
|
||||
String relatedId;
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.electromagnetic.industry.software.common.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
|
@ -8,7 +7,6 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class RespPageVO<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -17,4 +15,18 @@ public class RespPageVO<T> implements Serializable {
|
|||
|
||||
private List<T> records;
|
||||
|
||||
private boolean struct = false;
|
||||
|
||||
private ImportTableInfoVO importTableInfoVO;
|
||||
|
||||
public RespPageVO(long total, List<T> records) {
|
||||
this.struct = false;
|
||||
this.total = total;
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
public RespPageVO(ImportTableInfoVO importTableInfoVO) {
|
||||
this.struct = true;
|
||||
this.importTableInfoVO = importTableInfoVO;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue