瀏覽代碼

icon列表添加caseId参数

lyhzzz 2 年之前
父節點
當前提交
1728fd5b98

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

@@ -37,7 +37,10 @@ public class HotIconController extends BaseController{
     UploadService uploadService;
 
     @GetMapping("/list")
-    public ResultData list(){
+    public ResultData list(@RequestParam(required = false) Integer caseId){
+        if(caseId!=null){
+            return ResultData.ok(hotIconService.getListByCaseId(caseId));
+        }
         String username = JwtUtil.getUsername(getToken());
         return ResultData.ok(hotIconService.getListByUserName(username));
     }

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/ICaseTagService.java

@@ -18,4 +18,6 @@ public interface ICaseTagService extends IService<CaseTag> {
     List<CaseTag> allList(Integer caseId, String tagTitle);
 
     void updateDFHotIcon(Integer iconId);
+
+    List<CaseTag> getListByCaseId(Integer caseId);
 }

+ 4 - 0
src/main/java/com/fdkankan/fusion/service/IHotIconService.java

@@ -22,4 +22,8 @@ public interface IHotIconService extends IService<HotIcon> {
     void addUseNum(Integer hotIconId);
 
     void cancelIsNew(String username);
+
+    List<HotIcon> getListByCaseId(Integer caseId);
+
+    List<HotIcon> getByIds(List<Integer> hotIconId);
 }

+ 7 - 0
src/main/java/com/fdkankan/fusion/service/impl/CaseTagServiceImpl.java

@@ -62,4 +62,11 @@ public class CaseTagServiceImpl extends ServiceImpl<ICaseTagMapper, CaseTag> imp
                 .set(CaseTag::getHotIconUrl,defaultIcon.getIconUrl());
         this.update(wrapper);
     }
+
+    @Override
+    public List<CaseTag> getListByCaseId(Integer caseId) {
+        LambdaQueryWrapper<CaseTag> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CaseTag::getCaseId,caseId);
+        return list(wrapper);
+    }
 }

+ 27 - 0
src/main/java/com/fdkankan/fusion/service/impl/HotIconServiceImpl.java

@@ -4,15 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.entity.CaseTag;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.entity.HotIcon;
 import com.fdkankan.fusion.mapper.IHotIconMapper;
+import com.fdkankan.fusion.service.ICaseTagService;
 import com.fdkankan.fusion.service.IHotIconService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -25,6 +30,9 @@ import java.util.List;
 @Service
 public class HotIconServiceImpl extends ServiceImpl<IHotIconMapper, HotIcon> implements IHotIconService {
 
+    @Autowired
+    ICaseTagService caseTagService;
+
     @Override
     public List<HotIcon> getListByUserName(String username) {
         LambdaQueryWrapper<HotIcon> wrapper = new LambdaQueryWrapper<>();
@@ -76,4 +84,23 @@ public class HotIconServiceImpl extends ServiceImpl<IHotIconMapper, HotIcon> imp
                 .eq(HotIcon::getUserName,username);
         this.update(wrapper);
     }
+
+    @Override
+    public List<HotIcon> getListByCaseId(Integer caseId) {
+        List<CaseTag> list = caseTagService.getListByCaseId(caseId);
+        if(list.size() >0){
+            List<Integer> hotIconId = list.parallelStream().map(CaseTag::getHotIconId).collect(Collectors.toList());
+            if(hotIconId.size() >0){
+                return this.getByIds(hotIconId);
+            }
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
+    public List<HotIcon> getByIds(List<Integer> hotIconId) {
+        LambdaQueryWrapper<HotIcon> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(HotIcon::getIconId,hotIconId);
+        return this.list(wrapper);
+    }
 }