用户管理关联班组
This commit is contained in:
parent
b002590925
commit
81a78dfab5
|
|
@ -92,6 +92,15 @@ public class SysUser extends BaseEntity
|
|||
/** 登录权限 */
|
||||
private String loginType;
|
||||
|
||||
/** 班组ID */
|
||||
private Long teamId;
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleName;
|
||||
|
||||
public SysUser()
|
||||
{
|
||||
|
||||
|
|
@ -308,6 +317,30 @@ public class SysUser extends BaseEntity
|
|||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
public Long getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(Long teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode;
|
||||
}
|
||||
|
||||
public void setRoleCode(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -331,6 +364,9 @@ public class SysUser extends BaseEntity
|
|||
.append("remark", getRemark())
|
||||
.append("dept", getDept())
|
||||
.append("loginType", getLoginType())
|
||||
.append("teamId", getTeamId())
|
||||
.append("roleCode", getRoleCode())
|
||||
.append("roleName", getRoleName())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,13 +45,12 @@ import com.bonus.system.service.ISysUserService;
|
|||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class SysUserController extends BaseController
|
||||
{
|
||||
public class SysUserController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
|
|
@ -75,53 +74,53 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:list")
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.QUERY,logType = 0,module = "系统管理->用户管理",details = "查询用户列表")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->用户管理", details = "查询用户列表")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
try{
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
try {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:export")
|
||||
@PostMapping("/export")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->用户管理",details = "导出用户信息")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.EXPORT, logType = 0, module = "系统管理->用户管理", details = "导出用户信息")
|
||||
public void export(HttpServletResponse response, SysUser user) {
|
||||
try{
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
try {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/importData")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.IMPORT,logType = 0,module = "系统管理->用户管理",details = "导入用户信息")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.IMPORT, logType = 0, module = "系统管理->用户管理", details = "导入用户信息")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
try{
|
||||
try {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String operName = SecurityUtils.getUsername();
|
||||
String message = userService.importUser(userList, updateSupport, operName);
|
||||
return success(message);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
try{
|
||||
try {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,11 +129,9 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/info/{username}")
|
||||
public R<LoginUser> info(@PathVariable("username") String username)
|
||||
{
|
||||
public R<LoginUser> info(@PathVariable("username") String username) {
|
||||
SysUser sysUser = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(sysUser))
|
||||
{
|
||||
if (StringUtils.isNull(sysUser)) {
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
// 角色集合
|
||||
|
|
@ -154,15 +151,12 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/register")
|
||||
public R<Boolean> register(@RequestBody SysUser sysUser)
|
||||
{
|
||||
public R<Boolean> register(@RequestBody SysUser sysUser) {
|
||||
String username = sysUser.getUserName();
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||
{
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
if (!userService.checkUserNameUnique(sysUser))
|
||||
{
|
||||
if (!userService.checkUserNameUnique(sysUser)) {
|
||||
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
|
||||
}
|
||||
return R.ok(userService.registerUser(sysUser));
|
||||
|
|
@ -170,12 +164,12 @@ public class SysUserController extends BaseController
|
|||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public AjaxResult getInfo() {
|
||||
try{
|
||||
try {
|
||||
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
|
|
@ -186,8 +180,8 @@ public class SysUserController extends BaseController
|
|||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -196,25 +190,24 @@ public class SysUserController extends BaseController
|
|||
* 根据用户编号获取详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:user:query")
|
||||
@GetMapping(value = { "/", "/{userId}" })
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
try{
|
||||
try {
|
||||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", roles);
|
||||
// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||
}
|
||||
return ajax;
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -224,32 +217,27 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@PostMapping
|
||||
@SysLog(title = "用户管理", businessType = OperaType.INSERT,logType = 0,module = "系统管理->用户管理",details = "新增用户信息")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.INSERT, logType = 0, module = "系统管理->用户管理", details = "新增用户信息")
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
try{
|
||||
try {
|
||||
deptService.checkDeptDataScope(user.getDeptId());
|
||||
roleService.checkRoleDataScope(user.getRoleIds());
|
||||
if (!userService.checkUserNameUnique(user))
|
||||
{
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
String pwd = ValidateUtils.isPwd(user.getPassword());
|
||||
if(StringUtils.isNotEmpty(pwd)){
|
||||
if (StringUtils.isNotEmpty(pwd)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败," + pwd);
|
||||
}
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -259,29 +247,24 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->用户管理",details = "修改用户信息")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->用户管理", details = "修改用户信息")
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||
try{
|
||||
try {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
deptService.checkDeptDataScope(user.getDeptId());
|
||||
roleService.checkRoleDataScope(user.getRoleIds());
|
||||
if (!userService.checkUserNameUnique(user))
|
||||
{
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -291,16 +274,16 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:remove")
|
||||
@DeleteMapping("/{userIds}")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.DELETE,logType = 0,module = "系统管理->用户管理",details = "删除用户信息")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.DELETE, logType = 0, module = "系统管理->用户管理", details = "删除用户信息")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds) {
|
||||
try{
|
||||
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
try {
|
||||
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId())) {
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
|
|
@ -309,16 +292,16 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping("/resetPwd")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->用户管理",details = "重置用户密码")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->用户管理", details = "重置用户密码")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||
try{
|
||||
try {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -328,15 +311,15 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping("/changeStatus")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->用户管理",details = "修改用户状态")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->用户管理", details = "修改用户状态")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||
try{
|
||||
try {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -347,15 +330,15 @@ public class SysUserController extends BaseController
|
|||
@RequiresPermissions("system:user:query")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId) {
|
||||
try{
|
||||
try {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
return ajax;
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -365,15 +348,15 @@ public class SysUserController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping("/authRole")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.GRANT,logType = 0,module = "系统管理->用户管理",details = "用户授权角色")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.GRANT, logType = 0, module = "系统管理->用户管理", details = "用户授权角色")
|
||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
|
||||
try{
|
||||
try {
|
||||
userService.checkUserDataScope(userId);
|
||||
roleService.checkRoleDataScope(roleIds);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
|
@ -384,11 +367,24 @@ public class SysUserController extends BaseController
|
|||
@RequiresPermissions("system:user:list")
|
||||
@GetMapping("/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept) {
|
||||
try{
|
||||
try {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户关联班组
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2024/7/15 14:54
|
||||
*/
|
||||
@RequiresPermissions("system:user:associationTeam")
|
||||
@PostMapping("/associationTeam")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.GRANT, logType = 0, module = "系统管理->用户管理", details = "关联班组")
|
||||
public AjaxResult userAssociationTeam(@RequestBody SysUser user) {
|
||||
return userService.userAssociationTeam(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,4 +124,14 @@ public interface SysUserMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
|
||||
/**
|
||||
* 用户关联班组
|
||||
* @param user
|
||||
* @return void
|
||||
* @author cwchen
|
||||
* @date 2024/7/15 15:08
|
||||
*/
|
||||
void userAssociationTeam(SysUser user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package com.bonus.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
*
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
public interface ISysUserService
|
||||
{
|
||||
public interface ISysUserService {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
|
@ -20,7 +21,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
|
@ -28,7 +29,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
|
|
@ -36,7 +37,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
|
|
@ -44,7 +45,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
|
|
@ -52,7 +53,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 根据用户ID查询用户所属角色组
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -60,7 +61,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 根据用户ID查询用户所属岗位组
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -68,7 +69,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -92,21 +93,21 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
public void checkUserAllowed(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void checkUserDataScope(Long userId);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -114,7 +115,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -122,7 +123,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -130,15 +131,15 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -146,7 +147,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -154,16 +155,16 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean updateUserAvatar(String userName, String avatar);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -171,7 +172,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
|
|
@ -180,7 +181,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -188,7 +189,7 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
*
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -196,11 +197,20 @@ public interface ISysUserService
|
|||
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @param operName 操作用户
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
/**
|
||||
* 用户关联班组
|
||||
* @param user
|
||||
* @return AjaxResult
|
||||
* @author cwchen
|
||||
* @date 2024/7/15 14:56
|
||||
*/
|
||||
AjaxResult userAssociationTeam(SysUser user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import com.bonus.common.core.constant.UserConstants;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
|
|
@ -548,4 +551,16 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult userAssociationTeam(SysUser user) {
|
||||
try {
|
||||
userMapper.userAssociationTeam(user);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("用户关联班组",e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="loginType" column="login_type"/>
|
||||
<result property="teamId" column="team_id"/>
|
||||
<result property="roleCode" column="role_code"/>
|
||||
<result property="roleName" column="role_name"/>
|
||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||
|
||||
|
|
@ -51,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.login_type
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.login_type,u.team_id
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
|
|
@ -59,8 +62,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</sql>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" 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, d.dept_name, d.leader from sys_user u
|
||||
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, d.dept_name, d.leader,u.login_type,u.team_id,sr.role_code,sr.role_name from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
LEFT JOIN sys_user_role sur ON u.user_id = sur.user_id
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id AND sr.del_flag = '0' AND sr.status = '0'
|
||||
where u.del_flag = '0'
|
||||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
|
|
@ -211,7 +216,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="resetUserPwd" parameterType="SysUser">
|
||||
update sys_user set password = #{password} where user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<!--用户关联班组-->
|
||||
<update id="userAssociationTeam">
|
||||
UPDATE sys_user SET team_id = #{teamId} WHERE user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserById" parameterType="Long">
|
||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||
</delete>
|
||||
|
|
|
|||
Loading…
Reference in New Issue