Commit 1c45ebd0 authored by 赵啸非's avatar 赵啸非

添加角色关联查询

parent 93673907
...@@ -293,6 +293,8 @@ data|object|数据对象 ...@@ -293,6 +293,8 @@ data|object|数据对象
  userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)   userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)
  siteIds|String|所属站点id,多个逗号分隔   siteIds|String|所属站点id,多个逗号分隔
  areaCodes|String|所属区域code,多个逗号分隔   areaCodes|String|所属区域code,多个逗号分隔
  roleId|String|所属角色id,多个逗号分隔
  roleName|String|所属角色名称,多个逗号分隔
  status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)   status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
  createTime|Date|创建时间   createTime|Date|创建时间
  createUserId|Long|创建用户   createUserId|Long|创建用户
...@@ -341,7 +343,6 @@ msg|String|消息 ...@@ -341,7 +343,6 @@ msg|String|消息
data|object|数据对象 data|object|数据对象
 id|Long|用户ID,主键,自增长  id|Long|用户ID,主键,自增长
 loginName|String|登录名  loginName|String|登录名
 loginPwd|String|登录密码,使用md5双次加密
 loginLimitAddress|String|登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录  loginLimitAddress|String|登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
 realName|String|用户名  realName|String|用户名
 mobile|String|用户手机号  mobile|String|用户手机号
...@@ -351,6 +352,8 @@ data|object|数据对象 ...@@ -351,6 +352,8 @@ data|object|数据对象
 userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)  userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)
 siteIds|String|所属站点id,多个逗号分隔  siteIds|String|所属站点id,多个逗号分隔
 areaCodes|String|所属区域code,多个逗号分隔  areaCodes|String|所属区域code,多个逗号分隔
 roleId|String|所属角色Id,多个逗号分隔
 roleName|String|所属角色名称,多个逗号分隔
 status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)  status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
 createTime|Date|创建时间  createTime|Date|创建时间
 createUserId|Long|创建用户  createUserId|Long|创建用户
...@@ -403,9 +406,8 @@ dict|object|字典对象 ...@@ -403,9 +406,8 @@ dict|object|字典对象
参数名称|类型|必填|描述 参数名称|类型|必填|描述
:---|:---|:---|:------- :---|:---|:---|:-------
loginName|String|是|登录名 loginName|String|是|登录名
loginPwd|String|是|登录密码,使用md5双次加密 loginPwd|String|是|登录密码
loginLimitAddress|String|是|登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录 realName|String|是|用户真实姓名
realName|String|是|用户名
mobile|String|是|用户手机号 mobile|String|是|用户手机号
phone|String|是|用户联系电话 phone|String|是|用户联系电话
email|String|是|用户邮箱 email|String|是|用户邮箱
...@@ -414,16 +416,12 @@ userType|Integer|是|用户类型(0.系统用户,1.普通用户,2.工作人员) ...@@ -414,16 +416,12 @@ userType|Integer|是|用户类型(0.系统用户,1.普通用户,2.工作人员)
siteIds|String|是|所属站点id,多个逗号分隔 siteIds|String|是|所属站点id,多个逗号分隔
areaCodes|String|是|所属区域code,多个逗号分隔 areaCodes|String|是|所属区域code,多个逗号分隔
status|Integer|是|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职) status|Integer|是|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
createUserName|String|是|创建用户名称
lastLoginTime|Date|是|最后一次登录时间
lastLoginAddress|String|是|最后一次登录地址
**请求样例:** **请求样例:**
``` ```
{ {
"loginName":"6njc9h", "loginName":"6njc9h",
"loginPwd":"e8iiea", "loginPwd":"e8iiea",
"loginLimitAddress":"ljhkil",
"realName":"coyvcd", "realName":"coyvcd",
"mobile":"avklzq", "mobile":"avklzq",
"phone":"6da3c3", "phone":"6da3c3",
...@@ -432,10 +430,7 @@ lastLoginAddress|String|是|最后一次登录地址 ...@@ -432,10 +430,7 @@ lastLoginAddress|String|是|最后一次登录地址
"userType":4441, "userType":4441,
"siteIds":"hgh6s1", "siteIds":"hgh6s1",
"areaCodes":"a4cexd", "areaCodes":"a4cexd",
"status":710, "status":710
"createUserName":"p1hifg",
"lastLoginTime":"2022-06-02",
"lastLoginAddress":"gcs2a3"
} }
``` ```
...@@ -450,7 +445,6 @@ data|object|数据对象 ...@@ -450,7 +445,6 @@ data|object|数据对象
 entity|object|保存更新实体  entity|object|保存更新实体
  id|Long|用户ID,主键,自增长   id|Long|用户ID,主键,自增长
  loginName|String|登录名   loginName|String|登录名
  loginPwd|String|登录密码,使用md5双次加密
  loginLimitAddress|String|登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录   loginLimitAddress|String|登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
  realName|String|用户名   realName|String|用户名
  mobile|String|用户手机号   mobile|String|用户手机号
...@@ -460,6 +454,8 @@ data|object|数据对象 ...@@ -460,6 +454,8 @@ data|object|数据对象
  userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)   userType|Integer|用户类型(0.系统用户,1.普通用户,2.工作人员)
  siteIds|String|所属站点id,多个逗号分隔   siteIds|String|所属站点id,多个逗号分隔
  areaCodes|String|所属区域code,多个逗号分隔   areaCodes|String|所属区域code,多个逗号分隔
  roleId|String|所属角色id,多个逗号分隔
  roleName|String|所属角色名称,多个逗号分隔
  status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)   status|Integer|用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
  createTime|Date|创建时间   createTime|Date|创建时间
  createUserId|Long|创建用户   createUserId|Long|创建用户
...@@ -513,6 +509,7 @@ msg|String|消息|- ...@@ -513,6 +509,7 @@ msg|String|消息|-
} }
``` ```
## 角色信息 ## 角色信息
### 查询角色信息列表 ### 查询角色信息列表
......
...@@ -55,7 +55,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -55,7 +55,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
list.stream().forEach(item->{ list.stream().forEach(item->{
if(!ObjectUtils.isEmpty(collect.get(item.getId()))){ if(!ObjectUtils.isEmpty(collect.get(item.getId()))){
item.setRoleId(collect.get(item.getId()).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","))); item.setRoleId(collect.get(item.getId()).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(",")));
item.setRoleName(collect.get(item.getId()).stream().map(m->roleMap.get(item.getId())).filter(f->f!=null).collect(Collectors.joining(","))); item.setRoleName(collect.get(item.getId()).stream().map(m->roleMap.get(m.getRoleId())).filter(f->f!=null).collect(Collectors.joining(",")));
} }
}); });
......
package com.mortals.xhx.module.user.web; package com.mortals.xhx.module.user.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.param.service.ParamService; import com.mortals.xhx.module.param.service.ParamService;
import com.mortals.xhx.module.role.model.RoleQuery;
import com.mortals.xhx.module.role.model.RoleUserEntity;
import com.mortals.xhx.module.role.model.RoleUserQuery;
import com.mortals.xhx.module.role.service.RoleService;
import com.mortals.xhx.module.role.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -45,6 +52,11 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -45,6 +52,11 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private RoleUserService roleUserService;
@Autowired
private RoleService roleService;
public UserController() { public UserController() {
super.setFormClass(UserForm.class); super.setFormClass(UserForm.class);
super.setModuleDesc("用户信息业务"); super.setModuleDesc("用户信息业务");
...@@ -58,4 +70,15 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -58,4 +70,15 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
} }
@Override
protected int viewAfter(Long id, Map<String, Object> model, UserEntity entity, Context context) throws AppException {
Map<Long, String> roleMap = roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId(), y -> y.getName()));
List<RoleUserEntity> roleUserList = roleUserService.find(new RoleUserQuery().userId(id));
if(!ObjectUtils.isEmpty(roleUserList)){
entity.setRoleId(roleUserList.stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(",")));
entity.setRoleName(roleUserList.stream().map(m->roleMap.get(m.getRoleId())).filter(f->f!=null).collect(Collectors.joining(",")));
}
return super.viewAfter(id, model, entity, context);
}
} }
\ No newline at end of file
...@@ -16,13 +16,12 @@ Authorization: {{authToken}} ...@@ -16,13 +16,12 @@ Authorization: {{authToken}}
Content-Type: application/json Content-Type: application/json
{ {
"name":"9h8jlh", "name":"测试角色1",
"roleCode":"beliak", "roleCode":"ceshi",
"roleSort":0, "roleSort":0,
"roleType":2, "roleType":2,
"remark":"66tnax", "remark":"11111",
"status":0, "status":1
"createUserName":"6qo3fj"
} }
> {% > {%
...@@ -34,11 +33,6 @@ GET {{baseUrl}}/role/info?id={{Role_id}} ...@@ -34,11 +33,6 @@ GET {{baseUrl}}/role/info?id={{Role_id}}
Authorization: {{authToken}} Authorization: {{authToken}}
Accept: application/json Accept: application/json
###角色信息编辑
GET {{baseUrl}}/role/edit?id={{Role_id}}
Authorization: {{authToken}}
Accept: application/json
###角色信息删除 ###角色信息删除
GET {{baseUrl}}/role/delete?id={{Role_id}} GET {{baseUrl}}/role/delete?id={{Role_id}}
......
...@@ -16,21 +16,13 @@ Authorization: {{authToken}} ...@@ -16,21 +16,13 @@ Authorization: {{authToken}}
Content-Type: application/json Content-Type: application/json
{ {
"loginName":"jnxv54", "loginName":"test",
"loginPwd":"s1yseh", "loginPwd":"test",
"loginLimitAddress":"4ocvs3", "realName":"测试",
"realName":"3kr50i", "mobile":"13281114856",
"mobile":"29odxn", "userType":1,
"phone":"orixyo", "siteIds":"",
"email":"6tuwgq", "areaCodes":""
"qq":"4j5ioa",
"userType":690,
"siteIds":"nzhmdx",
"areaCodes":"e76dqy",
"status":1,
"createUserName":"g8gdc6",
"lastLoginTime":"1654099200000",
"lastLoginAddress":"dfc2gz"
} }
> {% > {%
......
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