App用户功能
This commit is contained in:
@@ -24,7 +24,15 @@ public enum RedisKeyEnum {
|
|||||||
/**
|
/**
|
||||||
* 终端信息查询缓存的公共key前缀
|
* 终端信息查询缓存的公共key前缀
|
||||||
*/
|
*/
|
||||||
DEVICE_INFO_KEY("DEVICE_INFO_PUBLIC:",-1L);
|
DEVICE_INFO_KEY("DEVICE_INFO_PUBLIC:",-1L),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP角色推荐码
|
||||||
|
*/
|
||||||
|
ROLE_REFERRAL_CODE_KEY("ROLE_REFERRAL_CODE",2L),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,17 @@ public enum MessageEnum {
|
|||||||
* 阿里云短信模板编号
|
* 阿里云短信模板编号
|
||||||
*/
|
*/
|
||||||
LOGIN(0, "SMS_176180086"),
|
LOGIN(0, "SMS_176180086"),
|
||||||
REGISTER(1, "SMS_176200101"),
|
REGISTER(1, "SMS_175995085"),
|
||||||
RESET_PWD(2, "SMS_176195072"),
|
UPDATE_PASSWORD(2,"SMS_175995084"),
|
||||||
FORGET_PWD(3, "SMS_176195072"),
|
DEFAULT_PASSWORD(3,"SMS_212270827"),
|
||||||
UPDATE_PHONE(4, "SMS_175583840"),
|
UPDATE_PHONE(4, "SMS_175583840"),
|
||||||
JUDGE_OLD_PHONE(5, "SMS_176195072"),
|
|
||||||
EVENT_MESSAGE_NOTICE(6,"SMS_212270827"),
|
RESET_PWD(5, "SMS_176195072"),
|
||||||
DEFAULT_PASSWORD(7,"SMS_212270827"),
|
FORGET_PWD(6, "SMS_176195072"),
|
||||||
|
JUDGE_OLD_PHONE(7, "SMS_176195072"),
|
||||||
|
EVENT_MESSAGE_NOTICE(8,"SMS_212270827"),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class RoleController extends BaseController {
|
|||||||
@ApiOperation("根据权限类型查询相关角色")
|
@ApiOperation("根据权限类型查询相关角色")
|
||||||
@ApiImplicitParam(name = "id", value = "权限类型索引", required = true)
|
@ApiImplicitParam(name = "id", value = "权限类型索引", required = true)
|
||||||
public HttpResult<Object> selectRoleDetail(@RequestParam("id") Integer id) {
|
public HttpResult<Object> selectRoleDetail(@RequestParam("id") Integer id) {
|
||||||
String methodDescribe = getMethodDescribe("list");
|
String methodDescribe = getMethodDescribe("selectRoleDetail");
|
||||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
|
||||||
List<Role> result = roleService.selectRoleDetail(id);
|
List<Role> result = roleService.selectRoleDetail(id);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ 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 = "devCode", value = "设备码", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "type", value = "验证码类型(0:登录 1:注册 2:重置密码 3:忘记密码 4:更换手机 5:确认旧手机验证码)", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "type", value = "验证码类型(0:登录 1:注册 2:修改密码 3:注册初始密码 4:换绑手机)", required = true, paramType = "query"),
|
||||||
})
|
})
|
||||||
public HttpResult<String> authCode(String phone, String devCode, String type) {
|
public HttpResult<String> authCode(String phone, String devCode, String type) {
|
||||||
String methodDescribe = getMethodDescribe("authCode");
|
String methodDescribe = getMethodDescribe("authCode");
|
||||||
@@ -61,7 +61,6 @@ 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")
|
||||||
@@ -75,12 +74,11 @@ public class AppUserController extends BaseController {
|
|||||||
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, "success", methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* app用户注册完自动登录
|
* app用户注册完自动登录
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
@PostMapping("autoLogin")
|
@PostMapping("autoLogin")
|
||||||
@@ -95,26 +93,75 @@ public class AppUserController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, object, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, object, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机app密码设置
|
* 手机app已登录修改密码
|
||||||
*/
|
*/
|
||||||
@PostMapping("setPsd")
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
@OperateInfo
|
@PostMapping("modifyPsd")
|
||||||
@ApiOperation(value = "设置密码", notes = "设置密码")
|
@ApiOperation("修改密码")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "userId", value = "用户索引", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
||||||
})
|
})
|
||||||
public HttpResult<String> setPsd(String userId, String password, String devCode) {
|
public HttpResult<Object> modifyPsd(String userId,String phone, String code,String password, String devCode) {
|
||||||
String methodDescribe = getMethodDescribe("setPsd");
|
String methodDescribe = getMethodDescribe("modifyPsd");
|
||||||
appUserService.setPsd(userId, devCode, password);
|
appUserService.modifyPsd(userId,phone,code,password,devCode);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机app忘记密码-重置密码
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("resetPsd")
|
||||||
|
@ApiOperation("重置密码")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
||||||
|
})
|
||||||
|
public HttpResult<Object> resetPsd(String phone, String code,String password, String devCode) {
|
||||||
|
String methodDescribe = getMethodDescribe("modifyPsd");
|
||||||
|
appUserService.resetPsd(phone,code,password,devCode);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机app确认旧手机验证码
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("confirmCode")
|
||||||
|
@ApiOperation("确认旧手机验证码")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
|
||||||
|
})
|
||||||
|
public HttpResult<Object> confirmCode(String phone,String code,String devCode) {
|
||||||
|
String methodDescribe = getMethodDescribe("confirmCode");
|
||||||
|
appUserService.confirmCode(phone,code,devCode);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app用户手机换绑
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("rebindPhone")
|
||||||
|
@ApiOperation("换绑新手机号")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "phoneNew", value = "新号码", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "code", value = "短信验证码", required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query")
|
||||||
|
})
|
||||||
|
public HttpResult<Object> rebindPhone(String userId,String phoneNew,String code,String devCode) {
|
||||||
|
String methodDescribe = getMethodDescribe("rebindPhone");
|
||||||
|
appUserService.rebindPhone(userId,phoneNew,code,devCode);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.njcn.user.service;
|
package com.njcn.user.service;
|
||||||
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xuyang
|
* @author xuyang
|
||||||
*/
|
*/
|
||||||
@@ -29,11 +27,23 @@ public interface IAppUserService {
|
|||||||
Object autoLogin(String phone, String devCode);
|
Object autoLogin(String phone, String devCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户设置密码
|
* 手机app已登录修改密码
|
||||||
* @param userId 用户id
|
|
||||||
* @param devCode 设备码
|
|
||||||
* @param password 密码
|
|
||||||
*/
|
*/
|
||||||
void setPsd(String userId, String devCode, String password);
|
void modifyPsd(String userId, String phone, String code, String password, String devCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app用户忘记密码
|
||||||
|
*/
|
||||||
|
void resetPsd(String phone, String code, String password, String devCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 旧手机验证码确认
|
||||||
|
*/
|
||||||
|
void confirmCode(String phone, String code, String devCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 换绑手机号
|
||||||
|
*/
|
||||||
|
void rebindPhone(String userId, String phoneNew, String code, String devCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,22 @@
|
|||||||
package com.njcn.user.service.impl;
|
package com.njcn.user.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
|
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.user.enums.UserResponseEnum;
|
import com.njcn.user.enums.UserResponseEnum;
|
||||||
import com.njcn.user.pojo.po.UserRole;
|
import com.njcn.user.pojo.po.UserRole;
|
||||||
import com.njcn.user.pojo.vo.app.RoleReferralCodeVO;
|
|
||||||
import com.njcn.user.service.IAppRoleService;
|
import com.njcn.user.service.IAppRoleService;
|
||||||
import com.njcn.user.service.IReferralCodeService;
|
|
||||||
import com.njcn.user.service.IRoleService;
|
import com.njcn.user.service.IRoleService;
|
||||||
import com.njcn.user.service.IUserRoleService;
|
import com.njcn.user.service.IUserRoleService;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -37,8 +36,9 @@ public class AppRoleServiceImpl implements IAppRoleService {
|
|||||||
private final IUserRoleService userRoleService;
|
private final IUserRoleService userRoleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void roleUpdate(String userId, String referralCode, String devCode) {
|
public void roleUpdate(String userId, String referralCode, String devCode) {
|
||||||
Object object = redisUtil.getObjectByKey("roleReferralCode");
|
Object object = redisUtil.getObjectByKey(RedisKeyEnum.ROLE_REFERRAL_CODE_KEY.getKey());
|
||||||
if (Objects.isNull(object)){
|
if (Objects.isNull(object)){
|
||||||
throw new BusinessException(UserResponseEnum.REFERRAL_CODE_LAPSE);
|
throw new BusinessException(UserResponseEnum.REFERRAL_CODE_LAPSE);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public class AppRoleServiceImpl implements IAppRoleService {
|
|||||||
roleMap.put(entry.getKey(),entry.getValue());
|
roleMap.put(entry.getKey(),entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redisUtil.saveByKeyWithExpire("roleReferralCode",roleMap,120L);
|
redisUtil.saveByKey(RedisKeyEnum.ROLE_REFERRAL_CODE_KEY.getKey(),roleMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,38 +214,79 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> impleme
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPsd(String userId, String devCode, String password) {
|
public void modifyPsd(String userId, String phone, String code, String password, String devCode) {
|
||||||
//参数校验
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
if (StringUtils.isBlank(userId)) {
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_INDEX_INVALID);
|
|
||||||
}
|
|
||||||
if (StringUtils.isBlank(userId)) {
|
|
||||||
throw new BusinessException(UserResponseEnum.PASSWORD_INVALID);
|
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(devCode)) {
|
if (StringUtils.isBlank(devCode)) {
|
||||||
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
}
|
}
|
||||||
try {
|
judgeCode(phone, code);
|
||||||
//查看是否存在该用户
|
//判断用户是否存在
|
||||||
User user = this.lambdaQuery().eq(User::getId,userId).one();
|
User user = this.lambdaQuery().eq(User::getId,userId).one();
|
||||||
if (Objects.isNull(user)){
|
if (Objects.isNull(user)){
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USERNAME_NOT_FOUND);
|
throw new BusinessException(UserResponseEnum.LOGIN_USERNAME_NOT_FOUND);
|
||||||
} else {
|
}
|
||||||
user.setPassword(password);
|
String secretPassword = userSetService.updatePassword(userId, password);
|
||||||
|
user.setPassword(secretPassword);
|
||||||
|
user.setPwdValidity(LocalDateTime.now());
|
||||||
|
user.setLoginTime(LocalDateTime.now());
|
||||||
user.setDevCode(devCode);
|
user.setDevCode(devCode);
|
||||||
logger.info("更新手机id:" + devCode);
|
|
||||||
this.updateById(user);
|
this.updateById(user);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("app用户设置密码异常:" + e.toString());
|
@Override
|
||||||
if (e.getMessage().length() < 10) {
|
public void resetPsd(String phone, String code, String password, String devCode) {
|
||||||
throw new BusinessException(UserResponseEnum.getCodeByMsg(e.getMessage()));
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
} else {
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
throw new BusinessException(UserResponseEnum.PASSWORD_SET_ERROR);
|
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isBlank(devCode)) {
|
||||||
|
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
}
|
}
|
||||||
|
judgeCode(phone, code);
|
||||||
|
//判断用户是否存在
|
||||||
|
User user = this.lambdaQuery().eq(User::getPhone,phone).one();
|
||||||
|
if (Objects.isNull(user)){
|
||||||
|
throw new BusinessException(UserResponseEnum.LOGIN_USERNAME_NOT_FOUND);
|
||||||
|
}
|
||||||
|
String secretPassword = userSetService.updatePassword(user.getId(), password);
|
||||||
|
user.setPassword(secretPassword);
|
||||||
|
user.setPwdValidity(LocalDateTime.now());
|
||||||
|
user.setLoginTime(LocalDateTime.now());
|
||||||
|
user.setDevCode(devCode);
|
||||||
|
this.updateById(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmCode(String phone, String code, String devCode) {
|
||||||
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phone)){
|
||||||
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(devCode)) {
|
||||||
|
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
|
}
|
||||||
|
judgeCode(phone, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rebindPhone(String userId, String phoneNew, String code, String devCode) {
|
||||||
|
if (!PubUtils.match(PatternRegex.PHONE_REGEX, phoneNew)){
|
||||||
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_WRONG);
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(devCode)) {
|
||||||
|
throw new BusinessException(UserResponseEnum.DEV_CODE_WRONG);
|
||||||
|
}
|
||||||
|
judgeCode(phoneNew, code);
|
||||||
|
User user = this.lambdaQuery().eq(User::getPhone,phoneNew).one();
|
||||||
|
if (!Objects.isNull(user)){
|
||||||
|
throw new BusinessException(UserResponseEnum.REGISTER_PHONE_REPEAT);
|
||||||
|
}
|
||||||
|
user.setName(phoneNew);
|
||||||
|
user.setLoginName(phoneNew);
|
||||||
|
user.setPhone(phoneNew);
|
||||||
|
user.setDevCode(devCode);
|
||||||
|
this.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.njcn.user.service.impl;
|
package com.njcn.user.service.impl;
|
||||||
|
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
|
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.user.enums.AppRoleEnum;
|
||||||
import com.njcn.user.pojo.vo.app.RoleReferralCodeVO;
|
import com.njcn.user.pojo.vo.app.RoleReferralCodeVO;
|
||||||
import com.njcn.user.service.IReferralCodeService;
|
import com.njcn.user.service.IReferralCodeService;
|
||||||
import com.njcn.user.service.IRoleService;
|
import com.njcn.user.service.IRoleService;
|
||||||
@@ -30,28 +32,11 @@ public class ReferralCodeServiceImpl implements IReferralCodeService {
|
|||||||
@Override
|
@Override
|
||||||
public List<RoleReferralCodeVO> findReferralCode() {
|
public List<RoleReferralCodeVO> findReferralCode() {
|
||||||
List<RoleReferralCodeVO> list = new ArrayList<>();
|
List<RoleReferralCodeVO> list = new ArrayList<>();
|
||||||
Object object = redisUtil.getObjectByKey("roleReferralCode");
|
Object object = redisUtil.getObjectByKey(RedisKeyEnum.ROLE_REFERRAL_CODE_KEY.getKey());
|
||||||
if (Objects.isNull(object)){
|
if (Objects.isNull(object)){
|
||||||
LinkedHashMap<String,String> roleMap = new LinkedHashMap<>();
|
list = refreshReferralCode();
|
||||||
String code1 = PubUtils.getCode(6);
|
|
||||||
String code2 = PubUtils.getCode(6);
|
|
||||||
String code3 = PubUtils.getCode(6);
|
|
||||||
roleMap.put(code1,"market_user");
|
|
||||||
roleMap.put(code2,"engineering_user");
|
|
||||||
roleMap.put(code3,"app_user");
|
|
||||||
redisUtil.saveByKeyWithExpire("roleReferralCode",roleMap,120L);
|
|
||||||
RoleReferralCodeVO vo1 = new RoleReferralCodeVO();
|
|
||||||
vo1.setRoleName(roleService.getRoleByCode("market_user").getName());
|
|
||||||
vo1.setRoleReferralCode(code1);
|
|
||||||
RoleReferralCodeVO vo2 = new RoleReferralCodeVO();
|
|
||||||
vo2.setRoleName(roleService.getRoleByCode("engineering_user").getName());
|
|
||||||
vo2.setRoleReferralCode(code2);
|
|
||||||
RoleReferralCodeVO vo3 = new RoleReferralCodeVO();
|
|
||||||
vo3.setRoleName(roleService.getRoleByCode("app_user").getName());
|
|
||||||
vo3.setRoleReferralCode(code3);
|
|
||||||
list = Arrays.asList(vo1,vo2,vo3);
|
|
||||||
} else {
|
} else {
|
||||||
LinkedHashMap<String,String> map = (LinkedHashMap<String,String>) redisUtil.getObjectByKey("roleReferralCode");
|
LinkedHashMap<String,String> map = (LinkedHashMap<String,String>) redisUtil.getObjectByKey(RedisKeyEnum.ROLE_REFERRAL_CODE_KEY.getKey());
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
RoleReferralCodeVO vo = new RoleReferralCodeVO();
|
RoleReferralCodeVO vo = new RoleReferralCodeVO();
|
||||||
vo.setRoleReferralCode(entry.getKey());
|
vo.setRoleReferralCode(entry.getKey());
|
||||||
@@ -68,20 +53,19 @@ public class ReferralCodeServiceImpl implements IReferralCodeService {
|
|||||||
String code1 = PubUtils.getCode(6);
|
String code1 = PubUtils.getCode(6);
|
||||||
String code2 = PubUtils.getCode(6);
|
String code2 = PubUtils.getCode(6);
|
||||||
String code3 = PubUtils.getCode(6);
|
String code3 = PubUtils.getCode(6);
|
||||||
roleMap.put(code1,"market_user");
|
roleMap.put(code1,AppRoleEnum.MARKET_USER.getCode());
|
||||||
roleMap.put(code2,"engineering_user");
|
roleMap.put(code2,AppRoleEnum.ENGINEERING_USER.getCode());
|
||||||
roleMap.put(code3,"app_user");
|
roleMap.put(code3,AppRoleEnum.APP_VIP_USER.getCode());
|
||||||
redisUtil.saveByKeyWithExpire("roleReferralCode",roleMap,120L);
|
redisUtil.saveByKey(RedisKeyEnum.ROLE_REFERRAL_CODE_KEY.getKey(),roleMap);
|
||||||
RoleReferralCodeVO vo1 = new RoleReferralCodeVO();
|
RoleReferralCodeVO vo1 = new RoleReferralCodeVO();
|
||||||
vo1.setRoleName(roleService.getRoleByCode("market_user").getName());
|
vo1.setRoleName(roleService.getRoleByCode(AppRoleEnum.MARKET_USER.getCode()).getName());
|
||||||
vo1.setRoleReferralCode(code1);
|
vo1.setRoleReferralCode(code1);
|
||||||
RoleReferralCodeVO vo2 = new RoleReferralCodeVO();
|
RoleReferralCodeVO vo2 = new RoleReferralCodeVO();
|
||||||
vo2.setRoleName(roleService.getRoleByCode("engineering_user").getName());
|
vo2.setRoleName(roleService.getRoleByCode(AppRoleEnum.ENGINEERING_USER.getCode()).getName());
|
||||||
vo2.setRoleReferralCode(code2);
|
vo2.setRoleReferralCode(code2);
|
||||||
RoleReferralCodeVO vo3 = new RoleReferralCodeVO();
|
RoleReferralCodeVO vo3 = new RoleReferralCodeVO();
|
||||||
vo3.setRoleName(roleService.getRoleByCode("app_user").getName());
|
vo3.setRoleName(roleService.getRoleByCode(AppRoleEnum.APP_VIP_USER.getCode()).getName());
|
||||||
vo3.setRoleReferralCode(code3);
|
vo3.setRoleReferralCode(code3);
|
||||||
|
|
||||||
return Arrays.asList(vo1,vo2,vo3);
|
return Arrays.asList(vo1,vo2,vo3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user