feat: add register
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user