update 优化 下拉选接口数据权限

2.X
疯狂的狮子Li 12 months ago
parent c9cf60c2d8
commit 9fafe52b4b

@ -129,7 +129,7 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:query")
@GetMapping("/optionselect")
public R<List<SysDeptVo>> optionselect(@RequestParam(required = false) Long[] deptIds) {
return R.ok(deptService.selectDeptByIds(List.of(deptIds)));
return R.ok(deptService.selectDeptByIds(deptIds == null ? null : List.of(deptIds)));
}
}

@ -116,7 +116,7 @@ public class SysPostController extends BaseController {
@SaCheckPermission("system:post:query")
@GetMapping("/optionselect")
public R<List<SysPostVo>> optionselect(@RequestParam(required = false) Long[] postIds) {
return R.ok(postService.selectPostByIds(List.of(postIds)));
return R.ok(postService.selectPostByIds(postIds == null ? null : List.of(postIds)));
}
}

@ -155,7 +155,7 @@ public class SysRoleController extends BaseController {
@SaCheckPermission("system:role:query")
@GetMapping("/optionselect")
public R<List<SysRoleVo>> optionselect(@RequestParam(required = false) Long[] roleIds) {
return R.ok(roleService.selectRoleByIds(List.of(roleIds)));
return R.ok(roleService.selectRoleByIds(roleIds == null ? null : List.of(roleIds)));
}
/**

@ -216,7 +216,7 @@ public class SysUserController extends BaseController {
@GetMapping("/optionselect")
public R<List<SysUserVo>> optionselect(@RequestParam(required = false) Long[] userIds,
@RequestParam(required = false) Long deptId) {
return R.ok(userService.selectUserByIds(List.of(userIds), deptId));
return R.ok(userService.selectUserByIds(userIds == null ? null : List.of(userIds), deptId));
}
/**

@ -26,6 +26,12 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
})
Page<SysUserVo> selectPageUserList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id"),
@DataColumn(key = "userName", value = "user_id")
})
List<SysUserVo> selectUserList(@Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
/**
*
*

@ -174,10 +174,9 @@ public class SysRoleServiceImpl implements ISysRoleService {
*/
@Override
public List<SysRoleVo> selectRoleByIds(List<Long> roleIds) {
return baseMapper.selectRoleList(new LambdaQueryWrapper<SysRole>()
.select(SysRole::getRoleId, SysRole::getRoleName, SysRole::getRoleKey)
.eq(SysRole::getStatus, UserConstants.ROLE_NORMAL)
.in(CollUtil.isNotEmpty(roleIds), SysRole::getRoleId, roleIds));
return baseMapper.selectRoleList(new QueryWrapper<SysRole>()
.eq("r.status", UserConstants.ROLE_NORMAL)
.in(CollUtil.isNotEmpty(roleIds), "r.role_id", roleIds));
}
/**

@ -180,7 +180,7 @@ public class SysUserServiceImpl implements ISysUserService {
*/
@Override
public List<SysUserVo> selectUserByIds(List<Long> userIds, Long deptId) {
return baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
return baseMapper.selectUserList(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName)
.eq(SysUser::getStatus, UserConstants.USER_NORMAL)
.eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId)

@ -8,7 +8,7 @@
</resultMap>
<select id="selectDeptList" resultMap="SysDeptResult">
select * from sys_dept ${ew.getCustomSqlSegment}
select ${ew.getSqlSelect} from sys_dept ${ew.getCustomSqlSegment}
</select>
<select id="countDeptById" resultType="Long">

@ -12,10 +12,15 @@
</resultMap>
<select id="selectPageUserList" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark
select ${ew.getSqlSelect}
from sys_user u
${ew.getCustomSqlSegment}
${ew.getCustomSqlSegment}
</select>
<select id="selectUserList" resultMap="SysUserResult">
select ${ew.getSqlSelect}
from sys_user
${ew.getCustomSqlSegment}
</select>
<select id="selectUserExportList" resultMap="SysUserExportResult">

Loading…
Cancel
Save