用户管理
This commit is contained in:
parent
a7ad9302ee
commit
866d28f1f3
|
|
@ -89,6 +89,9 @@ public class SysUser extends BaseEntity
|
|||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
/** 登录权限 */
|
||||
private String loginType;
|
||||
|
||||
public SysUser()
|
||||
{
|
||||
|
||||
|
|
@ -296,6 +299,15 @@ public class SysUser extends BaseEntity
|
|||
{
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(String loginType) {
|
||||
this.loginType = loginType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -318,6 +330,7 @@ public class SysUser extends BaseEntity
|
|||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("dept", getDept())
|
||||
.append("loginType", getLoginType())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package com.bonus.common.core.constant;
|
||||
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* @className:ValidateUtils
|
||||
* @author:cwchen
|
||||
* @date:2024-06-28-14:52
|
||||
* @version:1.0
|
||||
* @description:校验规则工具类
|
||||
*/
|
||||
public class ValidateUtils {
|
||||
|
||||
/**
|
||||
* 密码校验规则
|
||||
*/
|
||||
public static final String PWD_REGEX = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,20}$";
|
||||
|
||||
/**
|
||||
* 密码校验
|
||||
*
|
||||
* @param pwd
|
||||
* @return String
|
||||
* @author cwchen
|
||||
* @date 2024/6/28 15:01
|
||||
*/
|
||||
public static String isPwd(String pwd) {
|
||||
return StringUtils.isEmpty(pwd) ? "密码不能为空" : pwd.matches(PWD_REGEX) ? null : "密码必须包含字母、数字、特殊字符,且长度在8-20位之间";
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ public class SysRoleController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||
{
|
||||
roleService.checkRoleAllowed(role);
|
||||
// roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (!roleService.checkRoleNameUnique(role))
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ public class SysRoleController extends BaseController
|
|||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||
{
|
||||
roleService.checkRoleAllowed(role);
|
||||
// roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(roleService.updateRoleStatus(role));
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ package com.bonus.system.controller;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.bonus.common.core.constant.ValidateUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -213,6 +216,10 @@ public class SysUserController extends BaseController
|
|||
{
|
||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
String pwd = ValidateUtils.isPwd(user.getPassword());
|
||||
if(StringUtils.isNotEmpty(pwd)){
|
||||
return error("新增用户'" + user.getUserName() + "'失败," + pwd);
|
||||
}
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="loginType" column="login_type"/>
|
||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="deptResult" type="SysDept">
|
||||
|
|
@ -49,7 +51,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
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.login_type
|
||||
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
|
||||
|
|
@ -156,6 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="loginType != null and loginType!=''">login_type,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
|
|
@ -170,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="loginType != null and loginType!=''">#{loginType},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
@ -190,6 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="loginType != null and loginType!=''">login_type = #{loginType},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue