diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java index 4528209..e3dd405 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java @@ -1,7 +1,8 @@ package com.storeroom.modules.archives.controller; +import com.storeroom.exception.constant.ResponseStatus; import com.storeroom.modules.archives.service.ArchivesCaseService; -import com.storeroom.modules.dictionary.service.dto.CaseDTO; +import com.storeroom.modules.archives.service.dto.CaseDTO; import com.storeroom.utils.ApiResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -39,11 +40,13 @@ public class CaseController { public ApiResponse bingdingLabel( @Validated @RequestBody CaseDTO dto ){ - Integer bindingCount = caseService.findIsBingdingLabel(dto.getTid(),dto.getLabelType()); - if(bindingCount == 0){ - return ApiResponse.success(null); + String binding = caseService.findIsBingdingLabel(dto.getTid()); + String[] bindings = binding.split(","); + + if("0".equals(bindings[1]) || dto.getCoverLabel()){ + return ApiResponse.success(caseService.addCaseTag(dto.getId(),dto.getTid(),dto.getLabelType(),bindings[1],bindings[0])); }else{ - return ApiResponse.error(); + return ApiResponse.error(ResponseStatus.LABEL_BOUND); } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java index f6d3469..2b56a15 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java @@ -4,6 +4,7 @@ import com.storeroom.modules.archives.domain.ArchivesCase; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface ArchivesCaseRepository extends JpaRepository{ @@ -11,4 +12,8 @@ public interface ArchivesCaseRepository extends JpaRepository queryFields = archivesDictionaryRepository.findDisPlayField(categoryId); + queryFields.add("id"); String queryField = queryFields.stream().map(String::valueOf).collect(Collectors.joining(",")); String queryTable = archivesType.getEnName(); String quertOrder = ""; @@ -118,14 +119,14 @@ public class ArchivesServiceImpl implements ArchivesService { for(ArchivesDictionary archivesDictionary:showFiled){ //是否必填 if(archivesDictionary.getIsRequired()){ - if(null == json.get(archivesDictionary.getFieldName()) || "".equals(json.get(archivesDictionary.getFieldName()))){ + if(null == json.get(archivesDictionary.getFieldName()) || "null".equals(json.get(archivesDictionary.getFieldName())) || "".equals(json.get(archivesDictionary.getFieldName()))){ return archivesDictionary.getFieldName()+"不可为空!"; } } //是否重复 if(archivesDictionary.getIsRepeat()){ //判断是否为空 - if(null != json.get(archivesDictionary.getFieldName()) && !"".equals(json.get(archivesDictionary.getFieldName()))){ + if(null != json.get(archivesDictionary.getFieldName()) && !"".equals(json.get(archivesDictionary.getFieldName())) && !"null".equals(json.get(archivesDictionary.getFieldName()))){ String thissql = "select id,"+archivesDictionary.getFieldName()+" from "+archivesType.getEnName()+" where "+ archivesDictionary.getFieldName() +" = '"+json.get(archivesDictionary.getFieldName())+"'"; List list = entityManager.createNativeQuery(thissql).getResultList(); @@ -144,11 +145,11 @@ public class ArchivesServiceImpl implements ArchivesService { if(StringUtils.isEmpty(dto.getId())){ insertFiled +=archivesDictionary.getFieldName()+","; insertValue += archivesDictionary.getIsDataType() == 1 ? - null == json.get(archivesDictionary.getFieldName()) ? null+"," : "'"+json.get(archivesDictionary.getFieldName())+"'," + null == json.get(archivesDictionary.getFieldName()) || "null".equals(json.get(archivesDictionary.getFieldName())+"") ? null+"," : "'"+json.get(archivesDictionary.getFieldName())+"'," : json.get(archivesDictionary.getFieldName()) +","; }else { String thisValue = archivesDictionary.getIsDataType() == 1 ? - json.get(archivesDictionary.getFieldName()) == null ? null : "'" + json.get(archivesDictionary.getFieldName()) + "'" + json.get(archivesDictionary.getFieldName()) == null || "null".equals(json.get(archivesDictionary.getFieldName())+"") ? null : "'" + json.get(archivesDictionary.getFieldName()) + "'" : json.get(archivesDictionary.getFieldName()) + ""; updateValue += archivesDictionary.getFieldName() + "=" + thisValue + ","; } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/controller/DictrionaryController.java b/archives/src/main/java/com/storeroom/modules/dictionary/controller/DictrionaryController.java index 69586e5..3a7e3dd 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/controller/DictrionaryController.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/controller/DictrionaryController.java @@ -65,4 +65,13 @@ public class DictrionaryController { return ApiResponse.success(dictionaryService.findSubsetById(criteria.getId(),page)); } + @ApiOperation("根据字典id分页查询子集") + @GetMapping("/findAllSubsetById") +// @AnonymousGetMapping(value = "/findSubsetById") + public ApiResponse findAllSubsetById( + DictionaryQueryCriteria criteria + ){ + return ApiResponse.success(dictionaryService.findAllSubsetById(criteria.getId())); + } + } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/repository/DictionaryRepository.java b/archives/src/main/java/com/storeroom/modules/dictionary/repository/DictionaryRepository.java index 2d11fac..323a9b7 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/repository/DictionaryRepository.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/repository/DictionaryRepository.java @@ -17,6 +17,9 @@ public interface DictionaryRepository extends JpaRepository{ @Query(" from Dictionary order by dicSequence asc") List findAllOrderBy(); + @Query(" from Dictionary where dicPid = ?1 order by dicSequence asc") + List findAllByPidOrderBy(String pid); + @Query("select id from Dictionary where dicPid = ?1 ") List findAllByPid(String pid); diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/DictionaryService.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/DictionaryService.java index ca5f82b..54739bf 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/DictionaryService.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/DictionaryService.java @@ -17,4 +17,6 @@ public interface DictionaryService { void delete(String dictionaryId); //根据字典id查询子集 Object findSubsetById(String id, Pageable pageable); + //根据字典id查询所有子集 + Object findAllSubsetById(String id); } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DictionaryServiceImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DictionaryServiceImpl.java index d14f3d3..6e709db 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DictionaryServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DictionaryServiceImpl.java @@ -91,6 +91,36 @@ public class DictionaryServiceImpl implements DictionaryService { return PageUtil.toPage(pageMap); } + @Override + public List findAllSubsetById(String id) { + List menuList = new ArrayList<>(); + List dictionaryList = dictionaryRepository.findAllByPidOrderBy(id); + for (int i = 0; i < dictionaryList.size(); i++) { + Dictionary dictionary = dictionaryList.get(i); + menuList.add(BeanUtil.copyProperties(dictionary,DictionaryVO.class)); + } + for (DictionaryVO menu : menuList) { + menu.setChildMenus(getAllSubsetById(menu.getId())); + } + return menuList; + } + + public List getAllSubsetById(String pid){ + List menuList = new ArrayList<>(); + List dictionaryList = dictionaryRepository.findAllByPidOrderBy(pid); + if(dictionaryList.size() == 0){ + return null; + } + for (int i = 0; i < dictionaryList.size(); i++) { + Dictionary dictionary = dictionaryList.get(i); + menuList.add(BeanUtil.copyProperties(dictionary,DictionaryVO.class)); + } + for (DictionaryVO menu : menuList) { + menu.setChildMenus(getAllSubsetById(menu.getId())); + } + return menuList; + } + private List getChildId(String id,List deleteIds){ if(null == id){ return deleteIds; diff --git a/common/src/main/java/com/storeroom/exception/constant/ResponseStatus.java b/common/src/main/java/com/storeroom/exception/constant/ResponseStatus.java index 29e7aaf..63dce74 100644 --- a/common/src/main/java/com/storeroom/exception/constant/ResponseStatus.java +++ b/common/src/main/java/com/storeroom/exception/constant/ResponseStatus.java @@ -20,7 +20,9 @@ public enum ResponseStatus { //token 为空 TOKEN_IS_NULL(4002,"找不到当前登录信息"), //Field重复 - FIELD_REPEAT(5001,"当前字段重复"); + FIELD_REPEAT(5001,"当前字段重复"), + //当前标签已被绑定 + LABEL_BOUND(6201,"当前标签已被绑定");