fix: 角色授权
parent
4e6a354847
commit
22637889c0
|
@ -201,7 +201,9 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
.and(StringUtils.isNotBlank(data.getUserName()), () -> tbSysUser.userName.like(data.getUserName()))
|
||||
.and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysUser.status.eq(data.getStatus()))
|
||||
.and(Objects.nonNull(data.getDeptId()), () -> tbSysUser.deptId.eq(data.getDeptId()))
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL));
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL))
|
||||
.and(Objects.nonNull(data.getRoleId()),()-> tbSysRole.id.eq(data.getRoleId()));
|
||||
|
||||
QueryResults<TbSysUser> tbSysUserQueryResults = jpaQueryFactory.select(Projections.bean(TbSysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.userName,
|
||||
tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser)
|
||||
.leftJoin(tbSysDept).on(tbSysUser.deptId.eq(tbSysDept.id))
|
||||
|
@ -235,14 +237,16 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
|
||||
@Override
|
||||
public Paging<SysUser> selectUnallocatedList(PageRequest<SysUser> to) {
|
||||
//TODO: 未分配用户列表
|
||||
SysUser data = to.getData();
|
||||
PredicateBuilder builder = PredicateBuilder.instance()
|
||||
.and(StringUtils.isNotBlank(data.getPhonenumber()), () -> tbSysUser.phonenumber.like(data.getPhonenumber()))
|
||||
.and(StringUtils.isNotBlank(data.getUserName()), () -> tbSysUser.userName.like(data.getUserName()))
|
||||
.and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysUser.status.eq(data.getStatus()))
|
||||
.and(Objects.nonNull(data.getDeptId()), () -> tbSysUser.deptId.eq(data.getDeptId()))
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL));
|
||||
PredicateBuilder builder = PredicateBuilder.instance();
|
||||
if(Objects.nonNull(data)){
|
||||
builder.and(StringUtils.isNotBlank(data.getPhonenumber()), () -> tbSysUser.phonenumber.like(data.getPhonenumber()))
|
||||
.and(StringUtils.isNotBlank(data.getUserName()), () -> tbSysUser.userName.like(data.getUserName()))
|
||||
.and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysUser.status.eq(data.getStatus()))
|
||||
.and(Objects.nonNull(data.getDeptId()), () -> tbSysUser.deptId.eq(data.getDeptId()))
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL));
|
||||
}
|
||||
|
||||
QueryResults<SysUser> sysUserQueryResults = jpaQueryFactory.select(Projections.bean(SysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.userName,
|
||||
tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser)
|
||||
.leftJoin(tbSysDept).on(tbSysUser.deptId.eq(tbSysDept.id))
|
||||
|
|
|
@ -9,6 +9,7 @@ import cc.iotkit.common.log.enums.BusinessType;
|
|||
import cc.iotkit.common.web.core.BaseController;
|
||||
import cc.iotkit.model.system.SysUserRole;
|
||||
import cc.iotkit.system.dto.bo.SysDeptBo;
|
||||
import cc.iotkit.system.dto.bo.SysRoleAuthBo;
|
||||
import cc.iotkit.system.dto.bo.SysRoleBo;
|
||||
import cc.iotkit.system.dto.bo.SysUserBo;
|
||||
import cc.iotkit.system.dto.vo.DeptTreeSelectVo;
|
||||
|
@ -202,28 +203,30 @@ public class SysRoleController extends BaseController {
|
|||
/**
|
||||
* 批量取消授权用户
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 用户ID串
|
||||
*/
|
||||
@ApiOperation(value = "批量取消授权用户", notes = "批量取消授权用户")
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PostMapping("/authUser/cancelAll")
|
||||
public void cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||
public void cancelAuthUserAll(@Validated @RequestBody Request<SysRoleAuthBo> bo) {
|
||||
SysRoleAuthBo data = bo.getData();
|
||||
Long roleId = data.getRoleId();
|
||||
Long[] userIds = data.getUserIds();
|
||||
roleService.deleteAuthUsers(roleId, userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param userIds 用户ID串
|
||||
*/
|
||||
@ApiOperation(value = "批量选择用户授权", notes = "批量选择用户授权")
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PostMapping("/authUser/selectAll")
|
||||
public void selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||
public void selectAuthUserAll(@Validated @RequestBody Request<SysRoleAuthBo> bo) {
|
||||
SysRoleAuthBo data = bo.getData();
|
||||
Long roleId = data.getRoleId();
|
||||
Long[] userIds = data.getUserIds();
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
roleService.insertAuthUsers(roleId, userIds);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package cc.iotkit.system.dto.bo;
|
||||
|
||||
import cc.iotkit.common.api.BaseDto;
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.common.validate.AddGroup;
|
||||
import cc.iotkit.common.validate.EditGroup;
|
||||
import cc.iotkit.model.system.SysRole;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 角色信息业务对象 sys_role
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysRoleAuthBo extends BaseDto {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
@NotNull(message = "角色ID不能为空")
|
||||
private Long roleId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "用户ID列表")
|
||||
|
||||
private Long[] userIds;
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue