|
|
@ -7,6 +7,7 @@ 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 cn.hutool.extra.servlet.ServletUtil; |
|
|
|
import com.ccsens.cloudutil.feign.HealthFeignClient; |
|
|
|
import com.ccsens.tall.bean.dto.ProjectDto; |
|
|
|
import com.ccsens.tall.bean.dto.UserDto; |
|
|
@ -112,6 +113,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 企业登录 |
|
|
|
* |
|
|
|
* @param identifier |
|
|
|
* @param credential |
|
|
|
* @return |
|
|
@ -402,7 +404,6 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param openId |
|
|
|
* @param unionId |
|
|
|
* @return |
|
|
@ -478,6 +479,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取企业微信信息,并绑定用户 |
|
|
|
* |
|
|
|
* @param identifyType |
|
|
|
* @param param |
|
|
|
* @param user |
|
|
@ -1032,6 +1034,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询用户是否关注此项目 |
|
|
|
* |
|
|
|
* @param currentUserId |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
@ -1054,6 +1057,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户关注某个项目 |
|
|
|
* |
|
|
|
* @param currentUserId |
|
|
|
* @param projectIdDto |
|
|
|
*/ |
|
|
@ -1298,6 +1302,7 @@ public class UserService implements IUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 更改绑定手机号(不要密码) |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param phoneInfo |
|
|
|
* @throws Exception |
|
|
@ -1347,4 +1352,48 @@ public class UserService implements IUserService { |
|
|
|
} |
|
|
|
return userSign; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 通过userId获取token |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String getTokenByUserId(Long userId) { |
|
|
|
if (ObjectUtil.isNull(userId)) { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
Object object = redisUtil.get(RedisKeyManager.getTokenCachedKey(userId)); |
|
|
|
if (ObjectUtil.isNull(object)) { |
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andUserIdEqualTo(userId); |
|
|
|
List<SysAuth> authList = authDao.selectByExample(authExample); |
|
|
|
if (CollectionUtil.isNotEmpty(authList)) { |
|
|
|
userSignVo = new UserVo.UserSign(); |
|
|
|
userSignVo.setUserId(authList.get(0).getUserId()); |
|
|
|
userSignVo.setAuthId(authList.get(0).getId()); |
|
|
|
} |
|
|
|
//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; |
|
|
|
|
|
|
|
String token = |
|
|
|
JwtUtil.createJWT(userId + "", |
|
|
|
theMap, tokenExpired, |
|
|
|
WebConstant.JWT_ACCESS_TOKEN_SECERT); |
|
|
|
redisUtil.set(RedisKeyManager.getTokenCachedKey((Long) userId), |
|
|
|
token, tokenExpired / 1000); |
|
|
|
object = token; |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
return object.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|