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

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

@ -129,7 +129,7 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:query") @SaCheckPermission("system:dept:query")
@GetMapping("/optionselect") @GetMapping("/optionselect")
public R<List<SysDeptVo>> optionselect(@RequestParam(required = false) Long[] deptIds) { 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") @SaCheckPermission("system:post:query")
@GetMapping("/optionselect") @GetMapping("/optionselect")
public R<List<SysPostVo>> optionselect(@RequestParam(required = false) Long[] postIds) { 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") @SaCheckPermission("system:role:query")
@GetMapping("/optionselect") @GetMapping("/optionselect")
public R<List<SysRoleVo>> optionselect(@RequestParam(required = false) Long[] roleIds) { 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") @GetMapping("/optionselect")
public R<List<SysUserVo>> optionselect(@RequestParam(required = false) Long[] userIds, public R<List<SysUserVo>> optionselect(@RequestParam(required = false) Long[] userIds,
@RequestParam(required = false) Long deptId) { @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); 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 @Override
public List<SysRoleVo> selectRoleByIds(List<Long> roleIds) { public List<SysRoleVo> selectRoleByIds(List<Long> roleIds) {
return baseMapper.selectRoleList(new LambdaQueryWrapper<SysRole>() return baseMapper.selectRoleList(new QueryWrapper<SysRole>()
.select(SysRole::getRoleId, SysRole::getRoleName, SysRole::getRoleKey) .eq("r.status", UserConstants.ROLE_NORMAL)
.eq(SysRole::getStatus, UserConstants.ROLE_NORMAL) .in(CollUtil.isNotEmpty(roleIds), "r.role_id", roleIds));
.in(CollUtil.isNotEmpty(roleIds), SysRole::getRoleId, roleIds));
} }
/** /**

@ -180,7 +180,7 @@ public class SysUserServiceImpl implements ISysUserService {
*/ */
@Override @Override
public List<SysUserVo> selectUserByIds(List<Long> userIds, Long deptId) { 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) .select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName)
.eq(SysUser::getStatus, UserConstants.USER_NORMAL) .eq(SysUser::getStatus, UserConstants.USER_NORMAL)
.eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId) .eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId)

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

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

Loading…
Cancel
Save