|
|
@ -97,6 +97,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 企业登录 |
|
|
|
* |
|
|
|
* @return 返回用户信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign wxEnterpriseLogin(String identifier, String credential, String redirect) { |
|
|
@ -309,7 +310,6 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 账号登录 |
|
|
|
*/ |
|
|
@ -335,7 +335,7 @@ public class UserService implements IUserService { |
|
|
|
throw new BaseException(CodeEnum.PASSWORD_ERROR); |
|
|
|
} |
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
log.info("查询并验证账号用时:{}",end - start); |
|
|
|
log.info("查询并验证账号用时:{}", end - start); |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
@ -347,7 +347,7 @@ public class UserService implements IUserService { |
|
|
|
Long start = System.currentTimeMillis(); |
|
|
|
WxXcxUtil.WechatUser wechatUser = WxXcxUtil.getUserInfo(code, gameType); |
|
|
|
Long end = System.currentTimeMillis(); |
|
|
|
log.info("调用微信查询openId耗时:{}",end - start); |
|
|
|
log.info("调用微信查询openId耗时:{}", end - start); |
|
|
|
String openId = wechatUser.openid; |
|
|
|
String unionId = wechatUser.unionid; |
|
|
|
log.info("小程序登录,openid:{} ,unionId:{}", openId, unionId); |
|
|
@ -371,15 +371,15 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
String key = openId + TallConstant.LOGIN + identifyType; |
|
|
|
Object o = redisUtil.get(key); |
|
|
|
if(ObjectUtil.isNotNull(o)){ |
|
|
|
return (UserVo.UserSign)o; |
|
|
|
if (ObjectUtil.isNotNull(o)) { |
|
|
|
return (UserVo.UserSign) o; |
|
|
|
} |
|
|
|
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo(identifyType).andIdentifierEqualTo(openId); |
|
|
|
authList = authDao.selectByExample(authExample); |
|
|
|
long end1 = System.currentTimeMillis(); |
|
|
|
log.info("查auth表耗时:{}",end1 - start); |
|
|
|
log.info("查auth表耗时:{}", end1 - start); |
|
|
|
if (CollectionUtil.isEmpty(authList)) { |
|
|
|
List<SysAuth> sysAuthList = null; |
|
|
|
long end2 = 0; |
|
|
@ -388,7 +388,7 @@ public class UserService implements IUserService { |
|
|
|
sysAuthExample.createCriteria().andCredentialEqualTo(unionId); |
|
|
|
sysAuthList = authDao.selectByExample(sysAuthExample); |
|
|
|
end2 = System.currentTimeMillis(); |
|
|
|
log.info("查找同平台其他登录方式耗时:{}",end2 - end1); |
|
|
|
log.info("查找同平台其他登录方式耗时:{}", end2 - end1); |
|
|
|
} |
|
|
|
if (CollectionUtil.isNotEmpty(sysAuthList)) { |
|
|
|
//添加认证方式
|
|
|
@ -400,7 +400,7 @@ public class UserService implements IUserService { |
|
|
|
theAuth.setCredential(unionId); |
|
|
|
authDao.insertSelective(theAuth); |
|
|
|
long end3 = System.currentTimeMillis(); |
|
|
|
log.info("同平台有其他登录方式,添加小程序auth耗时:{}",end3 - (end2 == 0 ? end1 : end2)); |
|
|
|
log.info("同平台有其他登录方式,添加小程序auth耗时:{}", end3 - (end2 == 0 ? end1 : end2)); |
|
|
|
} else { |
|
|
|
//新建用户并保存微信信息
|
|
|
|
SysUser user = new SysUser(); |
|
|
@ -417,7 +417,7 @@ public class UserService implements IUserService { |
|
|
|
theAuth.setCredential(unionId); |
|
|
|
authDao.insertSelective(theAuth); |
|
|
|
long end4 = System.currentTimeMillis(); |
|
|
|
log.info("同平台没有其他登录方式,添加user和小程序auth耗时:{}",end4 - (end2 == 0 ? end1 : end2)); |
|
|
|
log.info("同平台没有其他登录方式,添加user和小程序auth耗时:{}", end4 - (end2 == 0 ? end1 : end2)); |
|
|
|
// //自动添加账号密码
|
|
|
|
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
|
|
|
|
// SysAuth accountAuth = new SysAuth();
|
|
|
@ -440,14 +440,15 @@ public class UserService implements IUserService { |
|
|
|
userSignVo.setAuthId(theAuth.getId()); |
|
|
|
|
|
|
|
//存入redis
|
|
|
|
redisUtil.set(key,userSignVo, TallConstant.LOGIN_TIME); |
|
|
|
redisUtil.set(key, userSignVo, TallConstant.LOGIN_TIME); |
|
|
|
long end2 = System.currentTimeMillis(); |
|
|
|
log.info("方法结束总耗时:{}",end2 - end1); |
|
|
|
log.info("方法结束总耗时:{}", end2 - end1); |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取企业微信信息,并绑定用户 |
|
|
|
* |
|
|
|
* @param identifyType 登录类型 |
|
|
|
* @param userid userId |
|
|
|
* @param corpId corpId |
|
|
@ -470,7 +471,7 @@ public class UserService implements IUserService { |
|
|
|
user.setGender(data.getByteValue("gender")); |
|
|
|
user.setAvatarUrl(data.getString("avatar")); |
|
|
|
} |
|
|
|
user.setRecStatus((byte)0); |
|
|
|
user.setRecStatus((byte) 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -511,7 +512,7 @@ public class UserService implements IUserService { |
|
|
|
* 获取token |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.TokenBean generateToken(WebConstant.CLIENT_TYPE clientType, Object subject, Map<String, Object> payLoads){ |
|
|
|
public UserVo.TokenBean generateToken(WebConstant.CLIENT_TYPE clientType, Object subject, Map<String, Object> payLoads) { |
|
|
|
UserVo.TokenBean tokenBean = new UserVo.TokenBean(); |
|
|
|
|
|
|
|
Long tokenExpired = null; |
|
|
@ -546,7 +547,7 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
|
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
log.info("生成token并缓存到redis用时:{}",end - start); |
|
|
|
log.info("生成token并缓存到redis用时:{}", end - start); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(refreshTokenExpired)) { |
|
|
|
String refreshToken = |
|
|
@ -566,7 +567,7 @@ public class UserService implements IUserService { |
|
|
|
* 发送验证码 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.SmsCode getSignInSmsCode(String phone,String verificationCodeId, String verificationCodeValue) { |
|
|
|
public UserVo.SmsCode getSignInSmsCode(String phone, String verificationCodeId, String verificationCodeValue) { |
|
|
|
//检查图形验证码是否正确
|
|
|
|
String codeKey = WebConstant.IMAGE_CODE + verificationCodeId; |
|
|
|
if (!redisUtil.hasKey(codeKey)) { |
|
|
@ -594,7 +595,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
|
|
|
|
String verifyCode = "1111"; |
|
|
|
if("1".equalsIgnoreCase(PropUtil.smsCode)){ |
|
|
|
if ("1".equalsIgnoreCase(PropUtil.smsCode)) { |
|
|
|
verifyCode = RandomUtil.randomNumbers(4); |
|
|
|
} |
|
|
|
|
|
|
@ -605,8 +606,8 @@ public class UserService implements IUserService { |
|
|
|
redisUtil.set(RedisKeyManager.getSigninSmsExistKey(phone), verifyCode, codeExistInSeconds); |
|
|
|
|
|
|
|
//5.发送验证码
|
|
|
|
if("1".equalsIgnoreCase(PropUtil.smsCode)) { |
|
|
|
SmsUtil.sendSms(phone, verifyCode,"", codeValidInSeconds); |
|
|
|
if ("1".equalsIgnoreCase(PropUtil.smsCode)) { |
|
|
|
SmsUtil.sendSms(phone, verifyCode, "", codeValidInSeconds); |
|
|
|
} |
|
|
|
//6.返回
|
|
|
|
smsCodeVo = new UserVo.SmsCode(); |
|
|
@ -633,7 +634,7 @@ public class UserService implements IUserService { |
|
|
|
* 注册 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.UserSign registerUser(UserDto.UserSignup userSignup){ |
|
|
|
public UserVo.UserSign registerUser(UserDto.UserSignup userSignup) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//验证码是否合格
|
|
|
|
if (isSmsCodeCorrect(userSignup.getPhone(), userSignup.getSmsCode())) { |
|
|
@ -813,6 +814,54 @@ public class UserService implements IUserService { |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 绑定手机号(不用验证码) |
|
|
|
* |
|
|
|
* @param currentUserId userId |
|
|
|
* @param wxPhone 手机号 |
|
|
|
* @return 用户id和认证类型 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.UserSign bindingPhoneNoCode(Long currentUserId, UserDto.WxBindingPhone wxPhone) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//查找该用户以前绑定的手机
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andUserIdEqualTo(currentUserId); |
|
|
|
List<SysAuth> authList = authDao.selectByExample(authExample); |
|
|
|
if (CollectionUtil.isNotEmpty(authList)) { |
|
|
|
throw new BaseException(CodeEnum.ALREADY_BINDING_PHONE); |
|
|
|
} else { |
|
|
|
//改手机对应账户,如果有,提示
|
|
|
|
List<SysAuth> phoneList; |
|
|
|
SysAuthExample phoneExample = new SysAuthExample(); |
|
|
|
phoneExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andIdentifierEqualTo(wxPhone.getPhone()); |
|
|
|
phoneList = authDao.selectByExample(phoneExample); |
|
|
|
if (CollectionUtil.isNotEmpty(phoneList)) { |
|
|
|
throw new BaseException(CodeEnum.MERGE_WX_PHONE); |
|
|
|
} else { |
|
|
|
//绑定 添加auth
|
|
|
|
SysAuth auth = new SysAuth(); |
|
|
|
auth.setId(snowflake.nextId()); |
|
|
|
auth.setUserId(currentUserId); |
|
|
|
auth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Phone.value); |
|
|
|
auth.setIdentifier(wxPhone.getPhone()); |
|
|
|
authDao.insertSelective(auth); |
|
|
|
|
|
|
|
//给所有手机号一样的角色添加userId
|
|
|
|
relevanceUserService.relevancePhone(wxPhone.getPhone(), currentUserId); |
|
|
|
//返回值
|
|
|
|
userSignVo = new UserVo.UserSign(); |
|
|
|
userSignVo.setAuthId(auth.getId()); |
|
|
|
userSignVo.setUserId(auth.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 更改绑定手机号 |
|
|
|
*/ |
|
|
@ -906,8 +955,8 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updatePasswordByAccount(UserDto.UpdatePasswordByAccount passwordDto) throws Exception{ |
|
|
|
if (passwordDto.getPasswordOld().equalsIgnoreCase(passwordDto.getPasswordNew())){ |
|
|
|
public void updatePasswordByAccount(UserDto.UpdatePasswordByAccount passwordDto) throws Exception { |
|
|
|
if (passwordDto.getPasswordOld().equalsIgnoreCase(passwordDto.getPasswordNew())) { |
|
|
|
throw new BaseException(CodeEnum.NEW_PASSWORD_REPEAT_OLD); |
|
|
|
} |
|
|
|
//检查账号和密码是否正确
|
|
|
@ -931,6 +980,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过用户查找手机号 |
|
|
|
* |
|
|
|
* @param userId userId |
|
|
|
* @return 手机号 |
|
|
|
*/ |
|
|
@ -1009,16 +1059,16 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public UserVo.TokenBean getUserInfoAndToken(WebConstant.CLIENT_TYPE clientType, WebConstant.IDENTIFY_TYPE identifyType,UserVo.UserSign userSignVo, Map<String, Object> theMap) { |
|
|
|
public UserVo.TokenBean getUserInfoAndToken(WebConstant.CLIENT_TYPE clientType, WebConstant.IDENTIFY_TYPE identifyType, UserVo.UserSign userSignVo, Map<String, Object> theMap) { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
UserVo.TokenBean tokenBean = userDao.getTokenBeanByUserId(userSignVo.getUserId()); |
|
|
|
//如果只有手机号没有账号信息,则将手机号脱敏当成账号
|
|
|
|
if (StrUtil.isEmpty(tokenBean.getAccount()) && StrUtil.isNotEmpty(tokenBean.getPhone())){ |
|
|
|
if (StrUtil.isEmpty(tokenBean.getAccount()) && StrUtil.isNotEmpty(tokenBean.getPhone())) { |
|
|
|
String phoneNumber = tokenBean.getPhone().substring(0, 3) + "****" + tokenBean.getPhone().substring(7, tokenBean.getPhone().length()); |
|
|
|
tokenBean.setAccount(phoneNumber); |
|
|
|
} |
|
|
|
long end1 = System.currentTimeMillis(); |
|
|
|
log.info("查询用户信息用了:{}",end1 - start); |
|
|
|
log.info("查询用户信息用了:{}", end1 - start); |
|
|
|
//获取token
|
|
|
|
UserVo.TokenBean tokenBean1 = generateToken(clientType, userSignVo.getUserId(), theMap); |
|
|
|
tokenBean.setToken(tokenBean1.getToken()); |
|
|
@ -1030,6 +1080,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 合并账号 |
|
|
|
* |
|
|
|
* @param currentUserId userId |
|
|
|
* @param mergePhone 手机号和合并方式 |
|
|
|
* @return 用户id |
|
|
@ -1053,11 +1104,11 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
} |
|
|
|
//将其他登录方式的userId替换为新userId
|
|
|
|
userDao.replaceAuth(currentUserId,userId); |
|
|
|
userDao.replaceAuth(currentUserId, userId); |
|
|
|
//将用户项目关联表里的userId替换为新的
|
|
|
|
userDao.replaceUserProject(currentUserId,userId); |
|
|
|
userDao.replaceUserProject(currentUserId, userId); |
|
|
|
//TODO 调用业务系统替换所有的userId
|
|
|
|
relevanceUserService.mergeUserByPhone(currentUserId,userId); |
|
|
|
relevanceUserService.mergeUserByPhone(currentUserId, userId); |
|
|
|
//原user改为已禁用
|
|
|
|
SysUser sysUser = userDao.selectByPrimaryKey(currentUserId); |
|
|
|
sysUser.setRecStatus((byte) 1); |
|
|
@ -1075,7 +1126,7 @@ public class UserService implements IUserService { |
|
|
|
SysAuth auth = authList.get(0); |
|
|
|
//查找这个手机号以前的用户,并删除
|
|
|
|
SysUser user = userDao.selectByPrimaryKey(auth.getUserId()); |
|
|
|
if(ObjectUtil.isNotNull(user)){ |
|
|
|
if (ObjectUtil.isNotNull(user)) { |
|
|
|
user.setRecStatus((byte) 2); |
|
|
|
userDao.updateByPrimaryKeySelective(user); |
|
|
|
} |
|
|
@ -1143,13 +1194,14 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改用户信息(添加微信信息) |
|
|
|
* |
|
|
|
* @return 返回信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.WxInfo updateUserInfo(Long currentUserId, UserDto.WxInfo userInfo) { |
|
|
|
//通过userId查找到用户
|
|
|
|
SysUser user = userDao.selectByPrimaryKey(currentUserId); |
|
|
|
log.info("查找到原来的user信息,{}",user); |
|
|
|
log.info("查找到原来的user信息,{}", user); |
|
|
|
if (ObjectUtil.isNull(user)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
|
|
} |
|
|
@ -1176,7 +1228,7 @@ public class UserService implements IUserService { |
|
|
|
user.setLanguage(userInfo.getLanguage()); |
|
|
|
} |
|
|
|
userDao.updateByPrimaryKeySelective(user); |
|
|
|
log.info("修改后的user信息,{}",user); |
|
|
|
log.info("修改后的user信息,{}", user); |
|
|
|
UserVo.WxInfo wxInfo = new UserVo.WxInfo(); |
|
|
|
BeanUtil.copyProperties(user, wxInfo); |
|
|
|
wxInfo.setHeadImgUrl(user.getAvatarUrl()); |
|
|
@ -1189,7 +1241,7 @@ public class UserService implements IUserService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void relievePhone(Long userId, UserDto.WxBindingPhone phoneInfo) { |
|
|
|
if(isSmsCodeCorrect(phoneInfo.getPhone(),phoneInfo.getSmsCode())){ |
|
|
|
if (isSmsCodeCorrect(phoneInfo.getPhone(), phoneInfo.getSmsCode())) { |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andUserIdEqualTo(userId) |
|
|
|
.andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
@ -1199,7 +1251,7 @@ public class UserService implements IUserService { |
|
|
|
SysAuth auth = authList.get(0); |
|
|
|
auth.setRecStatus((byte) 2); |
|
|
|
authDao.updateByPrimaryKeySelective(auth); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.PHONE_ERR); |
|
|
|
} |
|
|
|
} |
|
|
@ -1283,8 +1335,8 @@ public class UserService implements IUserService { |
|
|
|
userSignVo.setUserId(authList.get(0).getUserId()); |
|
|
|
userSignVo.setAuthId(authList.get(0).getId()); |
|
|
|
} |
|
|
|
log.info("获取认证信息:{}",userSignVo); |
|
|
|
if(ObjectUtil.isNotNull(userSignVo)){ |
|
|
|
log.info("获取认证信息:{}", userSignVo); |
|
|
|
if (ObjectUtil.isNotNull(userSignVo)) { |
|
|
|
//获取手机号
|
|
|
|
String phone = getPhone(userSignVo.getUserId()); |
|
|
|
//获取账号
|
|
|
@ -1302,7 +1354,7 @@ public class UserService implements IUserService { |
|
|
|
tokenBean.setPhone(phone); |
|
|
|
tokenBean.setAccount(account); |
|
|
|
tokenBean.setWxInfo(wxInfo); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
//如果token为空重新生成一份
|
|
|
@ -1336,35 +1388,35 @@ public class UserService implements IUserService { |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName; |
|
|
|
String password; |
|
|
|
if(StrUtil.isNotEmpty(userSignup.getAccount())){ |
|
|
|
if (StrUtil.isNotEmpty(userSignup.getAccount())) { |
|
|
|
accountName = userSignup.getAccount(); |
|
|
|
SysAuthExample sysAuthExample = new SysAuthExample(); |
|
|
|
sysAuthExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value).andIdentifierEqualTo(accountName); |
|
|
|
List<SysAuth> authList = authDao.selectByExample(sysAuthExample); |
|
|
|
if(CollectionUtil.isNotEmpty(authList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(authList)) { |
|
|
|
throw new BaseException(CodeEnum.ALREADY_EXIST_ACCOUNT); |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
accountName = "USER_" + RandomStringUtils.random(8, WebConstant.RANDOM_STR); |
|
|
|
} |
|
|
|
//检查账号是否存在
|
|
|
|
boolean flag = true; |
|
|
|
int i = 0; |
|
|
|
while (flag){ |
|
|
|
while (flag) { |
|
|
|
SysAuthExample sysAuthExample = new SysAuthExample(); |
|
|
|
sysAuthExample.createCriteria().andIdentifierEqualTo(accountName + (i==0 ? "" : "_"+i)).andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
sysAuthExample.createCriteria().andIdentifierEqualTo(accountName + (i == 0 ? "" : "_" + i)).andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value); |
|
|
|
List<SysAuth> authList1 = authDao.selectByExample(sysAuthExample); |
|
|
|
if(CollectionUtil.isEmpty(authList1)){ |
|
|
|
if (CollectionUtil.isEmpty(authList1)) { |
|
|
|
flag = false; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
|
accountName = accountName + (i==0 ? "" : "_"+i); |
|
|
|
accountName = accountName + (i == 0 ? "" : "_" + i); |
|
|
|
|
|
|
|
if(StrUtil.isNotEmpty(userSignup.getPassword())){ |
|
|
|
if (StrUtil.isNotEmpty(userSignup.getPassword())) { |
|
|
|
password = userSignup.getPassword(); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
password = "123456"; |
|
|
|
} |
|
|
|
SysAuth accountAuth = new SysAuth(); |
|
|
@ -1397,13 +1449,13 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public UserVo.VerificationCode getVertifyCode() { |
|
|
|
Map<String,Object> codeMap = ImageCodeGeneratorUtil.generateCountCode(); |
|
|
|
Map<String, Object> codeMap = ImageCodeGeneratorUtil.generateCountCode(); |
|
|
|
//生成一个id
|
|
|
|
long id = snowflake.nextId(); |
|
|
|
//将两个数的和,存在redis内,key为新生成的id
|
|
|
|
String imageCodeKey = WebConstant.IMAGE_CODE + id; |
|
|
|
redisUtil.set(imageCodeKey,codeMap.get("sum"),90); |
|
|
|
log.info("将图形验证码存入redis:{}",imageCodeKey); |
|
|
|
redisUtil.set(imageCodeKey, codeMap.get("sum"), 90); |
|
|
|
log.info("将图形验证码存入redis:{}", imageCodeKey); |
|
|
|
String imageBase64 = "data:image/png;base64," + ImageCodeGeneratorUtil.generateCodeImage(null, (String) codeMap.get("imageCode"), 200, 70); |
|
|
|
|
|
|
|
UserVo.VerificationCode vertifyCode = new UserVo.VerificationCode(); |
|
|
|