add
This commit is contained in:
@ -57,6 +57,7 @@ public class SysDeptController {
|
||||
}
|
||||
|
||||
@GetMapping(value = "/dept-tree/{roleId}")
|
||||
@Operation(summary = "角色部门树")
|
||||
public AjaxResult deptTree(@PathVariable("roleId") String roleId, SysDeptParam param) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", sysDeptService.selectDeptIdsByRoleId(roleId));
|
||||
|
@ -5,6 +5,8 @@ import com.qiaoba.api.system.entity.param.SysMenuParam;
|
||||
import com.qiaoba.api.system.entity.vo.SysMenuVo;
|
||||
import com.qiaoba.common.base.result.AjaxResult;
|
||||
import com.qiaoba.module.system.service.SysMenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -22,11 +24,13 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/system/menu")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "菜单管理")
|
||||
public class SysMenuController {
|
||||
|
||||
private final SysMenuService sysMenuService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取列表")
|
||||
public AjaxResult list(SysMenuParam param) {
|
||||
List<SysMenuVo> menus = sysMenuService.selectVoList(param);
|
||||
return AjaxResult.success(menus);
|
||||
@ -34,35 +38,41 @@ public class SysMenuController {
|
||||
|
||||
@PreAuthorize("hasAuthority('system:menu:query')")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
@Operation(summary = "获取详情")
|
||||
public AjaxResult getInfo(@PathVariable String menuId) {
|
||||
return AjaxResult.success(sysMenuService.selectById(menuId));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('system:menu:add')")
|
||||
@PostMapping
|
||||
@Operation(summary = "添加菜单")
|
||||
public AjaxResult add(@Validated @RequestBody SysMenu menu) {
|
||||
return AjaxResult.toAjax(sysMenuService.insert(menu));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('system:menu:edit')")
|
||||
@PutMapping
|
||||
@Operation(summary = "修改菜单")
|
||||
public AjaxResult edit(@Validated @RequestBody SysMenu menu) {
|
||||
return AjaxResult.toAjax(sysMenuService.updateById(menu));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('system:menu:remove')")
|
||||
@DeleteMapping("/{menuId}")
|
||||
@Operation(summary = "删除菜单")
|
||||
public AjaxResult remove(@PathVariable("menuId") String menuId) {
|
||||
return AjaxResult.toAjax(sysMenuService.deleteById(menuId));
|
||||
}
|
||||
|
||||
@GetMapping("/tree_select")
|
||||
@GetMapping("/tree-select")
|
||||
@Operation(summary = "构建菜单树")
|
||||
public AjaxResult treeSelect(SysMenuParam param) {
|
||||
List<SysMenuVo> menus = sysMenuService.selectVoList(param);
|
||||
return AjaxResult.success(sysMenuService.buildMenuTree(menus));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/role_menu_tree_select/{roleId}")
|
||||
@GetMapping(value = "/role-menu-tree-select/{roleId}")
|
||||
@Operation(summary = "角色菜单树")
|
||||
public AjaxResult roleMenuTreeSelect(@PathVariable("roleId") String roleId) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("checkedKeys", sysMenuService.selectMenuIdsByRoleId(roleId));
|
||||
|
@ -10,6 +10,7 @@ import com.qiaoba.api.system.entity.param.SysPostParam;
|
||||
import com.qiaoba.api.system.entity.param.SysRoleParam;
|
||||
import com.qiaoba.api.system.entity.param.SysUserParam;
|
||||
import com.qiaoba.api.system.entity.vo.SysUserVo;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.enums.BaseEnum;
|
||||
import com.qiaoba.common.base.result.AjaxResult;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
@ -17,14 +18,17 @@ import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
import com.qiaoba.common.poi.utils.ExcelUtil;
|
||||
import com.qiaoba.module.system.service.*;
|
||||
import com.qiaoba.module.system.templates.SysUserExport;
|
||||
import com.qiaoba.module.system.templates.SysUserImport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -47,6 +51,7 @@ public class SysUserController {
|
||||
private final SysPostService sysPostService;
|
||||
private final SysUserPostService sysUserPostService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final SysUserImportService sysUserImportService;
|
||||
|
||||
@PreAuthorize("hasAuthority('system:user:add')")
|
||||
@PostMapping
|
||||
@ -80,7 +85,7 @@ public class SysUserController {
|
||||
@DeleteMapping("/{userIds}")
|
||||
@Operation(summary = "删除用户")
|
||||
public AjaxResult remove(@PathVariable List<String> userIds) {
|
||||
return AjaxResult.toAjax(sysUserService.deleteByIds(userIds, true));
|
||||
return AjaxResult.toAjax(sysUserService.deleteByIds(userIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ -114,6 +119,20 @@ public class SysUserController {
|
||||
ExcelUtil.exportExcel(list, SysUserExport.class, "用户数据", response);
|
||||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
@Operation(summary = "导出模板")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), SysUserImport.class, "用户导入模板-(*)必填", response);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('system:user:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file) throws Exception {
|
||||
List<SysUserImport> list = ExcelUtil.importExcel(file, SysUserImport.class);
|
||||
Integer success = sysUserImportService.importUser(list);
|
||||
return AjaxResult.success(StrUtil.format("成功导入({})条数据", success));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('system:user:query')")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
@Operation(summary = "已分配角色列表")
|
||||
@ -134,4 +153,16 @@ public class SysUserController {
|
||||
sysUserService.handleUserRole(userId, Arrays.stream(roleIds).collect(Collectors.toSet()), true);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人中心-个人信息
|
||||
*/
|
||||
@GetMapping("/profile")
|
||||
public AjaxResult profile() {
|
||||
String username = SecurityUtil.getLoginUserId();
|
||||
AjaxResult ajax = AjaxResult.success(sysUserService.selectById(username, false));
|
||||
ajax.put("roleGroup", "超级管理员,普通角色");
|
||||
ajax.put("postGroup", "董事长");
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
@ -43,15 +43,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
*/
|
||||
int checkEmailUnique(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 更新删除状态
|
||||
*
|
||||
* @param userIds userIds
|
||||
* @param status status
|
||||
* @return 结果
|
||||
*/
|
||||
int updateUserDeleteStatus(@Param("list") List<String> userIds, String status);
|
||||
|
||||
/**
|
||||
* 分页查询用户列表
|
||||
*
|
||||
|
@ -29,4 +29,11 @@ public interface SysUserPostMapper extends BaseMapper<SysUserPost> {
|
||||
* @return postNames
|
||||
*/
|
||||
List<String> selectUsedPostNameByIds(@Param("list") List<String> postIds);
|
||||
|
||||
/**
|
||||
* 通过userIds删除
|
||||
*
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void deleteByUserIds(@Param("list") List<String> userIds);
|
||||
}
|
||||
|
@ -31,4 +31,11 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void deleteByRoleIdAndUserIds(@Param("roleId") String roleId, @Param("list") List<String> userIds);
|
||||
|
||||
/**
|
||||
* 通过userIds删除
|
||||
*
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void deleteByUserIds(@Param("list") List<String> userIds);
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.qiaoba.module.system.service;
|
||||
|
||||
import com.qiaoba.module.system.templates.SysUserImport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户导入 服务层
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/5/18 14:49
|
||||
*/
|
||||
public interface SysUserImportService {
|
||||
|
||||
/**
|
||||
* 导入用户信息
|
||||
*
|
||||
* @param users users
|
||||
* @return 成功条数
|
||||
*/
|
||||
Integer importUser(List<SysUserImport> users);
|
||||
}
|
@ -27,6 +27,13 @@ public interface SysUserPostService {
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 通过userIds删除
|
||||
*
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 通过userId查询所绑定的岗位ID列表
|
||||
*
|
||||
|
@ -27,6 +27,13 @@ public interface SysUserRoleService {
|
||||
*/
|
||||
void deleteByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 通过userIds删除
|
||||
*
|
||||
* @param userIds userIds
|
||||
*/
|
||||
void deleteByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 批量取消角色所绑定的用户
|
||||
*
|
||||
|
@ -99,8 +99,6 @@ public class SysLoginServiceImpl implements SysLoginService {
|
||||
private void validateUser(String username, SysUser user) {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
throw new ServiceException(StrUtil.format("登录用户:{} 不存在", username));
|
||||
} else if (BaseEnum.YES.getCode().equals(user.getIsDelete())) {
|
||||
throw new ServiceException(StrUtil.format("对不起, 您的账号:{} 已被删除", username));
|
||||
} else if (BaseEnum.ABNORMAL.getCode().equals(user.getStatus())) {
|
||||
throw new ServiceException(StrUtil.format("对不起, 您的账号:{} 已被禁用", username));
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
package com.qiaoba.module.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.qiaoba.api.system.entity.SysUser;
|
||||
import com.qiaoba.api.system.entity.dto.SysUserDto;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.constants.BaseConstant;
|
||||
import com.qiaoba.common.base.exceptions.ServiceException;
|
||||
import com.qiaoba.common.base.utils.ObjectUtil;
|
||||
import com.qiaoba.module.system.service.SysUserImportService;
|
||||
import com.qiaoba.module.system.service.SysUserService;
|
||||
import com.qiaoba.module.system.templates.SysUserImport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户导入 服务层实现
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/5/18 14:50
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SysUserImportServiceImpl implements SysUserImportService {
|
||||
|
||||
private final SysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer importUser(List<SysUserImport> users) {
|
||||
Integer success = 0;
|
||||
|
||||
for (SysUserImport importUser : users) {
|
||||
if (!ObjectUtil.isAllFieldNull(importUser)) {
|
||||
// 校验数据
|
||||
checkParams(importUser);
|
||||
sysUserService.saveOrUpdate(createUserDto(importUser), false);
|
||||
success++;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private SysUserDto createUserDto(SysUserImport importUser) {
|
||||
SysUserDto dto = BeanUtil.copyProperties(importUser, SysUserDto.class);
|
||||
if (StrUtil.isNotBlank(importUser.getRole())) {
|
||||
String[] roleArr = importUser.getRole().split(BaseConstant.DEFAULT_SPLIT_STR);
|
||||
dto.setRoleIds(Arrays.stream(roleArr).collect(Collectors.toSet()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(importUser.getPost())) {
|
||||
String[] postArr = importUser.getPost().split(BaseConstant.DEFAULT_SPLIT_STR);
|
||||
dto.setPostIds(Arrays.stream(postArr).collect(Collectors.toSet()));
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
private void checkParams(SysUserImport importUser) {
|
||||
if (StrUtil.isBlank(importUser.getUsername())) {
|
||||
throw new ServiceException("登录账号不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(importUser.getPassword())) {
|
||||
throw new ServiceException("登录密码不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(importUser.getNickname())) {
|
||||
throw new ServiceException("用户姓名不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(importUser.getRole())) {
|
||||
throw new ServiceException("用户角色不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(importUser.getStatus())) {
|
||||
throw new ServiceException("用户状态不能为空");
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,11 @@ public class SysUserPostServiceImpl implements SysUserPostService {
|
||||
sysUserPostMapper.delete(createWrapper(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
sysUserPostMapper.deleteByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectPostIdsByUserId(String userId) {
|
||||
return sysUserPostMapper.selectPostIdsByUserId(userId);
|
||||
|
@ -34,6 +34,11 @@ public class SysUserRoleServiceImpl implements SysUserRoleService {
|
||||
sysUserRoleMapper.delete(createWrapper(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByUserIds(List<String> userIds) {
|
||||
sysUserRoleMapper.deleteByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByRoleIdAndUserIds(String roleId, List<String> userIds) {
|
||||
sysUserRoleMapper.deleteByRoleIdAndUserIds(roleId, userIds);
|
||||
|
@ -2,6 +2,7 @@ package com.qiaoba.module.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -13,13 +14,11 @@ import com.qiaoba.api.system.entity.dto.ResetUserStatusDto;
|
||||
import com.qiaoba.api.system.entity.dto.SysUserDto;
|
||||
import com.qiaoba.api.system.entity.param.SysUserParam;
|
||||
import com.qiaoba.api.system.entity.vo.SysUserVo;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.common.base.enums.BaseEnum;
|
||||
import com.qiaoba.common.base.exceptions.ServiceException;
|
||||
import com.qiaoba.common.database.entity.PageQuery;
|
||||
import com.qiaoba.common.database.entity.TableDataInfo;
|
||||
import com.qiaoba.common.redis.constants.CacheConstant;
|
||||
import com.qiaoba.common.redis.service.RedisService;
|
||||
import com.qiaoba.auth.utils.SecurityUtil;
|
||||
import com.qiaoba.module.system.mapper.SysUserMapper;
|
||||
import com.qiaoba.module.system.service.SysUserPostService;
|
||||
import com.qiaoba.module.system.service.SysUserRoleService;
|
||||
@ -27,6 +26,7 @@ import com.qiaoba.module.system.service.SysUserService;
|
||||
import com.qiaoba.module.system.templates.SysUserExport;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -44,10 +44,10 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
private final SysUserMapper sysUserMapper;
|
||||
private final SysUserPostService sysUserPostService;
|
||||
private final SysUserRoleService sysUserRoleService;
|
||||
private final RedisService redisService;
|
||||
|
||||
@Override
|
||||
public int saveOrUpdate(SysUserDto dto, Boolean isUpdate) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized int saveOrUpdate(SysUserDto dto, Boolean isUpdate) {
|
||||
int result = 0;
|
||||
SysUser sysUser = dtoToSysUser(dto, isUpdate);
|
||||
// 检验是否已存在
|
||||
@ -97,10 +97,12 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByIds(List<String> userIds, Boolean isSoftDelete) {
|
||||
if (isSoftDelete) {
|
||||
return sysUserMapper.updateUserDeleteStatus(userIds, BaseEnum.YES.getCode());
|
||||
}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteByIds(List<String> userIds) {
|
||||
// 删除和角色绑定
|
||||
sysUserRoleService.deleteByUserIds(userIds);
|
||||
// 删除和岗位绑定
|
||||
sysUserPostService.deleteByUserIds(userIds);
|
||||
return sysUserMapper.deleteBatchIds(userIds);
|
||||
}
|
||||
|
||||
@ -133,6 +135,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleUserRole(String userId, Set<String> roleIds, boolean isUpdate) {
|
||||
if (isUpdate) {
|
||||
sysUserRoleService.deleteByUserId(userId);
|
||||
@ -149,8 +152,12 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
|
||||
@Override
|
||||
public List<SysUserExport> selectExportData(SysUserParam param) {
|
||||
return sysUserMapper.selectExportData(param);
|
||||
//return sysUserMapper.selectVoList(param);
|
||||
List<SysUserExport> list = sysUserMapper.selectExportData(param);
|
||||
list.forEach(export -> {
|
||||
export.setRole(CollectionUtil.join(export.getRoles(), "|"));
|
||||
export.setPost(CollectionUtil.join(export.getPosts(), "|"));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
private QueryWrapper<SysUser> param2Wrapper(SysUserParam sysUserParam) {
|
||||
@ -158,7 +165,6 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
wrapper.lambda()
|
||||
.orderByAsc(SysUser::getCreateTime)
|
||||
.eq(StrUtil.isNotBlank(sysUserParam.getDeptId()), SysUser::getDeptId, sysUserParam.getDeptId())
|
||||
.eq(StrUtil.isNotBlank(sysUserParam.getIsDelete()), SysUser::getIsDelete, sysUserParam.getIsDelete())
|
||||
.eq(StrUtil.isNotBlank(sysUserParam.getStatus()), SysUser::getStatus, sysUserParam.getStatus())
|
||||
.ge(StrUtil.isNotBlank(sysUserParam.getBeginTime()), SysUser::getCreateTime, sysUserParam.getBeginTime())
|
||||
.le(StrUtil.isNotBlank(sysUserParam.getEndTime()), SysUser::getCreateTime, sysUserParam.getEndTime())
|
||||
@ -225,7 +231,8 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
|
||||
}
|
||||
|
||||
private void handleUserPost(String userId, Set<String> postIds, boolean isUpdate) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void handleUserPost(String userId, Set<String> postIds, boolean isUpdate) {
|
||||
if (isUpdate) {
|
||||
sysUserPostService.deleteByUserId(userId);
|
||||
}
|
||||
@ -239,5 +246,4 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
sysUserPostService.insertBatch(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.qiaoba.module.system.templates;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@ -30,6 +28,12 @@ public class SysUserExport {
|
||||
@Excel(name = "部门", width = 20)
|
||||
private String deptName;
|
||||
|
||||
@Excel(name = "角色", width = 30)
|
||||
private String role;
|
||||
|
||||
@Excel(name = "岗位", width = 30)
|
||||
private String post;
|
||||
|
||||
@Excel(name = "性别", replace = {"男_0", "女_1", "未知_2"})
|
||||
private String gender;
|
||||
|
||||
@ -45,11 +49,8 @@ public class SysUserExport {
|
||||
@Excel(name = "创建时间", width = 30, format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String role = this.roles.toString();
|
||||
//@ExcelCollection(name = "角色")
|
||||
private List<String> roles;
|
||||
|
||||
//@ExcelCollection(name = "岗位")
|
||||
private List<String> posts;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.qiaoba.module.system.templates;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户导入模板
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2023/5/17 17:16
|
||||
*/
|
||||
@Data
|
||||
public class SysUserImport {
|
||||
|
||||
@Excel(name = "登录账号(*)", width = 20)
|
||||
private String username;
|
||||
|
||||
@Excel(name = "账号密码(*)", width = 20)
|
||||
private String password;
|
||||
|
||||
@Excel(name = "姓名(*)", width = 20)
|
||||
private String nickname;
|
||||
|
||||
@Excel(name = "角色(*)", width = 20)
|
||||
private String role;
|
||||
|
||||
@Excel(name = "部门", width = 20)
|
||||
private String deptId;
|
||||
|
||||
@Excel(name = "岗位", width = 20)
|
||||
private String post;
|
||||
|
||||
/**
|
||||
* addressList = true -> 下拉框
|
||||
*/
|
||||
@Excel(name = "性别", replace = {"男_0", "女_1", "未知_2"}, addressList = true)
|
||||
private String gender;
|
||||
|
||||
@Excel(name = "手机", width = 20)
|
||||
private String phone;
|
||||
|
||||
@Excel(name = "邮箱", width = 20)
|
||||
private String email;
|
||||
|
||||
@Excel(name = "状态(*)", replace = {"正常_1", "禁用_0"}, addressList = true)
|
||||
private String status;
|
||||
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
</select>
|
||||
|
||||
<select id="existUsed" resultType="string">
|
||||
SELECT nickname from sys_user where dept_id = #{deptId} and is_delete = '0' limit 1
|
||||
SELECT nickname from sys_user where dept_id = #{deptId} limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -23,11 +23,11 @@
|
||||
<result property="nickname" column="nickname"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="sex" column="sex"/>
|
||||
<result property="gender" column="gender"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||
<collection property="posts" javaType="java.util.List" resultMap="PostResult"/>
|
||||
<collection property="roles" ofType="string" resultMap="RoleResult"/>
|
||||
<collection property="posts" ofType="string" resultMap="PostResult"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="RoleResult" type="string">
|
||||
@ -43,28 +43,29 @@
|
||||
FROM sys_user u
|
||||
left join sys_dept t2
|
||||
on u.dept_id = t2.dept_id
|
||||
where u.is_delete = #{param.isDelete}
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND u.username like concat('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null and param.nickname != ''">
|
||||
AND u.nickname like concat('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
AND u.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deptId != null and param.deptId != ''">
|
||||
AND u.dept_id = #{param.deptId}
|
||||
</if>
|
||||
<if test="param.phone != null and param.phone != ''">
|
||||
AND u.phone like concat('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.beginTime != null and param.beginTime != ''">
|
||||
AND u.create_time >= #{param.beginTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND u.create_time <= #{param.endTime}
|
||||
</if>
|
||||
<where>
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND u.username like concat('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null and param.nickname != ''">
|
||||
AND u.nickname like concat('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
AND u.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deptId != null and param.deptId != ''">
|
||||
AND u.dept_id = #{param.deptId}
|
||||
</if>
|
||||
<if test="param.phone != null and param.phone != ''">
|
||||
AND u.phone like concat('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.beginTime != null and param.beginTime != ''">
|
||||
AND u.create_time >= #{param.beginTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND u.create_time <= #{param.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectVoPageList" resultMap="SysUserVoResult">
|
||||
@ -79,28 +80,29 @@
|
||||
left join sys_role t4 on t4.role_id = t3.role_id
|
||||
left join sys_user_post t5 on t5.user_id = t1.user_id
|
||||
left join sys_post t6 on t6.post_id = t5.post_id
|
||||
where t1.is_delete = #{param.isDelete}
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND t1.username like concat('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null and param.nickname != ''">
|
||||
AND t1.nickname like concat('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
AND t1.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deptId != null and param.deptId != ''">
|
||||
AND t1.dept_id = #{param.deptId}
|
||||
</if>
|
||||
<if test="param.phone != null and param.phone != ''">
|
||||
AND t1.phone like concat('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.beginTime != null and param.beginTime != ''">
|
||||
AND t1.create_time >= #{param.beginTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND t1.create_time <= #{param.endTime}
|
||||
</if>
|
||||
<where>
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND t1.username like concat('%', #{param.username}, '%')
|
||||
</if>
|
||||
<if test="param.nickname != null and param.nickname != ''">
|
||||
AND t1.nickname like concat('%', #{param.nickname}, '%')
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
AND t1.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deptId != null and param.deptId != ''">
|
||||
AND t1.dept_id = #{param.deptId}
|
||||
</if>
|
||||
<if test="param.phone != null and param.phone != ''">
|
||||
AND t1.phone like concat('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.beginTime != null and param.beginTime != ''">
|
||||
AND t1.create_time >= #{param.beginTime}
|
||||
</if>
|
||||
<if test="param.endTime != null and param.endTime != ''">
|
||||
AND t1.create_time <= #{param.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAllocatedList" resultMap="SysUserVoResult">
|
||||
@ -112,7 +114,7 @@
|
||||
on t1.user_id = t3.user_id
|
||||
left join sys_role t4
|
||||
on t4.role_id = t3.role_id
|
||||
where t1.is_delete = #{param.isDelete} and t4.role_id = #{param.roleId}
|
||||
where t4.role_id = #{param.roleId}
|
||||
<if test="param.username != null and param.username != ''">
|
||||
AND t1.username like concat('%', #{param.username}, '%')
|
||||
</if>
|
||||
@ -127,7 +129,7 @@
|
||||
left join sys_dept t2 on t1.dept_id = t2.dept_id
|
||||
left join sys_user_role t3 on t1.user_id = t3.user_id
|
||||
left join sys_role t4 on t4.role_id = t3.role_id
|
||||
where t1.is_delete = #{param.isDelete} and (t4.role_id != #{param.roleId} or t4.role_id IS NULL)
|
||||
where (t4.role_id != #{param.roleId} or t4.role_id IS NULL)
|
||||
and t1.user_id not in (select t1.user_id from sys_user t1 inner join sys_user_role t3 on t1.user_id = t3.user_id and
|
||||
t3.role_id = #{param.roleId})
|
||||
<if test="param.username != null and param.username != ''">
|
||||
@ -142,27 +144,21 @@
|
||||
<include refid="selectUserVo"/>
|
||||
</select>
|
||||
<select id="checkUsernameUnique" resultType="int">
|
||||
select count(*) from sys_user where username = #{username} and is_delete = #{isDelete}
|
||||
select count(*) from sys_user where username = #{username}
|
||||
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkPhoneUnique" resultType="int">
|
||||
select count(*) from sys_user where phone = #{phone} and is_delete = #{isDelete}
|
||||
select count(*) from sys_user where phone = #{phone}
|
||||
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkEmailUnique" resultType="int">
|
||||
select count(*) from sys_user where email = #{email} and is_delete = #{isDelete}
|
||||
select count(*) from sys_user where email = #{email}
|
||||
<if test="userId != null and userId != ''">and user_id != #{userId}</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateUserDeleteStatus">
|
||||
update sys_user set is_delete = #{status} where user_id in
|
||||
<foreach collection="list" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
|
@ -19,4 +19,10 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteByUserIds">
|
||||
delete from sys_user_post where user_id in
|
||||
<foreach collection="list" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
@ -19,4 +19,11 @@
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByUserIds">
|
||||
delete from sys_user_role where user_id in
|
||||
<foreach collection="list" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user