Commit f3f4a7c9 authored by wzp's avatar wzp

修改用户添加

parent 3ff65a3a
......@@ -122,21 +122,24 @@ public class MyShiroRealm extends AuthorizingRealm {
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
List<Role> list = roleService.selectRoleByUserId(userId);
List<String> ridList = new LinkedList<>();
if (list!=null&&list.get(0)!=null) {
// // 根据用户ID查询角色(role),放入到Authorization里。
// Map<String, Object> map = new HashMap<>();
// map.put("user_id", userId);
// List<EmployeeRole> employeeRoleList = this.employeeRoleService.listByMap(map);
List<String> ridList = new LinkedList<>();
// for (EmployeeRole employeeRole : employeeRoleList) {
// ridList.add(employeeRole.getRoleId());
// }
// List<Role> roleList = this.roleService.listByIds(ridList);
Set<String> roleSet = new HashSet<>();
for (Role role : list) {
roleSet.add(role.getAlias());
ridList.add(role.getId());
Set<String> roleSet = new HashSet<>();
for (Role role : list) {
roleSet.add(role.getAlias());
ridList.add(role.getId());
}
info.setRoles(roleSet);
}
info.setRoles(roleSet);
// 根据用户ID查询权限(permission)放入到Authorization里。
QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
......
......@@ -158,6 +158,10 @@ public class TUser implements Serializable {
@TableField(exist = false)
private String statusName;
@ApiModelProperty("机构区分字段")
@TableField(exist = false)
private String oId;
@TableField(exist = false)
private String jwtToken;
......
......@@ -165,8 +165,10 @@ public class LoginController {
}
List<Role> roles = roleService.selectRoleByUserId(user.getId());
List<String> list1 = new ArrayList<>();
roles.stream().forEach(r-> list1.add(r.getId()));
user.setRoleList(list1);
if (roles!=null&&roles.get(0)!=null) {
roles.stream().forEach(r -> list1.add(r.getId()));
user.setRoleList(list1);
}
//获取当前用户角色拥有菜单
List<Menu> userMenuPerms = new ArrayList<>();
if (roles.size() > 0) {
......
......@@ -92,6 +92,7 @@ public class TUserController extends BaseController {
@RequiresPermissions("/user/getPageList")
// @MethodLog(operModule = OperModule.USER, operType = OperType.SELECT)
public Map<String, Object> getPageList(String userName,String status,String type,String orgId,String areaId) {
TUser user1 = getcurUser();
TUser user = new TUser();
if (StringUtils.isNotBlank(userName)) {
user.setUserName(userName);
......@@ -112,6 +113,11 @@ public class TUserController extends BaseController {
user.setAuditStatus(status);
}
}
List<String> roleList = user1.getRoleList();
if (roleList!=null&&!roleList.contains("1")&&roleList.contains("2")){
user.setOId(user1.getOrgId());
user.setType("2");
}
try {
Page<TUser> list = userService.getList(getPage(), user);
return getResult(list);
......@@ -162,9 +168,11 @@ public class TUserController extends BaseController {
try {
TUser tUser = userService.selectById(id);
List<Role> list = roleService.selectRoleByUserId(id);
List<String> list1 = new ArrayList<>();
list.stream().forEach(r-> list1.add(r.getId()));
tUser.setRoleList(list1);
if (list!=null&&list.get(0)!=null) {
List<String> list1 = new ArrayList<>();
list.stream().forEach(r -> list1.add(r.getId()));
tUser.setRoleList(list1);
}
return getResult(tUser);
} catch (Exception e) {
e.printStackTrace();
......@@ -209,7 +217,19 @@ public class TUserController extends BaseController {
resultMap.put("message", "请选择机构!");
return resultMap;
}
if ("2".equals(user.getType())){
QueryWrapper<TUser> ew = new QueryWrapper<>();
user.setUserName(user.getUserName().trim());
ew.eq("is_deleted", 0);
ew.eq("type", "2");
ew.eq("org_id", user.getOrgId());
List<TUser> list = userService.list(ew);
if (list.size()>=3) {
resultMap.put("resultCode", 400);
resultMap.put("message", "机构已存在三个单位管理员!");
return resultMap;
}
}
QueryWrapper<TUser> ew = new QueryWrapper<>();
if (StringUtils.isNoneBlank(user.getUserName())) {
user.setUserName(user.getUserName().trim());
......
......@@ -81,6 +81,9 @@
<if test=" user.orgId != null and user.orgId != '' ">
and u.org_id = #{user.orgId}
</if>
<if test=" user.OId != null and user.OId != '' ">
and u.org_id = #{user.OId}
</if>
<if test=" user.areaId != null and user.areaId != '' ">
and u.area_id = #{user.areaId}
</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment