优化用户登录返回用户角色的案件状态id
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.system.service.flow.CaseFlowService;
|
||||
import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication;
|
||||
import com.ruoyi.wisdomarbitrate.service.miniprogress.IdentityAuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -40,7 +41,8 @@ public class SysLoginController {
|
||||
IdentityAuthenticationService identityAuthenticationService;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private CaseFlowService caseFlowService;
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
@@ -79,10 +81,13 @@ public class SysLoginController {
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
//查询用户角色关联的案件状态
|
||||
Set<Integer> caseStatus = caseFlowService.getCaseStatusIdByRoleKey(roles);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
ajax.put("caseStatus", caseStatus);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ruoyi.system.service.flow;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowSearchVO;
|
||||
import com.ruoyi.system.domain.vo.flow.MsCaseFlowVO;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface CaseFlowService {
|
||||
/**
|
||||
* 查询案件流程节点信息
|
||||
@@ -31,4 +33,11 @@ public interface CaseFlowService {
|
||||
* @return
|
||||
*/
|
||||
Boolean sortCaseFlow(MsCaseFlowSearchVO caseFlowSearchVO);
|
||||
|
||||
/**
|
||||
* 查询用户角色关联的案件状态
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -270,4 +267,64 @@ public class CaseFlowServiceImpl implements CaseFlowService {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户角色关联的案件状态
|
||||
*
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Set<Integer> getCaseStatusIdByRoleKey(Set<String> roles) {
|
||||
boolean isall = false;
|
||||
List<Long> roleIds = new ArrayList<>();
|
||||
//TODO
|
||||
// if (roles != null && roles.size() > 0) {
|
||||
// for (String role : roles) {
|
||||
// if (role.equals("admin")) {
|
||||
// isall = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (!isall) {
|
||||
for (String rolekey : roles) {
|
||||
SysRole sysRole = sysRoleMapper.checkRoleKeyUnique(rolekey);
|
||||
if (sysRole != null) {
|
||||
roleIds.add(sysRole.getRoleId());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 查询角色的案件状态id
|
||||
*/
|
||||
Set<Integer> caseStatusIds = getCaseStatusIdByRoleId(roleIds, isall);
|
||||
return caseStatusIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色的案件状态id
|
||||
*
|
||||
* @param roleIds
|
||||
* @param isall
|
||||
* @return
|
||||
*/
|
||||
private Set<Integer> getCaseStatusIdByRoleId(List<Long> roleIds, boolean isall) {
|
||||
Set<Integer> result = new HashSet<>();
|
||||
Example example = new Example(MsCaseFlowRoleRelated.class);
|
||||
Example.Criteria criteria = example.createCriteria();
|
||||
if (isall) {
|
||||
List<MsCaseFlowRoleRelated> msCaseFlowRoleRelateds = msCaseFlowRoleRelatedMapper.selectAll();
|
||||
if (msCaseFlowRoleRelateds != null && msCaseFlowRoleRelateds.size() > 0) {
|
||||
result = msCaseFlowRoleRelateds.stream().filter(s -> s.getFlowId() != null).map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toSet());
|
||||
}
|
||||
} else if (roleIds != null && roleIds.size() > 0) {
|
||||
criteria.andIn("roleid", roleIds);
|
||||
List<MsCaseFlowRoleRelated> msCaseFlowRoleRelateds = msCaseFlowRoleRelatedMapper.selectByExample(example);
|
||||
if (msCaseFlowRoleRelateds != null && msCaseFlowRoleRelateds.size() > 0) {
|
||||
result = msCaseFlowRoleRelateds.stream().filter(s -> s.getFlowId() != null).map(MsCaseFlowRoleRelated::getFlowId).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user