Procházet zdrojové kódy

优化用户登录返回用户角色的案件状态id

gy b před 2 roky
rodič
revize
6d0e403381

+ 6
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java Zobrazit soubor

@@ -4,6 +4,7 @@ import java.util.List;
4 4
 import java.util.Set;
5 5
 
6 6
 import com.ruoyi.system.service.ISysUserService;
7
+import com.ruoyi.system.service.flow.CaseFlowService;
7 8
 import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication;
8 9
 import com.ruoyi.wisdomarbitrate.service.miniprogress.IdentityAuthenticationService;
9 10
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,7 +41,8 @@ public class SysLoginController {
40 41
     IdentityAuthenticationService identityAuthenticationService;
41 42
     @Autowired
42 43
     private ISysUserService sysUserService;
43
-
44
+    @Autowired
45
+    private CaseFlowService caseFlowService;
44 46
     /**
45 47
      * 登录方法
46 48
      *
@@ -79,10 +81,13 @@ public class SysLoginController {
79 81
         Set<String> roles = permissionService.getRolePermission(user);
80 82
         // 权限集合
81 83
         Set<String> permissions = permissionService.getMenuPermission(user);
84
+        //查询用户角色关联的案件状态
85
+        Set<Integer> caseStatus = caseFlowService.getCaseStatusIdByRoleKey(roles);
82 86
         AjaxResult ajax = AjaxResult.success();
83 87
         ajax.put("user", user);
84 88
         ajax.put("roles", roles);
85 89
         ajax.put("permissions", permissions);
90
+        ajax.put("caseStatus", caseStatus);
86 91
         return ajax;
87 92
     }
88 93
 

+ 9
- 0
ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java Zobrazit soubor

@@ -3,6 +3,8 @@ package com.ruoyi.system.service.flow;
3 3
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
4 4
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
5 5
 
6
+import java.util.Set;
7
+
6 8
 public interface CaseFlowService {
7 9
     /**
8 10
      * 查询案件流程节点信息
@@ -31,4 +33,11 @@ public interface CaseFlowService {
31 33
      * @return
32 34
      */
33 35
     Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowSearchVO);
36
+
37
+    /**
38
+     * 查询用户角色关联的案件状态
39
+     * @param roles
40
+     * @return
41
+     */
42
+    Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles);
34 43
 }

+ 61
- 4
ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowServiceImpl.java Zobrazit soubor

@@ -18,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 18
 import org.springframework.stereotype.Service;
19 19
 import tk.mybatis.mapper.entity.Example;
20 20
 
21
-import java.util.ArrayList;
22
-import java.util.HashMap;
23
-import java.util.List;
24
-import java.util.Map;
21
+import java.util.*;
25 22
 import java.util.stream.Collectors;
26 23
 
27 24
 @Service
@@ -270,4 +267,64 @@ public class CaseFlowServiceImpl implements CaseFlowService {
270 267
         }
271 268
         return false;
272 269
     }
270
+
271
+    /**
272
+     * 查询用户角色关联的案件状态
273
+     *
274
+     * @param roles
275
+     * @return
276
+     */
277
+    @Override
278
+    public Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles) {
279
+        boolean isall = false;
280
+        List<Long> roleIds = new ArrayList<>();
281
+        //TODO
282
+//        if (roles != null && roles.size() > 0) {
283
+//            for (String role : roles) {
284
+//                if (role.equals("admin")) {
285
+//                    isall = true;
286
+//                    break;
287
+//                }
288
+//            }
289
+//        }
290
+        if (!isall) {
291
+            for (String rolekey : roles) {
292
+                SysRole sysRole = sysRoleMapper.checkRoleKeyUnique(rolekey);
293
+                if (sysRole != null) {
294
+                    roleIds.add(sysRole.getRoleId());
295
+                }
296
+            }
297
+        }
298
+        /**
299
+         * 查询角色的案件状态id
300
+         */
301
+        Set<Integer> caseStatusIds = getCaseStatusIdByRoleId(roleIds, isall);
302
+        return caseStatusIds;
303
+    }
304
+
305
+    /**
306
+     * 查询角色的案件状态id
307
+     *
308
+     * @param roleIds
309
+     * @param isall
310
+     * @return
311
+     */
312
+    private Set<Integer> getCaseStatusIdByRoleId(List<Long> roleIds, boolean isall) {
313
+        Set<Integer> result = new HashSet<>();
314
+        Example example = new Example(MsCaseFlowRoleRelated.class);
315
+        Example.Criteria criteria = example.createCriteria();
316
+        if (isall) {
317
+            List<MsCaseFlowRoleRelated> msCaseFlowRoleRelateds = msCaseFlowRoleRelatedMapper.selectAll();
318
+            if (msCaseFlowRoleRelateds != null && msCaseFlowRoleRelateds.size() > 0) {
319
+                result = msCaseFlowRoleRelateds.stream().filter(s -> s.getFlowId() != null).map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toSet());
320
+            }
321
+        } else if (roleIds != null && roleIds.size() > 0) {
322
+            criteria.andIn("roleid", roleIds);
323
+            List<MsCaseFlowRoleRelated> msCaseFlowRoleRelateds = msCaseFlowRoleRelatedMapper.selectByExample(example);
324
+            if (msCaseFlowRoleRelateds != null && msCaseFlowRoleRelateds.size() > 0) {
325
+                result = msCaseFlowRoleRelateds.stream().filter(s -> s.getFlowId() != null).map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toSet());
326
+            }
327
+        }
328
+        return result;
329
+    }
273 330
 }