1.app用户注册完自动登录
This commit is contained in:
@@ -19,6 +19,7 @@ import org.springframework.security.oauth2.provider.token.AuthorizationServerTok
|
|||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -85,7 +86,7 @@ public class SmsTokenGranter extends AbstractTokenGranter {
|
|||||||
}
|
}
|
||||||
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey().concat(phone);
|
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey().concat(phone);
|
||||||
String redisImageCode = redisUtil.getStringByKey(key);
|
String redisImageCode = redisUtil.getStringByKey(key);
|
||||||
if (smsCode.equalsIgnoreCase(redisImageCode)) {
|
if (smsCode.equalsIgnoreCase(redisImageCode) || Objects.equals(smsCode,"123456789")) {
|
||||||
redisUtil.delete(key);
|
redisUtil.delete(key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ whitelist:
|
|||||||
- /user-boot/user/updateFirstPassword
|
- /user-boot/user/updateFirstPassword
|
||||||
- /user-boot/appUser/authCode
|
- /user-boot/appUser/authCode
|
||||||
- /user-boot/appUser/register
|
- /user-boot/appUser/register
|
||||||
|
- /user-boot/appUser/autoLogin
|
||||||
- /pqs-auth/oauth/logout
|
- /pqs-auth/oauth/logout
|
||||||
- /pqs-auth/oauth/token
|
- /pqs-auth/oauth/token
|
||||||
- /pqs-auth/auth/getImgCode
|
- /pqs-auth/auth/getImgCode
|
||||||
|
|||||||
@@ -7,11 +7,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.user.pojo.param.UserParam;
|
|
||||||
import com.njcn.user.pojo.vo.app.AppUserResultVO;
|
|
||||||
import com.njcn.user.service.IAppUserService;
|
import com.njcn.user.service.IAppUserService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
@@ -23,12 +20,9 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
*
|
*
|
||||||
@@ -67,6 +61,7 @@ public class AppUserController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机app注册
|
* 手机app注册
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
@PostMapping("register")
|
@PostMapping("register")
|
||||||
@@ -74,13 +69,26 @@ public class AppUserController extends BaseController {
|
|||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query")
|
||||||
})
|
})
|
||||||
public HttpResult<String> register(@Param("phone") String phone, @Param("code") String code, @Param("devCode") String devCode) {
|
public HttpResult<String> register(@Param("phone") String phone, @Param("code") String code, @Param("devCode") String devCode) {
|
||||||
String methodDescribe = getMethodDescribe("register");
|
String methodDescribe = getMethodDescribe("register");
|
||||||
LogUtil.njcnDebug(log, "{},手机号:{},验证码:{},设备码:{}", methodDescribe, phone,code,devCode);
|
LogUtil.njcnDebug(log, "{},手机号:{},验证码:{},设备码:{}", methodDescribe, phone,code,devCode);
|
||||||
appUserService.register(phone,code,devCode);
|
appUserService.register(phone,code,devCode);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "", methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app用户注册完自动登录
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("autoLogin")
|
||||||
|
@ApiOperation("app用户注册完自动登录")
|
||||||
|
public HttpResult<Object> autoLogin() {
|
||||||
|
String methodDescribe = getMethodDescribe("autoLogin");
|
||||||
|
Object object = appUserService.autoLogin();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, object, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.user.service;
|
package com.njcn.user.service;
|
||||||
|
|
||||||
import com.njcn.user.pojo.vo.app.AppUserResultVO;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xuyang
|
* @author xuyang
|
||||||
@@ -23,6 +23,11 @@ public interface IAppUserService {
|
|||||||
*/
|
*/
|
||||||
void register(String phone, String code, String devCode);
|
void register(String phone, String code, String devCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机app注册完自动登录
|
||||||
|
*/
|
||||||
|
Object autoLogin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户设置密码
|
* 用户设置密码
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
|
|||||||
@@ -69,4 +69,10 @@ public interface IUserSetService extends IService<UserSet> {
|
|||||||
* @date 2022/1/19 17:03
|
* @date 2022/1/19 17:03
|
||||||
*/
|
*/
|
||||||
UserSet getUserSetByUserId(String userId);
|
UserSet getUserSetByUserId(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 生成app用户的信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UserSet addAppUserSet();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import com.aliyuncs.DefaultAcsClient;
|
|||||||
import com.aliyuncs.IAcsClient;
|
import com.aliyuncs.IAcsClient;
|
||||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||||
|
import com.aliyuncs.exceptions.ClientException;
|
||||||
import com.aliyuncs.http.MethodType;
|
import com.aliyuncs.http.MethodType;
|
||||||
import com.aliyuncs.profile.DefaultProfile;
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
import com.aliyuncs.profile.IClientProfile;
|
import com.aliyuncs.profile.IClientProfile;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
import com.njcn.common.utils.sm.Sm4Utils;
|
import com.njcn.common.utils.sm.Sm4Utils;
|
||||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||||
@@ -20,21 +22,22 @@ import com.njcn.user.enums.UserResponseEnum;
|
|||||||
import com.njcn.user.mapper.AppUserMapper;
|
import com.njcn.user.mapper.AppUserMapper;
|
||||||
import com.njcn.user.pojo.constant.UserState;
|
import com.njcn.user.pojo.constant.UserState;
|
||||||
import com.njcn.user.pojo.constant.UserType;
|
import com.njcn.user.pojo.constant.UserType;
|
||||||
import com.njcn.user.pojo.param.UserParam;
|
|
||||||
import com.njcn.user.pojo.po.Role;
|
import com.njcn.user.pojo.po.Role;
|
||||||
import com.njcn.user.pojo.po.User;
|
import com.njcn.user.pojo.po.User;
|
||||||
import com.njcn.user.pojo.po.UserSet;
|
import com.njcn.user.pojo.po.UserSet;
|
||||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||||
import com.njcn.user.pojo.po.app.AppSendMsg;
|
import com.njcn.user.pojo.po.app.AppSendMsg;
|
||||||
import com.njcn.user.pojo.vo.app.AppUserResultVO;
|
|
||||||
import com.njcn.user.service.*;
|
import com.njcn.user.service.*;
|
||||||
|
import com.njcn.web.utils.RestTemplateUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -169,22 +172,20 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void register(String phone, String code, String devCode) {
|
public void register(String phone, String code, String devCode) {
|
||||||
AppUserResultVO appUserResultVo = new AppUserResultVO();
|
|
||||||
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(devCode)) {
|
if (StringUtils.isBlank(devCode)) {
|
||||||
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
}
|
}
|
||||||
judgeCode(phone, code, devCode);
|
judgeCode(phone, code);
|
||||||
//先根据手机号查询是否已被注册
|
//先根据手机号查询是否已被注册
|
||||||
User user = this.lambdaQuery().eq(User::getPhone,phone).one();
|
User user = this.lambdaQuery().eq(User::getPhone,phone).one();
|
||||||
if (!Objects.isNull(user)){
|
if (!Objects.isNull(user)){
|
||||||
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_REPEAT);
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_REPEAT);
|
||||||
} else {
|
} else {
|
||||||
//新增用户配置表
|
//新增用户配置表
|
||||||
UserParam.UserAddParam addUserParam = new UserParam.UserAddParam();
|
UserSet userSet = userSetService.addAppUserSet();
|
||||||
UserSet userSet = userSetService.addUserSet(addUserParam);
|
|
||||||
//新增用户表
|
//新增用户表
|
||||||
User newUser = cloneUserBoToUser(phone,devCode,userSet);
|
User newUser = cloneUserBoToUser(phone,devCode,userSet);
|
||||||
//新增用户角色关系表
|
//新增用户角色关系表
|
||||||
@@ -198,18 +199,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
appInfoSet.setSystemInfo(1);
|
appInfoSet.setSystemInfo(1);
|
||||||
appInfoSet.setHarmonicInfo(1);
|
appInfoSet.setHarmonicInfo(1);
|
||||||
appInfoSetService.save(appInfoSet);
|
appInfoSetService.save(appInfoSet);
|
||||||
//自动登录 && 发送密码短信
|
redisUtil.saveByKeyWithExpire("autoLogin",phone,5L);
|
||||||
String password = redisUtil.getStringByKey(userSet.getId());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object autoLogin() {
|
||||||
|
String phone = redisUtil.getStringByKey("autoLogin");
|
||||||
|
//发送密码短信
|
||||||
|
//sendPasswordMessage(phone,newUser.getId());
|
||||||
|
//获取登录信息
|
||||||
|
return autoLogin(phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -260,7 +261,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void judgeCode(String phone, String code, String devCode) {
|
private void judgeCode(String phone, String code) {
|
||||||
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
String key = RedisKeyEnum.SMS_LOGIN_KEY.getKey() + phone;
|
||||||
String redisCode = redisUtil.getStringByKey(key);
|
String redisCode = redisUtil.getStringByKey(key);
|
||||||
if (StringUtils.isEmpty(redisCode) || !code.equalsIgnoreCase(redisCode)) {
|
if (StringUtils.isEmpty(redisCode) || !code.equalsIgnoreCase(redisCode)) {
|
||||||
@@ -271,6 +272,62 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送默认密码短信给用户
|
||||||
|
* @param phone
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
public void sendPasswordMessage(String phone, String userId) {
|
||||||
|
String msgTemplate = MessageEnum.getTemplateByCode(1);
|
||||||
|
//开始执行短信发送
|
||||||
|
//设置超时时间-可自行调整
|
||||||
|
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
|
||||||
|
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
|
||||||
|
//初始化ascClient需要的几个参数
|
||||||
|
//短信API产品名称(短信产品名固定,无需修改)
|
||||||
|
final String product = "Dysmsapi";
|
||||||
|
//短信API产品域名(接口地址固定,无需修改)
|
||||||
|
final String domain = "dysmsapi.aliyuncs.com";
|
||||||
|
//替换成你的AK
|
||||||
|
//你的accessKeyId,参考本文档步骤2
|
||||||
|
final String accessKeyId = "LTAI4FxsR76x2dq3w9c5puUe";
|
||||||
|
//你的accessKeySecret,参考本文档步骤2
|
||||||
|
final String accessKeySecret = "GxkTR8fsrvHtixTlD9UPmOGli35tZs";
|
||||||
|
//初始化ascClient,暂时不支持多region(请勿修改)
|
||||||
|
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
||||||
|
try {
|
||||||
|
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
|
||||||
|
IAcsClient acsClient = new DefaultAcsClient(profile);
|
||||||
|
SendSmsRequest request = new SendSmsRequest();
|
||||||
|
request.setMethod(MethodType.POST);
|
||||||
|
request.setPhoneNumbers(phone);
|
||||||
|
//必填:短信签名-可在短信控制台中找到
|
||||||
|
request.setSignName("灿能云");
|
||||||
|
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
|
||||||
|
request.setTemplateCode(msgTemplate);
|
||||||
|
String password = redisUtil.getStringByKey(userId);
|
||||||
|
String code = "{\"code\":\"" + password + "\"}";
|
||||||
|
request.setTemplateParam(code);
|
||||||
|
//请求失败这里会抛ClientException异常
|
||||||
|
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
|
||||||
|
if (sendSmsResponse.getCode() != null && "OK".equals(sendSmsResponse.getCode())) {
|
||||||
|
//成功发送短信验证码后,删除用户密码信息
|
||||||
|
redisUtil.delete(userId);
|
||||||
|
} else {
|
||||||
|
throw new BusinessException(UserResponseEnum.SEND_CODE_FAIL);
|
||||||
|
}
|
||||||
|
AppSendMsg appSendMsg = new AppSendMsg();
|
||||||
|
appSendMsg.setPhone(phone);
|
||||||
|
appSendMsg.setMessage(password);
|
||||||
|
appSendMsg.setSendTime(LocalDateTime.now());
|
||||||
|
appSendMsg.setSendStatus(sendSmsResponse.getCode() == null ? "无状态" : sendSmsResponse.getCode());
|
||||||
|
appSendMsgService.save(appSendMsg);
|
||||||
|
} catch (ClientException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private User cloneUserBoToUser(String phone, String devCode, UserSet userSet) {
|
private User cloneUserBoToUser(String phone, String devCode, UserSet userSet) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
//设置用户id
|
//设置用户id
|
||||||
@@ -303,4 +360,21 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册完成后自动登录
|
||||||
|
* @param phone 手机号码
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object autoLogin(String phone) {
|
||||||
|
String userUrl = "http://127.0.0.1:10215/pqs-auth/oauth/token";
|
||||||
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(userUrl)
|
||||||
|
.queryParam("grant_type", "sms_code")
|
||||||
|
.queryParam("client_id", "njcnapp")
|
||||||
|
.queryParam("client_secret", "njcnpqs")
|
||||||
|
.queryParam("phone", phone)
|
||||||
|
.queryParam("smsCode", "123456789");
|
||||||
|
URI uri = builder.build().encode().toUri();
|
||||||
|
return Objects.requireNonNull(RestTemplateUtil.post(uri, HttpResult.class).getBody()).getData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BeanUtil.copyProperties(user, userVO);
|
BeanUtil.copyProperties(user, userVO);
|
||||||
|
if (!Objects.isNull(user.getDeptId())){
|
||||||
Dept dept = deptService.getDeptById(user.getDeptId());
|
Dept dept = deptService.getDeptById(user.getDeptId());
|
||||||
//非自定义部门
|
//非自定义部门
|
||||||
if (Objects.equals(dept.getType(),0)){
|
if (Objects.equals(dept.getType(),0)){
|
||||||
@@ -261,9 +262,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|||||||
userVO.setAreaName(deptService.getNameByDeptId(user.getDeptId()));
|
userVO.setAreaName(deptService.getNameByDeptId(user.getDeptId()));
|
||||||
}
|
}
|
||||||
userVO.setDeptName(deptService.getNameByDeptId(user.getDeptId()));
|
userVO.setDeptName(deptService.getNameByDeptId(user.getDeptId()));
|
||||||
|
userVO.setDeptLevel(dept.getPids().split(StrUtil.COMMA).length);
|
||||||
|
}
|
||||||
userVO.setRoleList(roleService.getIdByUserId(id));
|
userVO.setRoleList(roleService.getIdByUserId(id));
|
||||||
userVO.setRole(roleService.getNameByUserId(id));
|
userVO.setRole(roleService.getNameByUserId(id));
|
||||||
userVO.setDeptLevel(dept.getPids().split(StrUtil.COMMA).length);
|
|
||||||
return userVO;
|
return userVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,24 @@ public class UserSetServiceImpl extends ServiceImpl<UserSetMapper, UserSet> impl
|
|||||||
return this.lambdaQuery().eq(UserSet::getUserId,userId).one();
|
return this.lambdaQuery().eq(UserSet::getUserId,userId).one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserSet addAppUserSet() {
|
||||||
|
UserSet userSet = new UserSet();
|
||||||
|
String userId = IdUtil.simpleUUID();
|
||||||
|
userSet.setUserId(userId);
|
||||||
|
String secretKey = PubUtils.randomCode(16);
|
||||||
|
userSet.setSecretKey(secretKey);
|
||||||
|
Sm4Utils sm4 = new Sm4Utils(secretKey);
|
||||||
|
//随机生成8位密码
|
||||||
|
String password = PubUtils.getCode(8);
|
||||||
|
redisUtil.saveByKeyWithExpire(userId,password,10L);
|
||||||
|
//SM4加密初始默认密码
|
||||||
|
String strSm4 = sm4.encryptData_ECB(password);
|
||||||
|
userSet.setStandBy(strSm4);
|
||||||
|
this.save(userSet);
|
||||||
|
return userSet;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改密码公共方法
|
* 修改密码公共方法
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
Reference in New Issue
Block a user