소스 검색

Merge remote-tracking branch 'origin/master'

TRX 1 년 전
부모
커밋
1055532188

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/dictionary/AddDictionaryItemParam.java

@@ -7,6 +7,8 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.Map;
+
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
@@ -37,4 +39,6 @@ public class AddDictionaryItemParam {
     @Schema(name = "sort", description = "排序", example = "1")
     private Integer sort = 1;
 
+    @Schema(name = "meta", description = "扩展字段", example = "{\"location\" : \"154.25.25233\"}")
+    private Map<String, Object> meta;
 }

+ 5 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/dictionary/AddDictionaryParam.java

@@ -8,6 +8,8 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.Map;
+
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
@@ -39,4 +41,7 @@ public class AddDictionaryParam {
 
     @Schema(name = "disabled", description = "状态", example = "false")
     private boolean disabled;
+
+    @Schema(name = "meta", description = "扩展字段", example = "{\"location\" : \"154.25.25233\"}")
+    private Map<String, Object> meta;
 }

+ 4 - 3
FullCardClient/src/main/java/com/zhongshu/card/client/model/dictionary/DictionaryItemModel.java

@@ -5,9 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import org.springframework.stereotype.Indexed;
 
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
+import java.util.*;
 
 @Data
 public class DictionaryItemModel {
@@ -49,6 +47,9 @@ public class DictionaryItemModel {
     @Schema(description = "状态")
     private boolean disable;
 
+    @Schema(description = "扩展字段")
+    private Map<String, Object> meta = new HashMap<>();
+
     private List<DictionaryItemModel> children = new ArrayList<>();
 
 

+ 6 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/dictionary/DictionaryModel.java

@@ -5,6 +5,9 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import org.springframework.stereotype.Indexed;
 
+import java.util.HashMap;
+import java.util.Map;
+
 @Data
 public class DictionaryModel {
 
@@ -36,4 +39,7 @@ public class DictionaryModel {
     //启动/禁用
     @Schema(description = "状态")
     private boolean disabled;
+
+    @Schema(description = "拓展字段")
+    private Map<String, Object> meta = new HashMap<>();
 }

+ 4 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/dictionary/Dictionary.java

@@ -14,6 +14,8 @@ import org.springframework.data.mongodb.core.index.Indexed;
 import org.springframework.data.mongodb.core.mapping.Document;
 import org.springframework.stereotype.Controller;
 
+import java.util.Map;
+
 @Data
 @Document
 @AllArgsConstructor
@@ -45,4 +47,6 @@ public class Dictionary extends SuperEntity {
     @Indexed
     private boolean disabled;
 
+    @Indexed
+    private Map<String, Object> meta;
 }

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/dictionary/DictionaryItem.java

@@ -12,6 +12,8 @@ import org.springframework.data.mongodb.core.index.Indexed;
 import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.util.Map;
+
 @Data
 @Document
 @AllArgsConstructor
@@ -51,4 +53,7 @@ public class DictionaryItem extends SuperEntity {
     @Indexed
     private boolean disable;
 
+    @Indexed
+    private Map<String, Object> meta;
+
 }

+ 20 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/dictionary/DictionaryService.java

@@ -53,17 +53,17 @@ public class DictionaryService extends SuperService {
      * @return
      */
     public ResultContent addDictionary(AddDictionaryParam param){
-        Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getKey());
-        if (byProjectIdAndKey != null){
-            return ResultContent.buildFail("字典编码已存在");
-        }
-
         if (StringUtils.isNotBlank(param.getId())){
             UpdateDictionaryParam updateParam = new UpdateDictionaryParam();
             BeanUtils.copyProperties(param, updateParam);
             return updateDictionary(updateParam);
         }
 
+        Dictionary byProjectIdAndKey = dictionaryDao.findTopByProjectIdAndKey(param.getProjectId(), param.getKey());
+        if (byProjectIdAndKey != null){
+            return ResultContent.buildFail("字典编码已存在");
+        }
+
         Dictionary dictionary = new Dictionary();
 
         BeanUtils.copyProperties(param, dictionary);
@@ -95,7 +95,7 @@ public class DictionaryService extends SuperService {
         if (byProjectIdAndKey != null && !byProjectIdAndKey.getId().equals(param.getId())){
             return ResultContent.buildFail("字典编码已存在");
         }
-        com.zhongshu.card.server.core.util.BeanUtils.copyPropertiesWithoutNull(param, dictionary);
+        com.zhongshu.card.server.core.util.BeanUtils.copyProperties(param, dictionary,"id");
         dictionaryDao.save(dictionary);
         return ResultContent.buildSuccess();
     }
@@ -141,6 +141,11 @@ public class DictionaryService extends SuperService {
      * 添加项
      */
     public ResultContent addItem(AddDictionaryItemParam param){
+
+
+        if (StringUtils.isNotBlank(param.getId())){
+            return updateItem(param);
+        }
         Dictionary dictionary = dictionaryDao.findTopById(param.getDictionaryId());
         if (dictionary == null){
             return ResultContent.buildFail("字典不存在");
@@ -150,6 +155,11 @@ public class DictionaryService extends SuperService {
             return ResultContent.buildFail("标准字典不允许添加项");
         }
 
+        DictionaryItem updateItem = dictionaryItemDao.findTopByDictionary_IdAndKey(param.getDictionaryId(), param.getKey());
+        if (updateItem != null && !updateItem.getId().equals(param.getId())){
+            return ResultContent.buildFail("项编码已存在");
+        }
+
         DictionaryItem dictionaryItem = new DictionaryItem();
         BeanUtils.copyProperties(param, dictionaryItem, "id");
         dictionaryItem.setType(DictionaryType.Customize);
@@ -158,6 +168,10 @@ public class DictionaryService extends SuperService {
         dictionaryItem.setId(id);
         dictionaryItem.setIdString(id);
         dictionaryItem.setCreateTime(System.currentTimeMillis());
+
+        if (StringUtils.isEmpty(param.getParentId())){
+            dictionaryItem.setParentId(null);
+        }
         dictionaryItemDao.save(dictionaryItem);
         return ResultContent.buildSuccess();
     }