add 新增 用户、部门、角色、岗位 下拉选接口与代码实现优化

2.X
疯狂的狮子Li 1 year ago
parent aaeb251843
commit d3394afab1

@ -120,4 +120,16 @@ public class SysDeptController extends BaseController {
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
/**
*
*
* @param deptIds ID
*/
@SaCheckPermission("system:dept:query")
@GetMapping("/optionselect")
public R<List<SysDeptVo>> optionselect(@RequestParam(required = false) Long[] deptIds) {
return R.ok(deptService.selectDeptByIds(List.of(deptIds)));
}
}

@ -110,12 +110,13 @@ public class SysPostController extends BaseController {
/**
*
*
* @param postIds ID
*/
@SaCheckPermission("system:post:query")
@GetMapping("/optionselect")
public R<List<SysPostVo>> optionselect() {
SysPostBo postBo = new SysPostBo();
postBo.setStatus(UserConstants.POST_NORMAL);
List<SysPostVo> posts = postService.selectPostList(postBo);
return R.ok(posts);
public R<List<SysPostVo>> optionselect(@RequestParam(required = false) Long[] postIds) {
return R.ok(postService.selectPostByIds(List.of(postIds)));
}
}

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

@ -206,6 +206,19 @@ public class SysUserController extends BaseController {
return toAjax(userService.deleteUserByIds(userIds));
}
/**
* ID
*
* @param userIds ID
* @param deptId ID
*/
@SaCheckPermission("system:user:query")
@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));
}
/**
*
*/

@ -52,6 +52,14 @@ public interface ISysDeptService {
*/
SysDeptVo selectDeptById(Long deptId);
/**
* ID
*
* @param deptIds id
* @return
*/
List<SysDeptVo> selectDeptByIds(List<Long> deptIds);
/**
* ID
*

@ -48,6 +48,14 @@ public interface ISysPostService {
*/
List<Long> selectPostListByUserId(Long userId);
/**
* ID
*
* @param postIds id
* @return
*/
List<SysPostVo> selectPostByIds(List<Long> postIds);
/**
*
*

@ -74,6 +74,14 @@ public interface ISysRoleService {
*/
SysRoleVo selectRoleById(Long roleId);
/**
* ID
*
* @param roleIds ID
* @return
*/
List<SysRoleVo> selectRoleByIds(List<Long> roleIds);
/**
*
*

@ -66,6 +66,15 @@ public interface ISysUserService {
*/
SysUserVo selectUserById(Long userId);
/**
* ID
*
* @param userIds ID
* @param deptId id
* @return
*/
List<SysUserVo> selectUserByIds(List<Long> userIds, Long deptId);
/**
* ID
*

@ -138,6 +138,20 @@ public class SysDeptServiceImpl implements ISysDeptService {
return dept;
}
/**
* ID
*
* @param deptIds id
* @return
*/
@Override
public List<SysDeptVo> selectDeptByIds(List<Long> deptIds) {
return baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getLeader)
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds));
}
/**
* ID
*

@ -1,10 +1,12 @@
package org.dromara.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.dromara.common.core.constant.UserConstants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StreamUtils;
@ -97,6 +99,20 @@ public class SysPostServiceImpl implements ISysPostService {
return StreamUtils.toList(list, SysPostVo::getPostId);
}
/**
* ID
*
* @param postIds id
* @return
*/
@Override
public List<SysPostVo> selectPostByIds(List<Long> postIds) {
return baseMapper.selectVoList(new LambdaQueryWrapper<SysPost>()
.select(SysPost::getPostId, SysPost::getPostName, SysPost::getPostCode)
.eq(SysPost::getStatus, UserConstants.POST_NORMAL)
.in(CollUtil.isNotEmpty(postIds), SysPost::getPostId, postIds));
}
/**
*
*

@ -166,6 +166,20 @@ public class SysRoleServiceImpl implements ISysRoleService {
return baseMapper.selectRoleById(roleId);
}
/**
* ID
*
* @param roleIds ID
* @return
*/
@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));
}
/**
*
*

@ -171,6 +171,22 @@ public class SysUserServiceImpl implements ISysUserService {
return user;
}
/**
* ID
*
* @param userIds ID
* @param deptId id
* @return
*/
@Override
public List<SysUserVo> selectUserByIds(List<Long> userIds, Long deptId) {
return baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName)
.eq(SysUser::getStatus, UserConstants.USER_NORMAL)
.eq(ObjectUtil.isNotNull(deptId), SysUser::getDeptId, deptId)
.in(CollUtil.isNotEmpty(userIds), SysUser::getUserId, userIds));
}
/**
*
*

Loading…
Cancel
Save