2
0
This commit is contained in:
2024-11-27 18:40:17 +08:00
18 changed files with 212 additions and 36 deletions

View File

@@ -47,9 +47,9 @@ public class SysEmailController extends BaseController {
}
String key = GlobalConstants.CAPTCHA_CODE_KEY + email;
String code = RandomUtil.randomNumbers(4);
redisService.setCacheObject(key, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
redisService.setCacheObject(key, code, Constants.MAIL_CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
try {
MailUtils.sendText(email, "登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
MailUtils.sendText(email, "Registration verification code", "Your verification code is: " + code + ", The validity period is " + Constants.MAIL_CAPTCHA_EXPIRATION + " minutes, please fill in as soon as possible.");
} catch (Exception e) {
log.error("验证码短信发送异常 => {}", e.getMessage());
return R.fail(e.getMessage());

View File

@@ -1,6 +1,7 @@
package org.wfc.system.controller;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.validation.annotation.Validated;
@@ -30,6 +31,7 @@ import org.wfc.system.api.domain.SysDept;
import org.wfc.system.api.domain.SysRole;
import org.wfc.system.api.domain.SysUser;
import org.wfc.common.core.domain.LoginUser;
import org.wfc.system.domain.query.UserRepeatQuery;
import org.wfc.system.service.ISysConfigService;
import org.wfc.system.service.ISysDeptService;
import org.wfc.system.service.ISysPermissionService;
@@ -79,12 +81,24 @@ public class SysUserController extends BaseController
private MessageSource messageSource;
/**
* 获取用户列表
* 测试国际化
*/
@GetMapping("/test")
public String test()
{
return MessageUtils.message("user.jcaptcha.error");
return MessageUtils.message("user.register.save.error", "test");
}
/**
* 检查重复
*/
@PostMapping("/checkRepeat")
public R<Boolean> checkRepeat(@RequestBody UserRepeatQuery query)
{
SysUser sysUser = new SysUser();
BeanUtils.copyProperties(query, sysUser);
return R.ok(!userService.checkUserNameUnique(sysUser) || !userService.checkPhoneUnique(sysUser)
|| !userService.checkEmailUnique(sysUser));
}
/**
@@ -165,8 +179,19 @@ public class SysUserController extends BaseController
}
if (!userService.checkUserNameUnique(sysUser))
{
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
return R.fail("user.register.save.error");
}
if (!userService.checkPhoneUnique(sysUser))
{
return R.fail("user.register.phone.save.error");
}
if (!userService.checkEmailUnique(sysUser))
{
return R.fail("user.register.email.save.error");
}
return R.ok(userService.registerUser(sysUser));
}

View File

@@ -0,0 +1,15 @@
package org.wfc.system.domain.query;
import lombok.Data;
/**
* @description: 用户重复query
* @author: caiyuchao
* @date: 2024-11-27
*/
@Data
public class UserRepeatQuery {
private String userName;
private String email;
private String phonenumber;
}

View File

@@ -1,9 +1,10 @@
package org.wfc.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.wfc.system.api.domain.SysUser;
import java.util.List;
/**
* 用户表 数据层
*

View File

@@ -23,6 +23,9 @@ 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="fullName" column="full_name" />
<result property="age" column="age" />
<result property="address" column="address" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@@ -156,6 +159,9 @@ 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="fullName != null and fullName != ''">full_name,</if>
<if test="age != null and age != ''">age,</if>
<if test="address != null and address != ''">address,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
@@ -170,6 +176,9 @@ 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="fullName != null and fullName != ''">#{fullName},</if>
<if test="age != null and age != ''">#{age},</if>
<if test="address != null and address != ''">#{address},</if>
sysdate()
)
</insert>