Преглед на файлове

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

gy b преди 2 години
родител
ревизия
6d0e403381

+ 6
- 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java Целия файл

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

+ 9
- 0
ruoyi-system/src/main/java/com/ruoyi/system/service/flow/CaseFlowService.java Целия файл

3
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
3
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
4
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
4
 import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
5
 
5
 
6
+import java.util.Set;
7
+
6
 public interface CaseFlowService {
8
 public interface CaseFlowService {
7
     /**
9
     /**
8
      * 查询案件流程节点信息
10
      * 查询案件流程节点信息
31
      * @return
33
      * @return
32
      */
34
      */
33
     Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowSearchVO);
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 Целия файл

18
 import org.springframework.stereotype.Service;
18
 import org.springframework.stereotype.Service;
19
 import tk.mybatis.mapper.entity.Example;
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
 import java.util.stream.Collectors;
22
 import java.util.stream.Collectors;
26
 
23
 
27
 @Service
24
 @Service
270
         }
267
         }
271
         return false;
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
 }