Commit f3f4a7c9 authored by wzp's avatar wzp

修改用户添加

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