系统管理
This commit is contained in:
parent
4c95d2b3cd
commit
5f398d6fcd
|
|
@ -76,6 +76,13 @@ public class SysRole extends BaseEntity
|
|||
/**是否内置,0内置,1非内置*/
|
||||
private String isBuiltIn;
|
||||
|
||||
/**角色级别*/
|
||||
private String roleLevel;
|
||||
/**角色级别描述*/
|
||||
private String roleLevelTips;
|
||||
/**角色级别名称*/
|
||||
private String roleLevelName;
|
||||
|
||||
public SysRole()
|
||||
{
|
||||
|
||||
|
|
@ -266,4 +273,28 @@ public class SysRole extends BaseEntity
|
|||
public void setIsBuiltIn(String isBuiltIn) {
|
||||
this.isBuiltIn = isBuiltIn;
|
||||
}
|
||||
|
||||
public String getRoleLevel() {
|
||||
return roleLevel;
|
||||
}
|
||||
|
||||
public void setRoleLevel(String roleLevel) {
|
||||
this.roleLevel = roleLevel;
|
||||
}
|
||||
|
||||
public String getRoleLevelTips() {
|
||||
return roleLevelTips;
|
||||
}
|
||||
|
||||
public void setRoleLevelTips(String roleLevelTips) {
|
||||
this.roleLevelTips = roleLevelTips;
|
||||
}
|
||||
|
||||
public String getRoleLevelName() {
|
||||
return roleLevelName;
|
||||
}
|
||||
|
||||
public void setRoleLevelName(String roleLevelName) {
|
||||
this.roleLevelName = roleLevelName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,49 +30,49 @@ public class SysUser extends BaseEntity {
|
|||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||
// @Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@Excel(name = "部门编号", type = Type.IMPORT)
|
||||
// @Excel(name = "部门编号", type = Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Excel(name = "公司编号", type = Type.IMPORT)
|
||||
// @Excel(name = "公司编号", type = Type.IMPORT)
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@Excel(name = "登录名称")
|
||||
@Excel(name = "登录账号")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@Excel(name = "用户名称")
|
||||
@Excel(name = "姓名")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@Excel(name = "用户邮箱")
|
||||
// @Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
|
||||
// @Excel(name = "手机号码", cellType = ColumnType.TEXT)
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
// @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
|
|
@ -85,11 +85,10 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
@Excel(name = "角色")
|
||||
private String roleName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
|
|
@ -99,22 +98,22 @@ public class SysUser extends BaseEntity {
|
|||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
||||
// @Excel(name = "最后登录IP", type = Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||
// @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 部门对象
|
||||
*/
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
||||
})
|
||||
// @Excels({
|
||||
// @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||
// @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
||||
// })
|
||||
private SysDept dept;
|
||||
|
||||
/**
|
||||
|
|
@ -140,11 +139,11 @@ public class SysUser extends BaseEntity {
|
|||
/**
|
||||
* 登录权限
|
||||
*/
|
||||
private String loginType;
|
||||
private String loginType = "0";
|
||||
/**
|
||||
* 审批状态
|
||||
*/
|
||||
private String approvalStatus;
|
||||
private String approvalStatus = "1";
|
||||
/**
|
||||
* 长期和临时用户标识
|
||||
*/
|
||||
|
|
@ -153,6 +152,27 @@ public class SysUser extends BaseEntity {
|
|||
/**是否内置,0内置,1非内置*/
|
||||
private String isBuiltIn = "1";
|
||||
|
||||
/**角色等级*/
|
||||
@Excel(name = "角色级别")
|
||||
private String roleLevel;
|
||||
|
||||
/**绑定id*/
|
||||
private Long bandId;
|
||||
|
||||
/**1 公司 2 分公司 3 项目部 4分包商 5施工人员*/
|
||||
private String permissionType;
|
||||
/**权限范围*/
|
||||
@Excel(name = "权限范围")
|
||||
private String permissionRange;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**角色名称*/
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
|
@ -387,4 +407,44 @@ public class SysUser extends BaseEntity {
|
|||
public void setIsBuiltIn(String isBuiltIn) {
|
||||
this.isBuiltIn = isBuiltIn;
|
||||
}
|
||||
|
||||
public String getRoleLevel() {
|
||||
return roleLevel;
|
||||
}
|
||||
|
||||
public void setRoleLevel(String roleLevel) {
|
||||
this.roleLevel = roleLevel;
|
||||
}
|
||||
|
||||
public Long getBandId() {
|
||||
return bandId;
|
||||
}
|
||||
|
||||
public void setBandId(Long bandId) {
|
||||
this.bandId = bandId;
|
||||
}
|
||||
|
||||
public String getPermissionType() {
|
||||
return permissionType;
|
||||
}
|
||||
|
||||
public void setPermissionType(String permissionType) {
|
||||
this.permissionType = permissionType;
|
||||
}
|
||||
|
||||
public String getPermissionRange() {
|
||||
return permissionRange;
|
||||
}
|
||||
|
||||
public void setPermissionRange(String permissionRange) {
|
||||
this.permissionRange = permissionRange;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class SysRoleController extends BaseController
|
|||
@SysLog(title = "角色管理", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->角色管理",details = "修改角色")
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role) {
|
||||
try{
|
||||
roleService.checkRoleAllowed(role);
|
||||
// roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.bonus.system.api.model.LoginUser;
|
|||
import com.bonus.system.domain.UserPasswordHistory;
|
||||
import com.bonus.system.service.*;
|
||||
import com.bonus.system.warning.WebSocketHandler;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -33,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
@ -140,10 +142,10 @@ public class SysUserController extends BaseController {
|
|||
if (StringUtils.isNull(sysUser)) {
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
SysDept sysDept = deptService.selectActiveDeptById(sysUser.getCompanyId());
|
||||
/*SysDept sysDept = deptService.selectActiveDeptById(sysUser.getCompanyId());
|
||||
if (StringUtils.isNull(sysDept)) {
|
||||
return R.fail("用户所在公司停用或注销");
|
||||
}
|
||||
}*/
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
|
|
@ -166,10 +168,10 @@ public class SysUserController extends BaseController {
|
|||
if (StringUtils.isNull(sysUser)) {
|
||||
return R.fail("用户名或密码错误");
|
||||
}
|
||||
SysDept sysDept = deptService.selectActiveDeptById(sysUser.getCompanyId());
|
||||
/*SysDept sysDept = deptService.selectActiveDeptById(sysUser.getCompanyId());
|
||||
if (StringUtils.isNull(sysDept)) {
|
||||
return R.fail("用户所在公司停用或注销");
|
||||
}
|
||||
}*/
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||
// 权限集合
|
||||
|
|
@ -302,9 +304,9 @@ public class SysUserController extends BaseController {
|
|||
@SysLog(title = "用户管理", businessType = OperaType.INSERT, logType = 0, module = "系统管理->用户管理", details = "新增用户信息")
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
try {
|
||||
deptService.checkDeptDataScope(user.getDeptId());
|
||||
roleService.checkRoleDataScope(user.getRoleIds());
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
// deptService.checkDeptDataScope(user.getDeptId());
|
||||
// roleService.checkRoleDataScope(user.getRoleIds());
|
||||
/*if (!userService.checkUserNameUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
|
|
@ -312,18 +314,23 @@ public class SysUserController extends BaseController {
|
|||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
} else if (Objects.equals(user.getIsBuiltIn(), "0")){
|
||||
return error("内置用户不允许添加");
|
||||
}
|
||||
}*/
|
||||
/*String pwd = ValidateUtils.isPwd(user.getPassword());
|
||||
if (StringUtils.isNotEmpty(pwd)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败," + pwd);
|
||||
}*/
|
||||
if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("新增用户失败,登录账号已存在");
|
||||
}
|
||||
// 设置默认密码
|
||||
user.setPassword("HDsbd@123456");
|
||||
AjaxResult ajaxResult = passwordValidatorService.validatePassword(-100L, user.getUserName(), "", user.getPassword());
|
||||
if (ajaxResult.isError()) {
|
||||
return ajaxResult;
|
||||
}
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
|
||||
user.setRoleIds(Stream.of(user.getRoleId()).toArray(Long[]::new));
|
||||
return toAjax(userService.insertUser(user));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
|
|
@ -339,20 +346,22 @@ public class SysUserController extends BaseController {
|
|||
@SysLog(title = "用户管理", businessType = OperaType.UPDATE, logType = 0, module = "系统管理->用户管理", details = "修改用户信息")
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||
try {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
deptService.checkDeptDataScope(user.getDeptId());
|
||||
roleService.checkRoleDataScope(user.getRoleIds());
|
||||
// userService.checkUserAllowed(user);
|
||||
// userService.checkUserDataScope(user.getUserId());
|
||||
// deptService.checkDeptDataScope(user.getDeptId());
|
||||
// roleService.checkRoleDataScope(user.getRoleIds());
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("修改用户失败,登录账号已存在");
|
||||
}
|
||||
/*else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}else if (Objects.equals(user.getIsBuiltIn(), "0")){
|
||||
return error("内置用户不允许修改");
|
||||
}
|
||||
}*/
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
user.setRoleIds(Stream.of(user.getRoleId()).toArray(Long[]::new));
|
||||
return toAjax(userService.updateUser(user));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
|
|
@ -569,10 +578,16 @@ public class SysUserController extends BaseController {
|
|||
|
||||
@PostMapping("/confirmPassword")
|
||||
public AjaxResult confirmPassword(@RequestBody SysUser user) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Long userId = Optional.ofNullable(user.getUserId()).orElse(SecurityUtils.getUserId());
|
||||
user.setUserId(userId);
|
||||
SysUser sysUser = userService.selectUserById(user.getUserId());
|
||||
boolean b = SecurityUtils.matchesPassword(user.getPassword(), sysUser.getPassword());
|
||||
return b? success():error("密码错误");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取角色下拉选")
|
||||
@PostMapping("/getRoleList")
|
||||
public AjaxResult getRoleList(@RequestBody SysRole role) {
|
||||
return userService.getRoleList(role);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.bonus.system.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:SelectVo
|
||||
* @author:cwchen
|
||||
* @date:2025-08-16-13:40
|
||||
* @version:1.0
|
||||
* @description:下拉选-vo
|
||||
*/
|
||||
@Data
|
||||
public class SelectVo {
|
||||
|
||||
/**id*/
|
||||
private Long value;
|
||||
/**名称*/
|
||||
private String name;
|
||||
/**角色级别名称*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String level;
|
||||
/**角色级别类型*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String levelType;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.system.mapper;
|
||||
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.domain.vo.SelectVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -155,4 +156,6 @@ public interface SysUserMapper {
|
|||
Integer approvalStatus(Long userId);
|
||||
|
||||
int systemUpdateUser(SysUser user);
|
||||
|
||||
List<SelectVo> getRoleList(int type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.system.service;
|
|||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.domain.SysRole;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.aspectj.weaver.loadtime.Aj;
|
||||
|
|
@ -237,5 +238,5 @@ public interface ISysUserService {
|
|||
|
||||
public AjaxResult systemUpdateUser(SysUser user);
|
||||
|
||||
|
||||
AjaxResult getRoleList(SysRole role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ public class PasswordValidatorServiceImpl implements PasswordValidatorService {
|
|||
}
|
||||
|
||||
// 3. 检查常见弱密码
|
||||
if (containsWeakPassword(newPassword.toLowerCase())) {
|
||||
/*if (containsWeakPassword(newPassword.toLowerCase())) {
|
||||
return AjaxResult.error("密码包含常见的弱密码片段!");
|
||||
}
|
||||
}*/
|
||||
|
||||
// 4. 检查连续字符
|
||||
if (systemConfig.getPasswordConfig().isRestrictConsecutiveChars() && containsConsecutiveCharacters(newPassword.toLowerCase(), systemConfig.getPasswordConfig().getMaxConsecutiveChars())) {
|
||||
/*if (systemConfig.getPasswordConfig().isRestrictConsecutiveChars() && containsConsecutiveCharacters(newPassword.toLowerCase(), systemConfig.getPasswordConfig().getMaxConsecutiveChars())) {
|
||||
return AjaxResult.error("密码不能包含超过" + systemConfig.getPasswordConfig().getMaxConsecutiveChars() + "位连续字符!");
|
||||
}
|
||||
}*/
|
||||
|
||||
// 5. 检查用户名
|
||||
if (systemConfig.getPasswordConfig().isExcludeUsernameInPassword() && newPassword.toLowerCase().contains(username.toLowerCase())) {
|
||||
|
|
@ -63,9 +63,9 @@ public class PasswordValidatorServiceImpl implements PasswordValidatorService {
|
|||
}
|
||||
|
||||
// 7. 检查密码历史
|
||||
if (isPasswordInHistory(userId, newPassword)) {
|
||||
/*if (isPasswordInHistory(userId, newPassword)) {
|
||||
return AjaxResult.error("新密码不能与最近的" + systemConfig.getPasswordConfig().getPasswordHistoryLimit() + "个旧密码相同!");
|
||||
}
|
||||
}*/
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,11 +203,12 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
@Override
|
||||
public SysDept selectDeptById(Long deptId)
|
||||
{
|
||||
SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||
/*SysDept sysDept = deptMapper.selectDeptById(deptId);
|
||||
if (systemConfig.isAddRootCompany() && Objects.nonNull(sysDept.getParentId()) && sysDept.getParentId().equals(0L)) {
|
||||
SysUser sysUser = deptMapper.selectCompanyAdminByDept(deptId);
|
||||
sysDept.setSysUser(sysUser);
|
||||
}
|
||||
}*/
|
||||
SysDept sysDept = new SysDept();
|
||||
return sysDept;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
String str = menu.getMenuName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
|
||||
menu.setMenuName(str);
|
||||
}
|
||||
SysDept sysDept = deptMapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
menu.setTemplateId(sysDept.getMenuTemplateId());
|
||||
// SysDept sysDept = deptMapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
// menu.setTemplateId(sysDept.getMenuTemplateId());
|
||||
List<SysMenu> menuList = menuMapper.selectMenuList(menu);
|
||||
return menuList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
String str = role.getRoleKey().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
|
||||
role.setRoleKey(str);
|
||||
}
|
||||
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
// role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
return roleMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
public int insertRole(SysRole role)
|
||||
{
|
||||
// 新增角色信息
|
||||
role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
// role.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
roleMapper.insertRole(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.bonus.common.core.utils.encryption.Sm4Utils;
|
|||
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.core.web.domain.TreeEntity;
|
||||
import com.bonus.common.datascope.annotation.DataScope;
|
||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.common.security.config.VerificationCodeConfig;
|
||||
|
|
@ -20,11 +21,13 @@ import com.bonus.system.api.domain.SysRole;
|
|||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.domain.SysUserRole;
|
||||
import com.bonus.system.domain.SysUserPost;
|
||||
import com.bonus.system.domain.vo.TreeSelect;
|
||||
import com.bonus.system.mapper.*;
|
||||
import com.bonus.system.service.ISysConfigService;
|
||||
import com.bonus.system.service.ISysDeptService;
|
||||
import com.bonus.system.service.ISysUserService;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
|
@ -40,6 +43,7 @@ import javax.validation.Validator;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +113,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
String phone =user.getPhonenumber().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
|
||||
user.setPhonenumber(phone);
|
||||
}
|
||||
user.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
// user.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
List<SysUser> sysUsers = userMapper.selectUserList(user);
|
||||
return sysUsers;
|
||||
}
|
||||
|
|
@ -169,7 +173,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
*/
|
||||
@Override
|
||||
public SysUser selectUserByPhotoNumber(String photoNumber) {
|
||||
return userMapper.selectUserByPhoneNumber(Sm4Utils.encrypt(photoNumber));
|
||||
// return userMapper.selectUserByPhoneNumber(Sm4Utils.encrypt(photoNumber));
|
||||
return userMapper.selectUserByPhoneNumber(photoNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,7 +264,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
@Override
|
||||
public boolean checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(Sm4Utils.encrypt(user.getPhonenumber()));
|
||||
// SysUser info = userMapper.checkPhoneUnique(Sm4Utils.encrypt(user.getPhonenumber()));
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getUserName());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
|
|
@ -329,7 +335,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
|
|
@ -361,9 +367,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
// insertUserPost(user);
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
|
|
@ -649,4 +655,18 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getRoleList(SysRole role) {
|
||||
try {
|
||||
int type = 1;
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()){
|
||||
// 超管
|
||||
type = 2;
|
||||
}
|
||||
return AjaxResult.success(Optional.ofNullable(userMapper.getRoleList(type)).orElse(new ArrayList<>()));
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(),e);
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,15 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="isBuiltIn" column="is_built_in"/>
|
||||
<result property="roleLevel" column="role_level"/>
|
||||
<result property="roleLevelTips" column="role_level_tips"/>
|
||||
<result property="roleLevelName" column="role_level_name"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.company_id, r.status, r.del_flag, r.create_time, r.remark, r.is_built_in
|
||||
r.company_id, r.status, r.del_flag, r.create_time, r.remark, r.is_built_in,
|
||||
r.role_level,
|
||||
r.role_level_name,
|
||||
r.role_level_tips
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="com.bonus.system.api.domain.SysRole" resultMap="SysRoleResult">
|
||||
|
|
@ -41,8 +46,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="roleName != null and roleName != ''">
|
||||
AND r.role_name like concat('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
AND r.company_id = #{companyId}
|
||||
<if test="roleLevel != null and roleLevel != ''">
|
||||
AND r.role_level = #{roleLevel}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
|
|
@ -56,8 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<include refid="com.bonus.system.mapper.DataScopeMapper.dataScopeFilter"/>
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
|
|
@ -120,7 +123,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">is_built_in,</if>
|
||||
create_time
|
||||
create_time,
|
||||
<if test="roleLevel != null and roleLevel!=''">role_level,</if>
|
||||
<if test="roleLevelTips != null and roleLevelTips!=''">role_level_tips,</if>
|
||||
<if test="roleLevelName != null and roleLevelName!=''">role_level_name</if>
|
||||
)values(
|
||||
<if test="roleId != null and roleId != 0">#{roleId},</if>
|
||||
<if test="roleName != null and roleName != ''">#{roleName},</if>
|
||||
|
|
@ -134,7 +140,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">#{isBuiltIn},</if>
|
||||
sysdate()
|
||||
sysdate(),
|
||||
<if test="roleLevel != null and roleLevel!=''">#{roleLevel},</if>
|
||||
<if test="roleLevelTips != null and roleLevelTips!=''">#{roleLevelTips},</if>
|
||||
<if test="roleLevelName != null and roleLevelName!=''">#{roleLevelName}</if>
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
|
@ -152,7 +161,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">is_built_in = #{isBuiltIn},</if>
|
||||
update_time = sysdate()
|
||||
update_time = sysdate(),
|
||||
<if test="roleLevel != null and roleLevel!=''">role_level = #{roleLevel},</if>
|
||||
<if test="roleLevelTips != null and roleLevelTips!=''">role_level_tips = #{roleLevelTips},</if>
|
||||
<if test="roleLevelName != null and roleLevelName!=''">role_level_name = #{roleLevelName}</if>
|
||||
</set>
|
||||
where role_id = #{roleId}
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
<result property="approvalStatus" column="approval_status"/>
|
||||
<result property="isPermanent" column="is_permanent"/>
|
||||
<result property="isBuiltIn" column="is_built_in"/>
|
||||
<result property="roleId" column="role_id"/>
|
||||
<result property="roleLevel" column="role_level"/>
|
||||
<result property="roleName" column="role_name"/>
|
||||
<result property="bandId" column="band_id"/>
|
||||
<result property="permissionType" column="permission_type"/>
|
||||
<result property="permissionRange" column="permission_range"/>
|
||||
<association property="dept" javaType="SysDept" resultMap="deptResult"/>
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||
|
||||
|
|
@ -91,7 +97,11 @@
|
|||
r.data_scope,
|
||||
r.status as role_status,
|
||||
u.login_type,
|
||||
u.is_built_in
|
||||
u.is_built_in,
|
||||
u.role_level,
|
||||
u.band_id,
|
||||
u.permission_type,
|
||||
u.permission_range
|
||||
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
|
||||
|
|
@ -101,15 +111,19 @@
|
|||
|
||||
<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,u.approval_status,u.is_permanent,u.is_built_in, d.dept_name,
|
||||
d.leader,r.role_id,
|
||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.approval_status,u.is_permanent,u.is_built_in,
|
||||
r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.status as role_status
|
||||
r.status as role_status,
|
||||
u.role_level,
|
||||
u.band_id,
|
||||
u.permission_type,
|
||||
u.permission_range,
|
||||
IFNULL(u.create_time,u.update_time) AS update_time
|
||||
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
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0'
|
||||
|
|
@ -122,6 +136,18 @@
|
|||
<if test="status != null and status != ''">
|
||||
AND u.status = #{status}
|
||||
</if>
|
||||
<if test="nickName != null and nickName != ''">
|
||||
AND INSTR(u.nick_name,#{nickName}) > 0
|
||||
</if>
|
||||
<if test="permissionRange != null and permissionRange != ''">
|
||||
AND INSTR(u.permission_range,#{permissionRange}) > 0
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
AND u.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="permissionType != null and permissionType != ''">
|
||||
AND u.permission_type = #{permissionType}
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
|
|
@ -131,20 +157,12 @@
|
|||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="companyId != null and companyId != 0">
|
||||
AND (find_in_set(#{companyId}, ancestors) or u.dept_id = #{companyId})
|
||||
</if>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
<if test="roleIds != null and roleIds.length > 0">
|
||||
and ur.role_id in
|
||||
<foreach collection="roleIds" item="item" index="index" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="com.bonus.system.mapper.DataScopeMapper.dataScopeFilter"/>
|
||||
GROUP BY u.user_id
|
||||
</select>
|
||||
|
||||
|
|
@ -218,7 +236,7 @@
|
|||
</select>
|
||||
<select id="selectUserByPhoneNumber" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.del_flag = '0'AND u.phonenumber = #{phoneNumber} AND sd.del_flag = '0' AND sd.status = '0'
|
||||
where u.del_flag = '0'AND u.user_name = #{phoneNumber} AND sd.del_flag = '0' AND sd.status = '0'
|
||||
</select>
|
||||
<select id="selectUserByEmail" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
|
|
@ -247,7 +265,7 @@
|
|||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||
select user_id, phonenumber
|
||||
from sys_user
|
||||
where phonenumber = #{phonenumber}
|
||||
where user_name = #{phonenumber}
|
||||
and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
|
|
@ -257,6 +275,20 @@
|
|||
where email = #{email}
|
||||
and del_flag = '0' limit 1
|
||||
</select>
|
||||
<!--查询角色下拉选-->
|
||||
<select id="getRoleList" resultType="com.bonus.system.domain.vo.SelectVo">
|
||||
SELECT role_id AS value,
|
||||
role_name AS name,
|
||||
role_level_name AS level,
|
||||
role_level AS levelType
|
||||
FROM sys_role
|
||||
<where>
|
||||
<if test="type == 1">
|
||||
AND (role_id!=1 OR role_name!='超级管理员' OR role_key!='admin')
|
||||
</if>
|
||||
AND del_flag = '0'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
@ -276,7 +308,13 @@
|
|||
<if test="approvalStatus != null and approvalStatus!=''">approval_status,</if>
|
||||
<if test="isPermanent != null and isPermanent!=''">is_permanent,</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">is_built_in,</if>
|
||||
create_time
|
||||
create_time,
|
||||
<if test="roleId != null">role_id,</if>
|
||||
<if test="roleLevel != null and roleLevel!=''">role_level,</if>
|
||||
<if test="roleName != null and roleName!=''">role_name,</if>
|
||||
<if test="bandId != null">band_id,</if>
|
||||
<if test="permissionType != null and permissionType!=''">permission_type,</if>
|
||||
<if test="permissionRange != null and permissionRange!=''">permission_range</if>
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
|
|
@ -294,7 +332,13 @@
|
|||
<if test="approvalStatus != null and approvalStatus!=''">#{approvalStatus},</if>
|
||||
<if test="isPermanent != null and isPermanent!=''">#{isPermanent},</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">#{isBuiltIn},</if>
|
||||
sysdate()
|
||||
sysdate(),
|
||||
<if test="roleId != null">#{roleId},</if>
|
||||
<if test="roleLevel != null and roleLevel!=''">#{roleLevel},</if>
|
||||
<if test="roleName != null and roleName!=''">#{roleName},</if>
|
||||
<if test="bandId != null">#{bandId},</if>
|
||||
<if test="permissionType != null and permissionType!=''">#{permissionType},</if>
|
||||
<if test="permissionRange != null and permissionRange!=''">#{permissionRange}</if>
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
|
@ -317,7 +361,13 @@
|
|||
<if test="loginType != null and loginType!=''">login_type = #{loginType},</if>
|
||||
<if test="isPermanent != null and isPermanent!=''">is_permanent = #{isPermanent},</if>
|
||||
<if test="isBuiltIn != null and isBuiltIn!=''">is_built_in = #{isBuiltIn},</if>
|
||||
update_time = sysdate()
|
||||
update_time = sysdate(),
|
||||
<if test="roleId != null">role_id = #{roleId},</if>
|
||||
<if test="roleLevel != null and roleLevel!=''">role_level = #{roleLevel},</if>
|
||||
<if test="roleName != null and roleName!=''">role_name = #{roleName},</if>
|
||||
<if test="bandId != null">band_id = #{bandId},</if>
|
||||
<if test="permissionType != null and permissionType!=''">permission_type = #{permissionType},</if>
|
||||
<if test="permissionRange != null and permissionRange!=''">permission_range = #{permissionRange}</if>
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
|
|
|||
Loading…
Reference in New Issue