Kaynağa Gözat

首页的问题管理代码调整

jiawuxian 1 yıl önce
ebeveyn
işleme
d777043a86

+ 1 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/question/service/IQuestionService.java

@@ -70,6 +70,7 @@ public interface IQuestionService extends IService<Question> {
      */
     List<PanelListVo> selectCurUserTaskList(PanelListDto panelListDto);
 
+
     WebPanelResult selectWebIndexData(PanelListDto req);
     WebPanelResult selectWebIndexData2(PanelListDto req);
 }

+ 51 - 11
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/question/service/impl/QuestionServiceImpl.java

@@ -330,12 +330,20 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         EasyExcel.write(response.getOutputStream(), QuestionExportDto.class).sheet("Sheet1").doWrite(list);
     }
 
+    /**
+     * 待确认
+     *
+     * @param req
+     * @return
+     */
     @Override
     public WebPanelResult selectWebIndexData(PanelListDto req) {
-        final int waitConfirm = baseMapper.selectCount(new LambdaQueryWrapper<Question>()
-                        .eq(Question::getOrgId, req.getOrgId())
-                        .eq(Question::getConfirmStatus, 0))
-                        .intValue();
+        Long confirmButton = 2353L;
+        LambdaQueryWrapper<Question> wrapper = generateCurUserTaskWrapper(req, confirmButton, null, null);
+        int waitConfirm = 0;
+        if (!wrapper.isEmptyOfWhere()) {
+            waitConfirm = baseMapper.selectCount(wrapper).intValue();
+        }
 
         return WebPanelResult
                 .builder()
@@ -346,12 +354,20 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 .nums(waitConfirm).build();
     }
 
+    /**
+     * 待整改
+     *
+     * @param req
+     * @return
+     */
     @Override
     public WebPanelResult selectWebIndexData2(PanelListDto req) {
-        final int waitRectification = baseMapper.selectCount(new LambdaQueryWrapper<Question>()
-                        .eq(Question::getOrgId, req.getOrgId())
-                        .eq(Question::getReformStatus, 10))
-                .intValue();
+        LambdaQueryWrapper<Question> wrapper = generateCurUserTaskWrapper(req, null, null, 2355L);
+        int waitRectification = 0;
+        if (!wrapper.isEmptyOfWhere()) {
+            waitRectification = baseMapper.selectCount(wrapper).intValue();
+        }
+
         return WebPanelResult
                 .builder()
                 .status(10)
@@ -369,12 +385,30 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
      */
     @Override
     public List<PanelListVo> selectCurUserTaskList(PanelListDto panelListDto) {
-        LambdaQueryWrapper<Question> wrapper = new LambdaQueryWrapper<>();
         Long confirmButton = 2353L;
         Long dissentButton = 2354L;
         Long reformButton = 2355L;
-        List<Long> ownPermission = remoteUserService.checkUserPermission(Arrays.asList(confirmButton, dissentButton, reformButton)
-                , SecurityUtils.getUserId(), SecurityConstants.INNER);
+        return selectCurUserTaskList(panelListDto, confirmButton, dissentButton, reformButton);
+    }
+
+    private LambdaQueryWrapper<Question> generateCurUserTaskWrapper(PanelListDto panelListDto, Long confirmButton, Long dissentButton, Long reformButton) {
+        LambdaQueryWrapper<Question> wrapper = new LambdaQueryWrapper<>();
+        List<Long> btns = new ArrayList<>();
+        if (ObjectUtil.isNotNull(confirmButton)) {
+            btns.add(confirmButton);
+        }
+        if (ObjectUtil.isNotNull(dissentButton)) {
+            btns.add(dissentButton);
+        }
+        if (ObjectUtil.isNotNull(reformButton)) {
+            btns.add(reformButton);
+        }
+
+        if (ObjectUtil.isEmpty(btns)) {
+            throw new ServiceException("至少需要一个按钮权限");
+        }
+
+        List<Long> ownPermission = remoteUserService.checkUserPermission(btns, SecurityUtils.getUserId(), SecurityConstants.INNER);
         if (ownPermission.contains(reformButton)) {
             wrapper.or(w -> w.eq(Question::getOrgId, panelListDto.getOrgId()).eq(Question::getReformStatus, QuestionReformEnum.Unreform.getValue()));
         }
@@ -387,6 +421,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
             wrapper.or(w -> w.eq(Question::getSubmitorId, SecurityUtils.getUserId()).eq(Question::getConfirmStatus, QuestionConfirmEnum.Dissent.getValue()));
         }
 
+        return wrapper;
+    }
+
+    private List<PanelListVo> selectCurUserTaskList(PanelListDto panelListDto, Long confirmButton, Long dissentButton, Long reformButton) {
+        LambdaQueryWrapper<Question> wrapper = generateCurUserTaskWrapper(panelListDto, confirmButton, dissentButton, reformButton);
+
         if (wrapper.isEmptyOfWhere()) {
             return new ArrayList<>();
         } else {