Forráskód Böngészése

feat : 接口修改

bilingfeng 2 éve
szülő
commit
9a0d21f9fb

+ 24 - 0
game-module/game-sdk/src/main/java/com/zanxiang/sdk/domain/vo/UserLoginVO.java

@@ -52,4 +52,28 @@ public class UserLoginVO {
      */
     @ApiModelProperty(notes = "是否绑定手机, 0 : 未绑定, 1:已绑定")
     private Integer bindPhone;
+
+    /**
+     * 是否存在旧账号
+     */
+    @ApiModelProperty(notes = "是否存在旧密码")
+    private Boolean hasOldPassword;
+
+    /**
+     * 用户手机号
+     */
+    @ApiModelProperty(notes = "用户手机号")
+    private String phoneNum;
+
+    /**
+     * 用户真实姓名
+     */
+    @ApiModelProperty(notes = "用户真实姓名")
+    private String cardName;
+
+    /**
+     * 用户身份证号
+     */
+    @ApiModelProperty(notes = "用户身份证号")
+    private String cardId;
 }

+ 33 - 31
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/LoginServiceImpl.java

@@ -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);
     }
 
     /**

+ 4 - 18
game-module/game-sdk/src/main/java/com/zanxiang/sdk/service/Impl/UserServiceImpl.java

@@ -194,32 +194,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         Long userId = userData.getUserId();
         //查询用户信息
         User user = this.getById(userId);
-        String mobile = user.getMobile();
-        //手机号
-        String phoneNum = null;
-        if (Strings.isNotBlank(mobile)) {
-            phoneNum = mobile.substring(0, 3) + "****" + mobile.substring(mobile.length() - 4);
-        }
-        //真实姓名
-        String cardName = null;
-        //身份证信息
-        String cardId = null;
         //查询用户实名信息
         UserCard userCard = userCardService.getOne(new LambdaQueryWrapper<UserCard>().eq(UserCard::getUserId, userId));
-        if (userCard != null && Strings.isNotBlank(userCard.getCardId()) && Strings.isNotBlank(userCard.getCardName())) {
-            cardName = "**" + userCard.getCardName().substring(userCard.getCardName().length() - 1);
-            cardId = userCard.getCardId().substring(0, 6) + "********" + userCard.getCardId().substring(userCard.getCardId().length() - 4);
-        }
         //构造用户登录信息
         return UserVO.builder()
                 .userId(user.getId())
                 .userName(user.getUsername())
                 .authentication(user.getAuthentication())
-                .bindPhone(Strings.isBlank(phoneNum) ? 0 : 1)
+                .bindPhone(Strings.isBlank(user.getMobile()) ? 0 : 1)
                 .hasOldPassword(Strings.isNotBlank(user.getPassword()))
-                .phoneNum(phoneNum)
-                .cardName(cardName)
-                .cardId(cardId)
+                .phoneNum(user.getShowPhoneNum())
+                .cardName(userCard == null ? null : userCard.getShowCardName())
+                .cardId(userCard == null ? null : userCard.getShowCardId())
                 .build();
     }