Browse Source

fix bug

master
刘力 3 years ago
parent
commit
4f5e52e73a
  1. 9
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java
  2. 9
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java
  3. 9
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java
  4. 9
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java
  5. 8
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java
  6. 7
      system/src/main/resources/application.yml

9
archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java

@ -58,13 +58,13 @@ public class ArchivesTypeController {
//TODO:权限未添加
public ApiResponse<Object> save(@RequestBody ArchivesTypeDTO archivesTypeDTO) {
if (!StringUtils.isEmpty(archivesTypeDTO.getId())) {
throw new BaseException("this is not empty Data");
throw new BaseException("id不为空");
}
if (archivesTypeDTO.getIsType() == null) {
throw new BaseException("type cannot be Null");
throw new BaseException("类型不能为空");
}
if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) {
throw new BaseException("Name canot be null");
throw new BaseException("名称不能为空");
}
archivesTypeService.create(archivesTypeDTO);
return ApiResponse.success("保存成功");
@ -139,17 +139,14 @@ public class ArchivesTypeController {
if (StringUtils.isEmpty(arcdicDto.getIsDataTypeDetails())) {
throw new BaseException("数据类型不能为空");
}
archivesDictionaryService.create(arcdicDto);
return ApiResponse.success(ResponseStatus.SUCCESS);
}
@ApiOperation("获取档案配置下拉列表")
@AnonymousGetMapping("arc-config")
public ApiResponse<Object> getArcConfig() {
return ApiResponse.success(dictionaryService.findDictrionaryMenu());
}
@ApiOperation("删除门类字典字段")

9
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java

@ -51,4 +51,13 @@ public interface ArchivesDictionaryService {
*/
void delete(String id);
/**
* 字段字典排序
* @param archivesDictionaryDTO /
* @return /
*/
ArchivesDictionaryDTO upSort(ArchivesDictionaryDTO archivesDictionaryDTO);
}

9
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

@ -106,5 +106,14 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
archivesDictionaryRepository.deleteById(id);
}
@Override
public ArchivesDictionaryDTO upSort(ArchivesDictionaryDTO archivesDictionaryDTO) {
ArchivesDictionary archivesDictionary = archivesDictionaryMapper.toEntity(archivesDictionaryDTO);
ArchivesDictionary archivesDictionary1 = archivesDictionaryRepository.findById(archivesDictionary.getId()).orElseGet(ArchivesDictionary::new);
archivesDictionary1.setIsSequence(archivesDictionary.getIsSequence());
archivesDictionaryRepository.save(archivesDictionary1);
return archivesDictionaryMapper.toDto(archivesDictionary1);
}
}

9
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -11,6 +11,7 @@ import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO;
import com.storeroom.modules.dictionary.service.mapstruct.ArchivesTypeMapper;
import com.storeroom.utils.DateUtils;
import com.storeroom.utils.NanoIdUtils;
import com.storeroom.utils.SpringUtils;
import com.storeroom.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
@ -33,13 +34,14 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
private final ArchivesTypeRepository archivesTypeRepository;
private final DynamicTableService dynamicTableService;
@Value("${table-template.archive}")
private String tableName;
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ArchivesTypeDTO archivesTypeDTO) {
//#生成表名称
String tableName="tb_";
ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO);
List<ArchivesType> archivesType1 = archivesTypeRepository.findByCnName(archivesType.getCnName());
if (archivesType1.size() == 0) {
@ -48,6 +50,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
archivesType.setEnName(tableName);
archivesTypeRepository.save(archivesType);
dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName);
} else {
throw new BaseException("门类名称不能重复");
}
@ -60,7 +63,9 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
List<ArchivesTypeDTO> trees = new ArrayList<>();
Set<String> ids = new HashSet<>();
for (ArchivesTypeDTO archivesTypeDTO : archivesTypeDTOS) {
//如果父节点id为空就是一级菜单
if (archivesTypeDTO.getPid() == null) {
//直接加入树列表
trees.add(archivesTypeDTO);
}
for (ArchivesTypeDTO at : archivesTypeDTOS) {

8
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java

@ -30,14 +30,15 @@ public class DynamicTableImpl implements DynamicTableService {
private final JdbcTemplate jdbcTemplate;
@Value("${table-template.file}")
private String fileTableName;
@Override
public void DynamicCreate(Integer type, String archiveTypeId, String tableName) {
List<Integer> integerList = new ArrayList<>();
if (type == 4 || type == 5) {
//#生成文件表名称
String fileTableName="file_tb_";
integerList.add(1);
integerList.add(2);
@ -57,6 +58,7 @@ public class DynamicTableImpl implements DynamicTableService {
List<FieldVO> fieldList = fieldService.findGroupType(integerList);
DynamicInsert(fieldList, archiveTypeId);
DynamicCreateFileTable(fieldList, tableName);
}
}
@ -95,7 +97,7 @@ public class DynamicTableImpl implements DynamicTableService {
archivesDictionaryDTO.setIsSequence(j.getIsSequence());
archivesDictionaryDTO.setIsType(j.getIsType());
archivesDictionaryDTO.setIsSystem(j.getIsSystem());
archivesDictionaryDTO.setIsColumnType(j.getIsType()==3?2:1);
archivesDictionaryDTO.setIsColumnType(j.getIsType() == 3 ? 2 : 1);
newList.add(archivesDictionaryDTO);
}

7
system/src/main/resources/application.yml

@ -76,9 +76,4 @@ user-cache:
hand-held:
ip: 47.98.148.152:8057
# 生成表模板
table-template:
#生成表名称
archive: tb_
#生成文件表
file: file_tb_
Loading…
Cancel
Save