update 用户信息查询
parent
3a4ce185d3
commit
c3107e6b79
|
@ -143,6 +143,15 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
|
|||
return buildQueryTitle(buildQueryWrapper(role));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> findByUserId(Long id) {
|
||||
return jpaQueryFactory.select(Projections.bean(SysRole.class, tbSysRole.id, tbSysRole.roleName, tbSysRole.roleKey, tbSysRole.roleSort, tbSysRole.dataScope, tbSysRole.status, tbSysRole.delFlag, tbSysRole.createTime, tbSysRole.remark))
|
||||
.from(tbSysRole)
|
||||
.leftJoin(tbSysUserRole).on(tbSysUserRole.roleId.eq(tbSysRole.id))
|
||||
.where(tbSysUserRole.userId.eq(id))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
private List<SysRole> buildQueryTitle(Predicate predicate) {
|
||||
return jpaQueryFactory.select(Projections.fields(SysRole.class, tbSysRole.id, tbSysRole.roleName,
|
||||
tbSysRole.roleKey, tbSysRole.roleSort, tbSysRole.menuCheckStrictly, tbSysRole.deptCheckStrictly,
|
||||
|
|
|
@ -12,6 +12,7 @@ import cc.iotkit.data.model.TbSysPost;
|
|||
import cc.iotkit.data.model.TbSysRole;
|
||||
import cc.iotkit.data.model.TbSysUser;
|
||||
import cc.iotkit.data.system.ISysDeptData;
|
||||
import cc.iotkit.data.system.ISysRoleData;
|
||||
import cc.iotkit.data.system.ISysUserData;
|
||||
import cc.iotkit.data.util.PageBuilder;
|
||||
import cc.iotkit.data.util.PredicateBuilder;
|
||||
|
@ -54,6 +55,8 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
|
||||
private final ISysDeptData sysDeptData;
|
||||
|
||||
private final ISysRoleData sysRoleData;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
||||
|
@ -98,6 +101,20 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
return Objects.isNull(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser findById(Long id){
|
||||
TbSysUser sysUser = jpaQueryFactory.select(tbSysUser).from(tbSysUser).where(tbSysUser.id.eq(id)).fetchOne();
|
||||
|
||||
SysUser convert = MapstructUtils.convert(sysUser, SysUser.class);
|
||||
List<SysRole> sysRoles = sysRoleData.findByUserId(id);
|
||||
convert.setRoles(sysRoles);
|
||||
SysDept dept = sysDeptData.findById(convert.getDeptId());
|
||||
if(ObjectUtil.isNotNull(dept)){
|
||||
convert.setDept(dept);
|
||||
}
|
||||
return convert;
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUser user) {
|
||||
final TbSysUser ret = jpaQueryFactory.select(tbSysUser).from(tbSysUser)
|
||||
|
@ -169,11 +186,8 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
SysDept sysDept = sysDeptData.findById(deptId);
|
||||
convert.setDept(sysDept);
|
||||
// 获取角色信息
|
||||
List<SysRole> sysRoles = jpaQueryFactory.select(Projections.bean(SysRole.class, tbSysRole.id, tbSysRole.roleName, tbSysRole.roleKey, tbSysRole.roleSort, tbSysRole.dataScope, tbSysRole.status, tbSysRole.delFlag, tbSysRole.createTime, tbSysRole.remark))
|
||||
.from(tbSysRole)
|
||||
.leftJoin(tbSysUserRole).on(tbSysUserRole.roleId.eq(tbSysRole.id))
|
||||
.where(tbSysUserRole.userId.eq(ret.getId()))
|
||||
.fetch();
|
||||
List<SysRole> sysRoles = sysRoleData.findByUserId(ret.getId());
|
||||
|
||||
convert.setRoles(sysRoles);
|
||||
}
|
||||
return convert;
|
||||
|
|
|
@ -123,13 +123,13 @@ public class SysUserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据用户编号获取详细信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*用户ID
|
||||
*/
|
||||
@ApiOperation("根据用户编号获取详细信息")
|
||||
@SaCheckPermission("system:user:query")
|
||||
@PostMapping(value = {"/", "/{userId}"})
|
||||
public SysUserInfoVo getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
@PostMapping(value = {"/getDetail"})
|
||||
public SysUserInfoVo getInfo(@Validated @RequestBody Request<Long> req) {
|
||||
Long userId = req.getData();
|
||||
userService.checkUserDataScope(userId);
|
||||
SysUserInfoVo userInfoVo = new SysUserInfoVo();
|
||||
List<SysRoleVo> roles = roleService.selectRoleAll();
|
||||
|
|
Loading…
Reference in New Issue