|
|
@ -4,8 +4,8 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ccsens.cloudutil.feign.HealthFeignClient; |
|
|
|
import com.ccsens.tall.bean.dto.ProjectDto; |
|
|
@ -24,11 +24,11 @@ import com.ccsens.util.wx.WxXcxUtil; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.RandomStringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -39,29 +39,29 @@ import java.util.regex.Pattern; |
|
|
|
@Service |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class UserService implements IUserService { |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private SysUserDao userDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private SysAuthDao authDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private ProMemberDao memberDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private ProRoleDao proRoleDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private ProMemberRoleDao memberRoleDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private SysBalanceLogDao sysBalanceLogDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private Snowflake snowflake; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private RedisUtil redisUtil; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private SysWxDao sysWxDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private SysProjectDao sysProjectDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private UserAttentionDao userAttentionDao; |
|
|
|
@Autowired |
|
|
|
@Resource |
|
|
|
private HealthFeignClient healthFeignClient; |
|
|
|
|
|
|
|
|
|
|
@ -71,13 +71,13 @@ public class UserService implements IUserService { |
|
|
|
@Override |
|
|
|
public UserVo.UserSign signin(WebConstant.CLIENT_TYPE clientType, WebConstant.IDENTIFY_TYPE identifyType, |
|
|
|
String identifier, String credential, String clientIp, String redirect) throws Exception { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//1.登陆
|
|
|
|
userSignVo = __signin(identifyType, identifier, credential, redirect); |
|
|
|
if (ObjectUtil.isNotNull(userSignVo) && ObjectUtil.isNotNull(userSignVo.getAuthId())) { |
|
|
|
//2.添加登陆记录
|
|
|
|
__addSigninRecord(clientType, clientIp, userSignVo.getAuthId()); |
|
|
|
} |
|
|
|
// if (ObjectUtil.isNotNull(userSignVo) && ObjectUtil.isNotNull(userSignVo.getAuthId())) {
|
|
|
|
// //2.添加登陆记录
|
|
|
|
// __addSigninRecord(clientType, clientIp, userSignVo.getAuthId());
|
|
|
|
// }
|
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
@ -99,7 +99,7 @@ public class UserService implements IUserService { |
|
|
|
case Phone: |
|
|
|
return phoneLogin(identifier, credential); |
|
|
|
case Email: |
|
|
|
return emailLogin(identifier, credential); |
|
|
|
// return emailLogin(identifier, credential);
|
|
|
|
case Account: |
|
|
|
return accountLogin(identifier, credential); |
|
|
|
default: |
|
|
@ -110,10 +110,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 企业登录 |
|
|
|
* |
|
|
|
* @param identifier |
|
|
|
* @param credential |
|
|
|
* @return |
|
|
|
* @return 返回用户信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign wxEnterpriseLogin(String identifier, String credential, String redirect) { |
|
|
|
log.info("企业微信登录:{},{}, {}", identifier, credential, redirect); |
|
|
@ -128,23 +125,21 @@ public class UserService implements IUserService { |
|
|
|
if (userInfo == null) { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
UserVo.UserSign userSignVo = getUserSign(userInfo.getUserId(), userInfo.getCorpId(), (byte) WebConstant.IDENTIFY_TYPE.WxEnterprise.value, redirect); |
|
|
|
|
|
|
|
return userSignVo; |
|
|
|
return getUserSign(userInfo.getUserId(), userInfo.getCorpId(), (byte) WebConstant.IDENTIFY_TYPE.WxEnterprise.value, redirect); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 微信网页登陆 |
|
|
|
* |
|
|
|
* @param code |
|
|
|
* @return |
|
|
|
* @param code 微信code |
|
|
|
* @return 返回用户信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign wxH5Login(WebConstant.IDENTIFY_TYPE identifyType, String code) { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//获取微信信息
|
|
|
|
WxOauth2UserInfo wxOauth2UserInfo = WxGzhUtil.getOauth2UserInfo(identifyType, code); |
|
|
|
|
|
|
|
SysAuth theAuth = null; |
|
|
|
SysAuth theAuth; |
|
|
|
if (ObjectUtil.isNotNull(wxOauth2UserInfo)) { |
|
|
|
// //查找有无保存的信息
|
|
|
|
// SysWxExample sysWxExample = new SysWxExample();
|
|
|
@ -228,17 +223,16 @@ public class UserService implements IUserService { |
|
|
|
/** |
|
|
|
* 微信公众号登陆 |
|
|
|
* |
|
|
|
* @param code |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
* @param code 微信code |
|
|
|
* @return 返回用户信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign wxLogin(WebConstant.IDENTIFY_TYPE identifyType, String code) throws Exception { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
private UserVo.UserSign wxLogin(WebConstant.IDENTIFY_TYPE identifyType, String code) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//获取微信信息并保存
|
|
|
|
log.info("公众号登陆,{}", code); |
|
|
|
WxOauth2UserInfo wxOauth2UserInfo = WxGzhUtil.getOauth2UserInfo(identifyType, code); |
|
|
|
|
|
|
|
SysAuth theAuth = null; |
|
|
|
SysAuth theAuth; |
|
|
|
if (ObjectUtil.isNotNull(wxOauth2UserInfo)) { |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.OAUTH2_Wx.value) |
|
|
@ -303,7 +297,7 @@ public class UserService implements IUserService { |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
public void __addSigninRecord(WebConstant.CLIENT_TYPE clientType, String clientIp, Long authId) { |
|
|
|
// public void __addSigninRecord(WebConstant.CLIENT_TYPE clientType, String clientIp, Long authId) {
|
|
|
|
// SigninLog siginLog = new SigninLog();
|
|
|
|
// siginLog.setId(snowflake.nextId());
|
|
|
|
// siginLog.setAuthId(authId);
|
|
|
@ -311,18 +305,17 @@ public class UserService implements IUserService { |
|
|
|
// siginLog.setSigninIp(clientIp);
|
|
|
|
// siginLog.setSigninTime(DateUtil.date());
|
|
|
|
// signinLogDao.insertSelective(siginLog);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 手机号登陆 |
|
|
|
* |
|
|
|
* @param phone |
|
|
|
* @param smsVerifyCode |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
* @param phone 手机号 |
|
|
|
* @param smsVerifyCode 验证码 |
|
|
|
* @return 返回用户信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign phoneLogin(String phone, String smsVerifyCode) throws Exception { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
private UserVo.UserSign phoneLogin(String phone, String smsVerifyCode) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
if (isSmsCodeCorrect(phone, smsVerifyCode)) { |
|
|
|
//1.查找对应账户,不存在则注册
|
|
|
|
List<SysAuth> authList = null; |
|
|
@ -345,17 +338,17 @@ public class UserService implements IUserService { |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
private UserVo.UserSign emailLogin(String phone, String emailVerifyCode) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
// private UserVo.UserSign emailLogin(String phone, String emailVerifyCode) {
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 账号登录 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign accountLogin(String username, String password) throws Exception { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
List<SysAuth> authList = null; |
|
|
|
SysAuth theAuth = null; |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
List<SysAuth> authList; |
|
|
|
SysAuth theAuth; |
|
|
|
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria() |
|
|
@ -386,8 +379,7 @@ public class UserService implements IUserService { |
|
|
|
String openId = wechatUser.openid; |
|
|
|
String unionId = wechatUser.unionid; |
|
|
|
log.info("小程序登录,openid:{} ,unionId:{}", openId, unionId); |
|
|
|
UserVo.UserSign userSignVo = getUserSign(openId, unionId, (byte) WebConstant.IDENTIFY_TYPE.Wxmp.value, null); |
|
|
|
return userSignVo; |
|
|
|
return getUserSign(openId, unionId, (byte) WebConstant.IDENTIFY_TYPE.Wxmp.value, null); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -400,9 +392,9 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param openId |
|
|
|
* @param unionId |
|
|
|
* @return |
|
|
|
* @param openId openId |
|
|
|
* @param unionId unionId |
|
|
|
* @return 返回认证信息 |
|
|
|
*/ |
|
|
|
private UserVo.UserSign getUserSign(String openId, String unionId, |
|
|
|
byte identifyType, String redirect) { |
|
|
@ -535,7 +527,7 @@ public class UserService implements IUserService { |
|
|
|
* 获取token |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.TokenBean generateToken(WebConstant.CLIENT_TYPE clientType, Object subject, Map<String, Object> payLoads) throws Exception { |
|
|
|
public UserVo.TokenBean generateToken(WebConstant.CLIENT_TYPE clientType, Object subject, Map<String, Object> payLoads){ |
|
|
|
UserVo.TokenBean tokenBean = new UserVo.TokenBean(); |
|
|
|
|
|
|
|
Long tokenExpired = null; |
|
|
@ -543,24 +535,16 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
switch (clientType) { |
|
|
|
case Wxmp: |
|
|
|
//tokenExpired = 3600 * 1000L * 2;
|
|
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
|
break; |
|
|
|
case WxEnterprise: |
|
|
|
case H5: |
|
|
|
//tokenExpired = 3600 * 1000L * 2;
|
|
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
|
break; |
|
|
|
case Android: |
|
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
|
break; |
|
|
|
case IOS: |
|
|
|
tokenExpired = 3600 * 1000L * 2; |
|
|
|
refreshTokenExpired = 3600 * 1000L * 24 * 30; |
|
|
|
break; |
|
|
|
case WxEnterprise: |
|
|
|
tokenExpired = 3600 * 1000L * 24; |
|
|
|
break; |
|
|
|
default: |
|
|
|
|
|
|
|
} |
|
|
@ -571,19 +555,19 @@ public class UserService implements IUserService { |
|
|
|
JwtUtil.createJWT(subject + "", |
|
|
|
payLoads, tokenExpired, |
|
|
|
WebConstant.JWT_ACCESS_TOKEN_SECERT); |
|
|
|
redisUtil.set(RedisKeyManager.getTokenCachedKey((Long) subject), |
|
|
|
redisUtil.set(RedisKeyManager.getTokenCachedKey(subject), |
|
|
|
token, tokenExpired / 1000); |
|
|
|
tokenBean.setToken(token); |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(refreshTokenExpired)) { |
|
|
|
String refresh_token = |
|
|
|
String refreshToken = |
|
|
|
JwtUtil.createJWT(subject + "", |
|
|
|
payLoads, refreshTokenExpired, |
|
|
|
WebConstant.JWT_ACCESS_TOKEN_SECERT); |
|
|
|
redisUtil.set(RedisKeyManager.getRefreshTokenCachedKey(subject), |
|
|
|
refresh_token, refreshTokenExpired / 1000); |
|
|
|
tokenBean.setRefresh_token(refresh_token); |
|
|
|
refreshToken, refreshTokenExpired / 1000); |
|
|
|
tokenBean.setRefresh_token(refreshToken); |
|
|
|
} |
|
|
|
|
|
|
|
//2.返回
|
|
|
@ -627,19 +611,22 @@ public class UserService implements IUserService { |
|
|
|
throw new SmsException(SmsException.Error_SendTooFast); |
|
|
|
} |
|
|
|
|
|
|
|
//2.生成随机验证码
|
|
|
|
// String verifyCode = RandomUtil.randomNumbers(4);
|
|
|
|
//2.生成随机验证码 默认1111,生产开启验证码则获取随机数
|
|
|
|
String verifyCode = "1111"; |
|
|
|
if("1".equalsIgnoreCase(PropUtil.smsCode)){ |
|
|
|
verifyCode = RandomUtil.randomNumbers(4); |
|
|
|
} |
|
|
|
|
|
|
|
//3.保存到redis中
|
|
|
|
Integer codeValidInSeconds = WebConstant.Expired_Verify_Code_In_Seconds; |
|
|
|
Integer codeExistINSeconds = WebConstant.Exist_Verify_Code_In_Seconds; |
|
|
|
Integer codeExistInSeconds = WebConstant.Exist_Verify_Code_In_Seconds; |
|
|
|
redisUtil.set(RedisKeyManager.getSigninSmsKey(phone), verifyCode, codeValidInSeconds); |
|
|
|
redisUtil.set(RedisKeyManager.getSigninSmsExistKey(phone), verifyCode, codeExistINSeconds); |
|
|
|
redisUtil.set(RedisKeyManager.getSigninSmsExistKey(phone), verifyCode, codeExistInSeconds); |
|
|
|
|
|
|
|
//5.发送验证码
|
|
|
|
// SmsUtil.sendSms(phone, verifyCode, client_type.phase, codeValidInSeconds);
|
|
|
|
|
|
|
|
if("1".equalsIgnoreCase(PropUtil.smsCode)) { |
|
|
|
SmsUtil.sendSms(phone, verifyCode,"", codeValidInSeconds); |
|
|
|
} |
|
|
|
//6.返回
|
|
|
|
smsCodeVo = new UserVo.SmsCode(); |
|
|
|
smsCodeVo.setPhone(phone); |
|
|
@ -652,8 +639,8 @@ public class UserService implements IUserService { |
|
|
|
* 通过id找用户 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public SysUser getUserById(Long userId) throws Exception { |
|
|
|
SysUser theUser = null; |
|
|
|
public SysUser getUserById(Long userId) { |
|
|
|
SysUser theUser; |
|
|
|
theUser = userDao.selectByPrimaryKey(userId); |
|
|
|
if (ObjectUtil.isNull(theUser)) { |
|
|
|
throw new BaseException(406, "找不到对应Id用户: " + userId); |
|
|
@ -665,8 +652,8 @@ public class UserService implements IUserService { |
|
|
|
* 注册 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.UserSign registerUser(UserDto.UserSignup userSignup) throws Exception { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
public UserVo.UserSign registerUser(UserDto.UserSignup userSignup){ |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//验证码是否合格
|
|
|
|
if (isSmsCodeCorrect(userSignup.getPhone(), userSignup.getSmsCode())) { |
|
|
|
//检查手机号是否已被注册
|
|
|
@ -759,7 +746,6 @@ public class UserService implements IUserService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Boolean findAccount(String account) { |
|
|
|
Boolean flag = false; |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value) |
|
|
|
.andIdentifierEqualTo(account); |
|
|
@ -782,7 +768,6 @@ public class UserService implements IUserService { |
|
|
|
throw new BaseException(CodeEnum.PHONE_ERR); |
|
|
|
} |
|
|
|
|
|
|
|
Boolean flag = false; |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andIdentifierEqualTo(phone); |
|
|
@ -836,7 +821,6 @@ public class UserService implements IUserService { |
|
|
|
} else { |
|
|
|
//改手机对应账户,如果有,提示
|
|
|
|
List<SysAuth> phoneList; |
|
|
|
SysAuth theAuth = null; |
|
|
|
SysAuthExample phoneExample = new SysAuthExample(); |
|
|
|
phoneExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andIdentifierEqualTo(wxPhone.getPhone()); |
|
|
@ -1146,7 +1130,7 @@ 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) throws Exception { |
|
|
|
public UserVo.TokenBean getUserInfoAndToken(WebConstant.CLIENT_TYPE clientType, WebConstant.IDENTIFY_TYPE identifyType,UserVo.UserSign userSignVo, Map<String, Object> theMap) { |
|
|
|
|
|
|
|
UserVo.TokenBean tokenBean = generateToken(clientType, userSignVo.getUserId(), theMap); |
|
|
|
//获取手机号
|
|
|
@ -1203,21 +1187,20 @@ public class UserService implements IUserService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private SysWx getSysWx(String unionId) { |
|
|
|
SysWx sysWx = null; |
|
|
|
SysWxExample sysWxExample = new SysWxExample(); |
|
|
|
sysWxExample.createCriteria().andUnionIdEqualTo(unionId); |
|
|
|
List<SysWx> sysWxList = sysWxDao.selectByExample(sysWxExample); |
|
|
|
if (CollectionUtil.isNotEmpty(sysWxList)) { |
|
|
|
sysWx = sysWxList.get(0); |
|
|
|
} |
|
|
|
return sysWx; |
|
|
|
} |
|
|
|
//
|
|
|
|
// private SysWx getSysWx(String unionId) {
|
|
|
|
// SysWx sysWx = null;
|
|
|
|
// SysWxExample sysWxExample = new SysWxExample();
|
|
|
|
// sysWxExample.createCriteria().andUnionIdEqualTo(unionId);
|
|
|
|
// List<SysWx> sysWxList = sysWxDao.selectByExample(sysWxExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(sysWxList)) {
|
|
|
|
// sysWx = sysWxList.get(0);
|
|
|
|
// }
|
|
|
|
// return sysWx;
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 合并账号 |
|
|
|
* |
|
|
|
* @param currentUserId userId |
|
|
|
* @param wxPhone 手机号和合并方式 |
|
|
|
* @return 用户id |
|
|
@ -1336,8 +1319,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改用户信息(添加微信信息) |
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return 返回信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.WxInfo updateUserInfo(Long currentUserId, UserDto.WxInfo userInfo) { |
|
|
@ -1407,7 +1389,7 @@ public class UserService implements IUserService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.UserSign changePhoneNotPassword(Long userId, UserDto.WxBindingPhone phoneInfo) { |
|
|
|
UserVo.UserSign userSign = null; |
|
|
|
UserVo.UserSign userSign; |
|
|
|
if (isSmsCodeCorrect(phoneInfo.getPhone(), phoneInfo.getSmsCode())) { |
|
|
|
//查找新手机号的的绑定信息
|
|
|
|
Long newPhoneUserId = selectUserIdByPhone(phoneInfo.getPhone()); |
|
|
@ -1455,8 +1437,8 @@ public class UserService implements IUserService { |
|
|
|
/** |
|
|
|
* 通过userId获取token |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @return |
|
|
|
* @param userId userId |
|
|
|
* @return token |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.TokenBean getTokenByUserId(Long userId) { |
|
|
@ -1465,7 +1447,7 @@ public class UserService implements IUserService { |
|
|
|
if (ObjectUtil.isNull(userId)) { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
Object tokenR = redisUtil.get(RedisKeyManager.getTokenCachedKey(userId)); |
|
|
|
Object tokenRe = redisUtil.get(RedisKeyManager.getTokenCachedKey(userId)); |
|
|
|
//获取认证信息
|
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
@ -1498,23 +1480,23 @@ public class UserService implements IUserService { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
//如果token为空重新生成一份
|
|
|
|
if (ObjectUtil.isNull(tokenR)) { |
|
|
|
if (ObjectUtil.isNull(tokenRe)) { |
|
|
|
//3.生成token(access_token,refresh_token)
|
|
|
|
if (ObjectUtil.isNotNull(userSignVo)) { |
|
|
|
Map<String, Object> theMap = CollectionUtil.newHashMap(); |
|
|
|
theMap.put("authId", String.valueOf(userSignVo.getAuthId())); |
|
|
|
Long tokenExpired = 3600 * 1000L * 24 * 100; |
|
|
|
long tokenExpired = 3600 * 1000L * 24 * 100; |
|
|
|
|
|
|
|
String token = |
|
|
|
JwtUtil.createJWT(userId + "", |
|
|
|
theMap, tokenExpired, |
|
|
|
WebConstant.JWT_ACCESS_TOKEN_SECERT).toString(); |
|
|
|
redisUtil.set(RedisKeyManager.getTokenCachedKey((Long) userId), |
|
|
|
WebConstant.JWT_ACCESS_TOKEN_SECERT); |
|
|
|
redisUtil.set(RedisKeyManager.getTokenCachedKey(userId), |
|
|
|
token, tokenExpired / 1000); |
|
|
|
tokenR = token; |
|
|
|
tokenRe = token; |
|
|
|
} |
|
|
|
} |
|
|
|
tokenBean.setToken(tokenR.toString()); |
|
|
|
tokenBean.setToken(tokenRe.toString()); |
|
|
|
return tokenBean; |
|
|
|
} |
|
|
|
|
|
|
@ -1526,8 +1508,8 @@ public class UserService implements IUserService { |
|
|
|
user.setId(snowflake.nextId()); |
|
|
|
userDao.insertSelective(user); |
|
|
|
//自动添加账号密码
|
|
|
|
String accountName = null; |
|
|
|
String password = null; |
|
|
|
String accountName; |
|
|
|
String password; |
|
|
|
if(StrUtil.isNotEmpty(userSignup.getAccount())){ |
|
|
|
accountName = userSignup.getAccount(); |
|
|
|
SysAuthExample sysAuthExample = new SysAuthExample(); |
|
|
@ -1584,9 +1566,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<UserVo.UserInfo> queryUserInfos(Long[] ids) { |
|
|
|
|
|
|
|
List<UserVo.UserInfo> infos = userDao.queryUserInfos(ids); |
|
|
|
return infos; |
|
|
|
return userDao.queryUserInfos(ids); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|