|
@@ -1,7 +1,6 @@
|
|
|
package cn.xyh.system.service;
|
|
package cn.xyh.system.service;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
|
-import cn.xyh.amActivity.service.IAmAlumnusService;
|
|
|
|
|
import cn.xyh.common.constant.CacheConstants;
|
|
import cn.xyh.common.constant.CacheConstants;
|
|
|
import cn.xyh.common.constant.Constants;
|
|
import cn.xyh.common.constant.Constants;
|
|
|
import cn.xyh.common.core.domain.entity.SysUser;
|
|
import cn.xyh.common.core.domain.entity.SysUser;
|
|
@@ -16,6 +15,7 @@ import cn.xyh.common.utils.ServletUtils;
|
|
|
import cn.xyh.common.utils.StringUtils;
|
|
import cn.xyh.common.utils.StringUtils;
|
|
|
import cn.xyh.common.utils.redis.RedisUtils;
|
|
import cn.xyh.common.utils.redis.RedisUtils;
|
|
|
import cn.xyh.common.utils.spring.SpringUtils;
|
|
import cn.xyh.common.utils.spring.SpringUtils;
|
|
|
|
|
+import cn.xyh.system.utils.GuidUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -28,7 +28,6 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
@Service
|
|
|
public class SysRegisterService {
|
|
public class SysRegisterService {
|
|
|
|
|
|
|
|
- private final IAmAlumnusService alumnusService;
|
|
|
|
|
private final ISysUserService userService;
|
|
private final ISysUserService userService;
|
|
|
private final ISysConfigService configService;
|
|
private final ISysConfigService configService;
|
|
|
|
|
|
|
@@ -36,13 +35,9 @@ public class SysRegisterService {
|
|
|
* 注册
|
|
* 注册
|
|
|
*/
|
|
*/
|
|
|
public void register(RegisterBody registerBody) {
|
|
public void register(RegisterBody registerBody) {
|
|
|
- String username = registerBody.getUsername();
|
|
|
|
|
- String password = registerBody.getPassword();
|
|
|
|
|
String phone = registerBody.getPhoneNumber();
|
|
String phone = registerBody.getPhoneNumber();
|
|
|
String name = registerBody.getName();
|
|
String name = registerBody.getName();
|
|
|
- String openId = registerBody.getOpenId();
|
|
|
|
|
- // 校验用户类型是否存在
|
|
|
|
|
- String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
|
|
|
|
|
|
+ String username = StringUtils.isEmpty(registerBody.getUserName()) ? GuidUtil.getUnionUserName() : registerBody.getUserName();
|
|
|
|
|
|
|
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
|
|
// 验证码开关
|
|
// 验证码开关
|
|
@@ -52,17 +47,18 @@ public class SysRegisterService {
|
|
|
SysUser sysUser = new SysUser();
|
|
SysUser sysUser = new SysUser();
|
|
|
sysUser.setUserName(username);
|
|
sysUser.setUserName(username);
|
|
|
sysUser.setNickName(name);
|
|
sysUser.setNickName(name);
|
|
|
- sysUser.setOpenId(openId);
|
|
|
|
|
|
|
+ sysUser.setOpenId(registerBody.getOpenId());
|
|
|
sysUser.setPhonenumber(phone);
|
|
sysUser.setPhonenumber(phone);
|
|
|
- sysUser.setPassword(BCrypt.hashpw(password));
|
|
|
|
|
- sysUser.setUserType(userType);
|
|
|
|
|
|
|
+ sysUser.setPassword(BCrypt.hashpw(registerBody.getPassword()));
|
|
|
|
|
+ sysUser.setUserType(UserType.AM_USER.getUserType());
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if (!userService.checkPhoneUnique(sysUser)) {
|
|
if (!userService.checkPhoneUnique(sysUser)) {
|
|
|
throw new UserException("user.register.save.error", phone);
|
|
throw new UserException("user.register.save.error", phone);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!userService.checkUserNameUnique(sysUser)) {
|
|
if (!userService.checkUserNameUnique(sysUser)) {
|
|
|
- throw new UserException("user.register.save.error", username);
|
|
|
|
|
|
|
+ throw new UserException("user.register.save.error", name);
|
|
|
}
|
|
}
|
|
|
boolean regFlag = userService.registerUser(sysUser);
|
|
boolean regFlag = userService.registerUser(sysUser);
|
|
|
if (!regFlag) {
|
|
if (!regFlag) {
|