diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java b/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java index 1e319c8..554cf53 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java @@ -4,14 +4,18 @@ package com.storeroom.modules.dictionary.controller; import com.storeroom.annotaion.rest.AnonymousGetMapping; import com.storeroom.annotaion.rest.AnonymousPostMapping; import com.storeroom.exception.BaseException; +import com.storeroom.exception.constant.ResponseStatus; import com.storeroom.modules.common.ArchivesTypeEnum; +import com.storeroom.modules.dictionary.service.ArchivesDictionaryService; import com.storeroom.modules.dictionary.service.ArchivesTypeService; +import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import com.storeroom.utils.ApiResponse; import com.storeroom.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,6 +30,7 @@ import java.util.*; public class ArchivesTypeController { private final ArchivesTypeService archivesTypeService; + private final ArchivesDictionaryService archivesDictionaryService; @ApiOperation("门类类型") @@ -36,7 +41,7 @@ public class ArchivesTypeController { list.put(ArchivesTypeEnum.project.getCode(), ArchivesTypeEnum.project.getType()); list.put(ArchivesTypeEnum.archives.getCode(), ArchivesTypeEnum.archives.getType()); list.put(ArchivesTypeEnum.inChive.getCode(), ArchivesTypeEnum.inChive.getType()); - list.put(ArchivesTypeEnum.files.getCode(), ArchivesTypeEnum.folder.getType()); + list.put(ArchivesTypeEnum.files.getCode(), ArchivesTypeEnum.files.getType()); list.put(ArchivesTypeEnum.Template.getCode(), ArchivesTypeEnum.Template.getType()); return ApiResponse.success(list); } @@ -45,13 +50,13 @@ public class ArchivesTypeController { @AnonymousPostMapping("create") //TODO:权限未添加 public ApiResponse save(@RequestBody ArchivesTypeDTO archivesTypeDTO) { - if (archivesTypeDTO.getId() != null) { + if (!StringUtils.isEmpty(archivesTypeDTO.getId())) { throw new BaseException("this is not empty Data"); } if (archivesTypeDTO.getIsType() == null) { throw new BaseException("type cannot be Null"); } - if (archivesTypeDTO.getCnName().isEmpty()) { + if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) { throw new BaseException("Name canot be null"); } archivesTypeService.create(archivesTypeDTO); @@ -64,4 +69,33 @@ public class ArchivesTypeController { public ApiResponse getMenuTree() { return ApiResponse.success(archivesTypeService.buildTree()); } + + + @ApiOperation("门类字段管理") + @AnonymousGetMapping("manage") + public ApiResponse getFieldName(String categoryId) { + if (!StringUtils.isEmpty(categoryId)) { + return ApiResponse.success(archivesDictionaryService.getAll(categoryId)); + } + throw new BaseException("id异常"); + } + + @ApiOperation("通过id查询门类字典") + @AnonymousGetMapping("query") + public ApiResponse getArcDic(String arcdicId) { + if (!StringUtils.isEmpty(arcdicId)) { + return ApiResponse.success(archivesDictionaryService.findById(arcdicId)); + } + throw new BaseException("id异常"); + } + + @ApiOperation("修改数据") + @AnonymousPostMapping("update") + public ApiResponse update(@RequestBody ArchivesDictionaryDTO arcdicDto) { + if (!StringUtils.isEmpty(arcdicDto.getId())) { + archivesDictionaryService.update(arcdicDto); + return ApiResponse.success(ResponseStatus.SUCCESS); + } + throw new BaseException("id异常"); + } } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java b/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java index 0a7f4df..4a64b5e 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java @@ -28,4 +28,13 @@ public interface ArchivesDictionaryRepository extends JpaRepository findDisPlay(String categoryId); + /** + * 通过门类id查询 + * @param categoryId + * @return + */ + List findByCategoryId(String categoryId); + + + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java index b4bf6ec..27e7d08 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java @@ -2,6 +2,7 @@ package com.storeroom.modules.dictionary.service; import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; +import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import java.util.List; @@ -12,4 +13,28 @@ public interface ArchivesDictionaryService { * @param list */ void saveAll(List list); + + + + /** + * 获取所有门类字典字段 + * @return + */ + List getAll(String categoryId); + + + /** + * 通过id 查询字段数据 + * @param adId 字典id + * @return + */ + ArchivesDictionaryDTO findById(String adId); + + /** + * 修改保存 + * @param + * @return + */ + void update(ArchivesDictionaryDTO arcdicDto); + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java index 2627270..6aaf156 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesTypeService.java @@ -1,6 +1,7 @@ package com.storeroom.modules.dictionary.service; + import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import java.util.List; @@ -24,4 +25,7 @@ public interface ArchivesTypeService { + + + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java index 961fe3f..985cf6f 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java @@ -1,12 +1,15 @@ package com.storeroom.modules.dictionary.service.impl; +import com.storeroom.exception.BaseException; import com.storeroom.modules.dictionary.domain.ArchivesDictionary; import com.storeroom.modules.dictionary.repository.ArchivesDictionaryRepository; import com.storeroom.modules.dictionary.service.ArchivesDictionaryService; import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; +import com.storeroom.modules.dictionary.service.dto.ArchivesTypeDTO; import com.storeroom.modules.dictionary.service.mapstruct.ArchivesDictionaryMapper; import com.storeroom.utils.NanoIdUtils; +import com.storeroom.utils.ValidationUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -25,14 +28,67 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService { @Override @Transactional(rollbackFor = Exception.class) public void saveAll(List list) { - List list1=new ArrayList<>(); + List list1 = new ArrayList<>(); for (ArchivesDictionaryDTO o : list) { ArchivesDictionary a = archivesDictionaryMapper.toEntity(o); a.setId(NanoIdUtils.randomNanoId()); - //this.archivesDictionaryRepository.saveAndFlush(a); - list1.add(a); + // archivesDictionaryRepository.save(a); + list1.add(a); } archivesDictionaryRepository.saveAll(list1); } + + @Override + public List getAll(String categoryId) { + return archivesDictionaryMapper.toDto(archivesDictionaryRepository.findByCategoryId(categoryId)); + } + + @Override + public ArchivesDictionaryDTO findById(String adId) { + return archivesDictionaryMapper.toDto(archivesDictionaryRepository.findById(adId).orElseGet(ArchivesDictionary::new)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ArchivesDictionaryDTO arcdicDto){ + ArchivesDictionary dictionary = archivesDictionaryMapper.toEntity(arcdicDto); + + ArchivesDictionary dictionary1 = archivesDictionaryRepository.findById(dictionary.getId()).orElseGet(ArchivesDictionary::new); + + ValidationUtil.isNull(dictionary1.getId(), "ArchivesDictionary", "id", dictionary.getId()); + + + dictionary1.setFieldName(dictionary.getFieldName()); + dictionary1.setFieldCnName(dictionary.getFieldCnName()); + dictionary1.setIsDefaultValue(dictionary.getIsDefaultValue()); + dictionary1.setIsInput(dictionary.getIsInput()); + dictionary1.setIsInputClass(dictionary.getIsInputClass()); + dictionary1.setIsDataTypeDetails(dictionary.getIsDataTypeDetails()); + dictionary1.setIsColumnLength(dictionary.getIsColumnLength()); + dictionary1.setIsColumnType(dictionary.getIsColumnType()); + dictionary1.setIsSequence(dictionary.getIsSequence()); + dictionary1.setIsType(dictionary.getIsType()); + dictionary1.setIsSystem(dictionary.getIsSystem()); + dictionary1.setIsLine(dictionary.getIsLine()); + dictionary1.setIsInput(dictionary.getIsInput()); + dictionary1.setIsRequired(dictionary.getIsRequired()); + dictionary1.setIsAutomatic(dictionary.getIsAutomatic()); + dictionary1.setIsAdd(dictionary.getIsAdd()); + dictionary1.setIsSearch(dictionary.getIsSearch()); + dictionary1.setIsInherit(dictionary.getIsInherit()); + dictionary1.setIsFilling(dictionary.getIsFilling()); + dictionary1.setFillingDigit(dictionary.getFillingDigit()); + dictionary1.setIsRepeat(dictionary.getIsRepeat()); + dictionary1.setIsDisplay(dictionary.getIsDisplay()); + dictionary1.setDisplayOrder(dictionary.getDisplayOrder()); + dictionary1.setIsDisplayformat(dictionary.getIsDisplayformat()); + dictionary1.setEditLength(dictionary.getEditLength()); + dictionary1.setDisplayformatType(dictionary.getDisplayformatType()); + dictionary1.setDisplayLength(dictionary.getDisplayLength()); + archivesDictionaryRepository.save(dictionary1); + + } + + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java index 228c6f0..0047f4e 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java @@ -75,4 +75,6 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { } return trees; } + + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java index 881a968..c31f17d 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java @@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -78,10 +79,11 @@ public class DynamicTableImpl implements DynamicTableService { * @param list * @param archiveTypeId */ + private void DynamicInsert(List list, String archiveTypeId) { List newList = new ArrayList<>(); - ArchivesDictionaryDTO archivesDictionaryDTO = new ArchivesDictionaryDTO(); for (FieldVO j : list) { + ArchivesDictionaryDTO archivesDictionaryDTO = new ArchivesDictionaryDTO(); j.setCategoryId(archiveTypeId); archivesDictionaryDTO.setFieldName(j.getFieldName()); archivesDictionaryDTO.setFieldCnName(j.getFieldCnName()); @@ -95,6 +97,8 @@ public class DynamicTableImpl implements DynamicTableService { archivesDictionaryDTO.setIsSystem(j.getIsSystem()); newList.add(archivesDictionaryDTO); } + + archivesDictionaryService.saveAll(newList); }