|
@@ -11,6 +11,7 @@ import com.zanxiang.common.utils.IpUtils;
|
|
|
import com.zanxiang.common.utils.JsonUtil;
|
|
|
import com.zanxiang.common.utils.URIUtil;
|
|
|
import com.zanxiang.mybatis.entity.User;
|
|
|
+import com.zanxiang.mybatis.entity.UserCard;
|
|
|
import com.zanxiang.sdk.constant.ApiUrlConstant;
|
|
|
import com.zanxiang.sdk.constant.RedisKeyConstant;
|
|
|
import com.zanxiang.sdk.domain.dto.UserOauthDTO;
|
|
@@ -77,6 +78,9 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
@Autowired
|
|
|
private ChannelService channelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserCardService userCardService;
|
|
|
+
|
|
|
/**
|
|
|
* QQ开发者应用id
|
|
|
*/
|
|
@@ -101,13 +105,10 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
public ResultVO<UserLoginVO> loginPassword(LoginPasswordParam param, UserData userData) {
|
|
|
String username = param.getUsername();
|
|
|
String password = param.getPassword();
|
|
|
- Long gameId = userData.getGameId();
|
|
|
- Integer deviceType = userData.getDeviceType();
|
|
|
- Integer type = param.getType();
|
|
|
//用户信息
|
|
|
User user;
|
|
|
//登录, 进行登录检测
|
|
|
- if (Objects.equals(type, LoginPasswordParam.LOGIN)) {
|
|
|
+ if (Objects.equals(param.getType(), LoginPasswordParam.LOGIN)) {
|
|
|
//判断是否手机号
|
|
|
if (RegexUtil.checkPhone(username)) {
|
|
|
user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getMobile, username));
|
|
@@ -136,10 +137,10 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
//创建用户信息
|
|
|
user = User.builder()
|
|
|
.agentId(channelService.getByChannelSign(userData.getChannel()))
|
|
|
- .gameId(gameId)
|
|
|
+ .gameId(userData.getGameId())
|
|
|
.username(username)
|
|
|
.password(RegisterUtil.cmfPassword(password))
|
|
|
- .deviceType(deviceType)
|
|
|
+ .deviceType(userData.getDeviceType())
|
|
|
.status(AccountStatusEnum.NORMAL_STATUS.getStatus())
|
|
|
.authentication(0)
|
|
|
.createTime(LocalDateTime.now())
|
|
@@ -151,20 +152,8 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
.build();
|
|
|
userService.save(user);
|
|
|
}
|
|
|
- //插入用户登录记录
|
|
|
- userLoginLogService.addUserLoginLog(userData.getIp(), user, gameId, 0);
|
|
|
- //验证通过, 获取token
|
|
|
- String userToken = userTokenService.getUserToken(user.getId(), deviceType);
|
|
|
- //构造用户登录信息
|
|
|
- UserLoginVO userLoginVO = UserLoginVO.builder()
|
|
|
- .userId(user.getId())
|
|
|
- .userName(user.getUsername())
|
|
|
- .token(userToken)
|
|
|
- .authentication(user.getAuthentication())
|
|
|
- .bindPhone(Strings.isBlank(user.getMobile()) ? 0 : 1)
|
|
|
- .build();
|
|
|
//返回登录信息
|
|
|
- return new ResultVO<>(userLoginVO);
|
|
|
+ return new ResultVO<>(this.createUserLoginVO(user, userData));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,11 +167,8 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVO<UserLoginVO> loginMobile(LoginMobileParam param, UserData userData) {
|
|
|
String mobile = param.getMobile();
|
|
|
- String code = param.getCode();
|
|
|
- Long gameId = userData.getGameId();
|
|
|
- Integer deviceType = userData.getDeviceType();
|
|
|
//验证码校验
|
|
|
- HttpStatusEnum httpStatusEnum = smsService.smsCheck(SmsTypeEnum.SMS_REG.getType(), mobile, code);
|
|
|
+ HttpStatusEnum httpStatusEnum = smsService.smsCheck(SmsTypeEnum.SMS_REG.getType(), mobile, param.getCode());
|
|
|
//验证不通过, 返回
|
|
|
if (!Objects.equals(httpStatusEnum, HttpStatusEnum.SUCCESS)) {
|
|
|
return new ResultVO<>(httpStatusEnum);
|
|
@@ -193,10 +179,10 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
if (user == null) {
|
|
|
user = User.builder()
|
|
|
.agentId(channelService.getByChannelSign(userData.getChannel()))
|
|
|
- .gameId(gameId)
|
|
|
+ .gameId(userData.getGameId())
|
|
|
.username(mobile)
|
|
|
.mobile(mobile)
|
|
|
- .deviceType(deviceType)
|
|
|
+ .deviceType(userData.getDeviceType())
|
|
|
.status(AccountStatusEnum.NORMAL_STATUS.getStatus())
|
|
|
.authentication(0)
|
|
|
.createTime(LocalDateTime.now())
|
|
@@ -213,20 +199,36 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
return new ResultVO<>(HttpStatusEnum.ACCOUNT_HALT);
|
|
|
}
|
|
|
}
|
|
|
- //验证通过, 获取token
|
|
|
- String userToken = userTokenService.getUserToken(user.getId(), deviceType);
|
|
|
+ //返回登录信息
|
|
|
+ return new ResultVO<>(this.createUserLoginVO(user, userData));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造用户登录信息
|
|
|
+ *
|
|
|
+ * @param user : 用户
|
|
|
+ * @param userData : 信息
|
|
|
+ * @return : 返回结果
|
|
|
+ */
|
|
|
+ private UserLoginVO createUserLoginVO(User user, UserData userData) {
|
|
|
+ //获取token
|
|
|
+ String userToken = userTokenService.getUserToken(user.getId(), userData.getDeviceType());
|
|
|
//插入用户登录记录
|
|
|
- userLoginLogService.addUserLoginLog(userData.getIp(), user, gameId, 0);
|
|
|
+ userLoginLogService.addUserLoginLog(userData.getIp(), user, userData.getGameId(), 0);
|
|
|
+ //查询用户实名信息
|
|
|
+ UserCard userCard = userCardService.getOne(new LambdaQueryWrapper<UserCard>().eq(UserCard::getUserId, user.getId()));
|
|
|
//构造用户登录信息
|
|
|
- UserLoginVO userLoginVO = UserLoginVO.builder()
|
|
|
+ return UserLoginVO.builder()
|
|
|
.userId(user.getId())
|
|
|
.userName(user.getUsername())
|
|
|
.token(userToken)
|
|
|
.authentication(user.getAuthentication())
|
|
|
.bindPhone(Strings.isBlank(user.getMobile()) ? 0 : 1)
|
|
|
+ .hasOldPassword(Strings.isNotBlank(user.getPassword()))
|
|
|
+ .phoneNum(user.getShowPhoneNum())
|
|
|
+ .cardName(userCard == null ? null : userCard.getShowCardName())
|
|
|
+ .cardId(userCard == null ? null : userCard.getShowCardId())
|
|
|
.build();
|
|
|
- //返回登录信息
|
|
|
- return new ResultVO<>(userLoginVO);
|
|
|
}
|
|
|
|
|
|
/**
|