This commit is contained in:
磷叶 2024-11-22 14:24:59 +08:00
parent 87c55fe426
commit b54e9b6566
10 changed files with 113 additions and 76 deletions

View File

@ -7,10 +7,13 @@ import javax.validation.constraints.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.validate.ValidGroup;
import com.ruoyi.common.utils.RegexpUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -33,7 +36,7 @@ public class SysUser extends BaseEntity
private static final long serialVersionUID = 1L;
/** 用户ID */
@Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
@Excel(name = "ID", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
private Long userId;
@Excel(name = "工号")
@ -42,35 +45,37 @@ public class SysUser extends BaseEntity
private String userNo;
/** 部门ID */
@Excel(name = "部门编号", type = Type.IMPORT)
@Excel(name = "部门ID", type = Type.IMPORT)
private Long deptId;
/** 用户账号 */
@Excel(name = "登录名称")
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
/** 登录账号 */
@Excel(name = "登录账号")
@NotBlank(message = "登录账号不允许为空", groups = {ValidGroup.Create.class})
@Xss(message = "登录账号不能包含脚本字符")
@Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符")
private String userName;
/** 用户昵称 */
@Excel(name = "用户名称")
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
/** 姓名 */
@Excel(name = "姓名")
@Xss(message = "姓名不能包含脚本字符")
@Size(min = 0, max = 30, message = "姓名长度不能超过30个字符")
private String nickName;
/** 用户邮箱 */
@Excel(name = "用户邮箱")
@Excel(name = "邮箱")
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
private String email;
/** 手机号码 */
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
@Excel(name = "手机号", cellType = ColumnType.TEXT)
@NotBlank(message = "手机号不允许为空", groups = {ValidGroup.Create.class})
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
@Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "手机号格式不正确")
private String phonenumber;
/** 用户性别 */
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知", combo = {"", "", "未知"})
private String sex;
/** 用户头像 */
@ -80,7 +85,7 @@ public class SysUser extends BaseEntity
private String password;
/** 帐号状态0正常 1停用 */
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用", combo = {"正常", "停用"})
private String status;
/** 删除标志0代表存在 2代表删除 */
@ -114,16 +119,16 @@ public class SysUser extends BaseEntity
private Long roleId;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd", cellType = ColumnType.TEXT)
@ApiModelProperty("生日")
private LocalDate birthday;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入职时间", width = 30, dateFormat = "yyyy-MM-dd")
@Excel(name = "入职时间", width = 30, dateFormat = "yyyy-MM-dd", cellType = ColumnType.TEXT)
@ApiModelProperty("入职时间")
private LocalDate employDate;
@Excel(name = "在职情况", readConverterExp = "1=在职,2=离职")
@Excel(name = "在职情况", readConverterExp = "1=在职,2=离职", combo = {"在职", "离职"})
@ApiModelProperty("在职情况")
private String employStatus;
@ -135,7 +140,7 @@ public class SysUser extends BaseEntity
public static SysUser system() {
SysUser user = new SysUser();
user.setUserId(0L);
user.setNickName("系统");
user.setUserName("系统");
return user;
}

View File

@ -132,10 +132,6 @@ public class LoginUser implements UserDetails
return user.getUserName();
}
public String getNickName() {
return user.getNickName();
}
/**
* 账户是否未过期,过期无法验证
*/

View File

@ -62,16 +62,6 @@ public class SecurityUtils
}
}
/**
* 获取用户名称
**/
public static String getNickName() {
try {
return getLoginUser().getNickName();
} catch (Exception e) {
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
}
}
/**
* 获取用户

View File

@ -31,7 +31,7 @@ import com.ruoyi.system.service.ISysUserService;
/**
* 登录校验方法
*
*
* @author ruoyi
*/
@Component
@ -45,7 +45,7 @@ public class SysLoginService
@Autowired
private RedisCache redisCache;
@Autowired
private ISysUserService userService;
@ -54,7 +54,7 @@ public class SysLoginService
/**
* 登录验证
*
*
* @param username 用户名
* @param password 密码
* @param code 验证码
@ -102,7 +102,7 @@ public class SysLoginService
/**
* 校验验证码
*
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识

View File

@ -20,7 +20,7 @@ import com.ruoyi.system.service.ISysUserService;
/**
* 注册校验方法
*
*
* @author ruoyi
*/
@Component
@ -69,13 +69,8 @@ public class SysRegisterService
{
msg = "密码长度必须在5到20个字符之间";
}
else if (!userService.checkUserNameUnique(sysUser))
{
msg = "保存用户'" + username + "'失败,注册账号已存在";
}
else
{
sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(password));
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag)
@ -92,7 +87,7 @@ public class SysRegisterService
/**
* 校验验证码
*
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识

View File

@ -25,4 +25,21 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -23,4 +23,13 @@ public class SysUserQuery extends SysUser {
@ApiModelProperty("用户昵称列表")
private List<String> nickNames;
@ApiModelProperty("精准手机号")
private String eqPhonenumber;
@ApiModelProperty("精准工号")
private String eqUserNo;
@ApiModelProperty("排除用户ID")
private Long excludeUserId;
}

View File

@ -127,4 +127,10 @@ public interface SysUserMapper
* @return 结果
*/
public SysUser checkEmailUnique(String email);
/**
* 查询用户数量
*/
int selectCount(SysUserQuery query);
}

View File

@ -70,46 +70,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_role r on r.role_id = ur.role_id
</sql>
<select id="selectUserList" parameterType="SysUserQuery" 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.user_no,
u.birthday,
u.employ_date,
u.employ_status,
d.dept_name,
d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<sql id="searchCondition">
and u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="nickName != null and nickName != ''">
AND u.nick_name like concat('%', #{nickName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="eqPhonenumber != null and eqPhonenumber != ''">
AND u.phonenumber = #{eqPhonenumber}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
@ -119,6 +96,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="excludeUserId != null">
and u.user_id != #{excludeUserId}
</if>
<if test="eqUserNo != null and eqUserNo != ''">
and u.user_no = #{eqUserNo}
</if>
<if test="userIds != null and userIds.size() > 0">
AND u.user_id IN
<foreach collection="userIds" item="item" open="(" separator="," close=")">
@ -137,13 +120,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
</sql>
<select id="selectUserList" parameterType="SysUserQuery" resultMap="SysUserResult">
select
u.user_id,
u.dept_id,
u.user_name,
u.nick_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.user_no,
u.birthday,
u.employ_date,
u.employ_status,
d.dept_name,
d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
<where>
<include refid="searchCondition"/>
</where>
<!-- 数据范围过滤 -->
${@com.ruoyi.framework.util.DataScopeUtil@dataScope("d", "u", needScope)}
${params.dataScope}
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.user_name, u.email, u.phonenumber, u.status, u.create_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
@ -160,7 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.user_name, u.email, u.phonenumber, u.status, u.create_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
@ -199,7 +211,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
<select id="selectCount" resultType="java.lang.Integer">
select count(u.user_id)
from sys_user u
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>

View File

@ -61,7 +61,6 @@ public class SysProfileController extends BaseController
{
LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());