|
@@ -3,7 +3,6 @@ package com.zanxiang.sdk.service.Impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.zanxiang.common.domain.ResultVO;
|
|
|
import com.zanxiang.common.enums.AccountStatusEnum;
|
|
|
-import com.zanxiang.common.enums.DeviceTypeEnum;
|
|
|
import com.zanxiang.common.enums.HttpStatusEnum;
|
|
|
import com.zanxiang.common.enums.SmsTypeEnum;
|
|
|
import com.zanxiang.common.exception.BaseException;
|
|
@@ -89,16 +88,17 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
/**
|
|
|
* 用户名注册或者登录
|
|
|
*
|
|
|
- * @param param : 注册登录参数
|
|
|
- * @param request : 请求信息
|
|
|
+ * @param param : 注册登录参数
|
|
|
+ * @param userData : 用户信息
|
|
|
* @return : 返回用户登录信息
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResultVO<UserLoginVO> loginPassword(LoginPasswordParam param, HttpServletRequest request) {
|
|
|
+ public ResultVO<UserLoginVO> loginPassword(LoginPasswordParam param, UserData userData) {
|
|
|
String username = param.getUsername();
|
|
|
String password = param.getPassword();
|
|
|
- Long gameId = Long.valueOf(request.getHeader("gameId"));
|
|
|
+ Long gameId = userData.getGameId();
|
|
|
+ Integer deviceType = userData.getDeviceType();
|
|
|
Integer type = param.getType();
|
|
|
//用户信息
|
|
|
User user;
|
|
@@ -128,7 +128,7 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
.gameId(gameId)
|
|
|
.username(username)
|
|
|
.password(RegisterUtil.cmfPassword(password))
|
|
|
- .deviceType(DeviceTypeEnum.DEVICE_TYPE_ANDROID.getDeviceType())
|
|
|
+ .deviceType(deviceType)
|
|
|
.status(AccountStatusEnum.NORMAL_STATUS.getStatus())
|
|
|
.authentication(0)
|
|
|
.createTime(LocalDateTime.now())
|
|
@@ -136,12 +136,10 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
.build();
|
|
|
userService.save(user);
|
|
|
}
|
|
|
- //登录的ip
|
|
|
- String realIp = IpUtils.getRealIp(request);
|
|
|
//插入用户登录记录
|
|
|
- userLoginLogService.addUserLoginLog(realIp, user, gameId, 0);
|
|
|
+ userLoginLogService.addUserLoginLog(userData.getIp(), user, gameId, 0);
|
|
|
//验证通过, 获取token
|
|
|
- String userToken = userTokenService.getUserToken(user.getId(), DeviceTypeEnum.DEVICE_TYPE_ANDROID.getDeviceType());
|
|
|
+ String userToken = userTokenService.getUserToken(user.getId(), deviceType);
|
|
|
//构造用户登录信息
|
|
|
UserLoginVO userLoginVO = UserLoginVO.builder()
|
|
|
.userId(user.getId())
|
|
@@ -157,16 +155,17 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
/**
|
|
|
* 手机号登录
|
|
|
*
|
|
|
- * @param param : 手机号登录参数
|
|
|
- * @param request : 请求信息
|
|
|
+ * @param param : 手机号登录参数
|
|
|
+ * @param userData : 用户信息
|
|
|
* @return : 返回登录信息
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResultVO<UserLoginVO> loginMobile(LoginMobileParam param, HttpServletRequest request) {
|
|
|
+ public ResultVO<UserLoginVO> loginMobile(LoginMobileParam param, UserData userData) {
|
|
|
String mobile = param.getMobile();
|
|
|
String code = param.getCode();
|
|
|
- Long gameId = Long.valueOf(request.getHeader("gameId"));
|
|
|
+ Long gameId = userData.getGameId();
|
|
|
+ Integer deviceType = userData.getDeviceType();
|
|
|
//验证码校验
|
|
|
HttpStatusEnum httpStatusEnum = smsService.smsCheck(SmsTypeEnum.SMS_REG.getType(), mobile, code);
|
|
|
//验证不通过, 返回
|
|
@@ -180,7 +179,7 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
user = User.builder()
|
|
|
.gameId(gameId)
|
|
|
.mobile(mobile)
|
|
|
- .deviceType(DeviceTypeEnum.DEVICE_TYPE_ANDROID.getDeviceType())
|
|
|
+ .deviceType(deviceType)
|
|
|
.status(AccountStatusEnum.NORMAL_STATUS.getStatus())
|
|
|
.authentication(0)
|
|
|
.createTime(LocalDateTime.now())
|
|
@@ -194,11 +193,9 @@ public class LoginServiceImpl implements RegisterLoginService {
|
|
|
}
|
|
|
}
|
|
|
//验证通过, 获取token
|
|
|
- String userToken = userTokenService.getUserToken(user.getId(), DeviceTypeEnum.DEVICE_TYPE_ANDROID.getDeviceType());
|
|
|
- //登录的ip
|
|
|
- String realIp = IpUtils.getRealIp(request);
|
|
|
+ String userToken = userTokenService.getUserToken(user.getId(), deviceType);
|
|
|
//插入用户登录记录
|
|
|
- userLoginLogService.addUserLoginLog(realIp, user, gameId, 0);
|
|
|
+ userLoginLogService.addUserLoginLog(userData.getIp(), user, gameId, 0);
|
|
|
//构造用户登录信息
|
|
|
UserLoginVO userLoginVO = UserLoginVO.builder()
|
|
|
.userId(user.getId())
|