Przeglądaj źródła

图标修改指定上限

lyhzzz 11 miesięcy temu
rodzic
commit
2233f04ab0

+ 6 - 1
src/main/java/com/fdkankan/fusion/common/ResultCode.java

@@ -64,7 +64,12 @@ public enum ResultCode {
     CASE_HAVE_SETTINGS(7019,"案件已有设置,无法新增"),
 
     SS_SCENE_DOWN_ERROR(7020,"深时点云场景下载失败"),
-    FILE_NOT_EXIST(7021,"文件不存在,或已被刪除");
+    FILE_NOT_EXIST(7021,"文件不存在,或已被刪除"),
+
+    HOST_ICON_LIMIT(7022,"案件图标超过上限")
+
+    ;
+
 
     public int code;
     public String msg;

+ 8 - 1
src/main/java/com/fdkankan/fusion/controller/HotIconController.java

@@ -49,10 +49,17 @@ public class HotIconController extends BaseController{
 
     @PostMapping("/add")
     public ResultData add(@RequestParam(required = false) MultipartFile file,
-                          @RequestParam(required = false) String iconTitle) throws IOException {
+                          @RequestParam(required = false) String iconTitle,
+                          @RequestParam(required = false) Integer caseId) throws IOException {
         if(file==null || StringUtils.isEmpty(iconTitle)){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
+        if(caseId != null){
+            List<HotIcon> hotIconList = hotIconService.getListByCaseId(caseId);
+            if(!hotIconList.isEmpty() && hotIconList.size() >=19){
+                throw new BusinessException(ResultCode.HOST_ICON_LIMIT);
+            }
+        }
 
         String iconUrl = uploadService.uploadFile(file, true, String.format(FilePath.ICON_OSS_PATH,environment,""));
 

+ 2 - 0
src/main/java/com/fdkankan/fusion/entity/HotIcon.java

@@ -55,6 +55,8 @@ public class HotIcon implements Serializable {
      */
     @TableField("is_new")
     private Integer isNew;
+    @TableField("case_id")
+    private Integer caseId;
 
     @TableField("tb_status")
     @TableLogic

+ 2 - 1
src/main/java/com/fdkankan/fusion/service/IHotIconService.java

@@ -3,6 +3,7 @@ package com.fdkankan.fusion.service;
 import com.fdkankan.fusion.entity.HotIcon;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.HashSet;
 import java.util.List;
 
 /**
@@ -25,5 +26,5 @@ public interface IHotIconService extends IService<HotIcon> {
 
     List<HotIcon> getListByCaseId(Integer caseId);
 
-    List<HotIcon> getByIds(List<Integer> hotIconId);
+    List<HotIcon> getByIds( HashSet<Integer> hotIconId);
 }

+ 20 - 6
src/main/java/com/fdkankan/fusion/service/impl/HotIconServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -87,19 +88,32 @@ public class HotIconServiceImpl extends ServiceImpl<IHotIconMapper, HotIcon> imp
 
     @Override
     public List<HotIcon> getListByCaseId(Integer caseId) {
-        List<Integer> hotIconId = new ArrayList<>();
+        HashSet<Integer> hotIconIds = new HashSet<>();
         List<CaseTag> list = caseTagService.getListByCaseId(caseId);
         if(list.size() >0){
-            hotIconId = list.parallelStream().map(CaseTag::getHotIconId).collect(Collectors.toList());
+            List<Integer> ids  = list.parallelStream().map(CaseTag::getHotIconId).collect(Collectors.toList());
+            if(!ids.isEmpty()){
+                hotIconIds.addAll(ids);
+            }
         }
-        hotIconId.add(getDefaultIcon().getIconId());
-        return this.getByIds(hotIconId);
+        hotIconIds.add(getDefaultIcon().getIconId());
+        LambdaQueryWrapper<HotIcon> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(HotIcon::getCaseId,caseId);
+        List<HotIcon> list1 = this.list(wrapper);
+        List<Integer> ids = list1.stream().map(HotIcon::getIconId).collect(Collectors.toList());
+        if(!ids.isEmpty()){
+            hotIconIds.addAll(ids);
+        }
+        if(hotIconIds.isEmpty()){
+            return new ArrayList<>();
+        }
+        return this.getByIds(hotIconIds);
     }
 
     @Override
-    public List<HotIcon> getByIds(List<Integer> hotIconId) {
+    public List<HotIcon> getByIds( HashSet<Integer> hotIconIds) {
         LambdaQueryWrapper<HotIcon> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(HotIcon::getIconId,hotIconId);
+        wrapper.in(HotIcon::getIconId,hotIconIds);
         wrapper.orderByDesc(HotIcon::getIsSystem)           // 官方默认
                 .orderByDesc(HotIcon::getIsNew)           // 新增
                 .orderByDesc(HotIcon::getLastUse)         // 上次使用