未注册登录返回结果
This commit is contained in:
@ -17,7 +17,8 @@ public enum ApiErrorCode implements IApiCode {
|
||||
NOT_FOUND("404000", "你请求的路径不存在"),
|
||||
UNAUTHORIZED("404001", "非法访问"),
|
||||
FAIL("500000", "操作失败"),
|
||||
INNER_ERROR("500001", "服务器内部异常");
|
||||
INNER_ERROR("500001", "服务器内部异常"),
|
||||
NO_REG("600001", "用户未注册");
|
||||
|
||||
private final String code;
|
||||
private final String msg;
|
||||
|
||||
@ -2,6 +2,7 @@ package com.sczx.user.service.impl;
|
||||
|
||||
import com.alibaba.nacos.common.utils.MD5Utils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sczx.user.common.enums.ApiErrorCode;
|
||||
import com.sczx.user.common.enums.MiniProgramTypeEnum;
|
||||
import com.sczx.user.convert.UserInfoConvert;
|
||||
import com.sczx.user.dto.LoginResponse;
|
||||
@ -13,7 +14,7 @@ import com.sczx.user.repository.BaseUserRepo;
|
||||
import com.sczx.user.service.IUserService;
|
||||
import com.sczx.user.thirdpart.dto.WechatDecryptedPhoneInfo;
|
||||
import com.sczx.user.thirdpart.dto.WechatMiniProgramResponse;
|
||||
import com.sczx.user.thirdpart.integ.WeichatInteg;
|
||||
import com.sczx.user.thirdpart.integration.WeichatInteg;
|
||||
import com.sczx.user.util.JwtUtil;
|
||||
import com.sczx.user.util.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -173,6 +174,9 @@ public class UserServiceImpl implements IUserService {
|
||||
*/
|
||||
private LoginResponse getLoginResponse(String programId, String programType) {
|
||||
SimpleUserInfoDTO simpleUserInfoDTO = getUserInfoByProgramId(programId, programType);
|
||||
if(Objects.isNull(simpleUserInfoDTO)){
|
||||
throw new BizException(ApiErrorCode.NO_REG);
|
||||
}
|
||||
|
||||
String token = jwtUtil.generateToken(simpleUserInfoDTO, simpleUserInfoDTO.getUserName());
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.sczx.user.thirdpart.integ;
|
||||
package com.sczx.user.thirdpart.integration;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sczx.user.exception.BizException;
|
||||
@ -43,7 +43,9 @@ public class WeichatInteg {
|
||||
|
||||
try {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
log.info("获取微信WechatMiniProgramResponse请求:{}", url);
|
||||
String response = restTemplate.getForObject(url, String.class);
|
||||
log.info("获取微信WechatMiniProgramResponse响应:{}", response);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.readValue(response, WechatMiniProgramResponse.class);
|
||||
@ -198,7 +200,9 @@ public class WeichatInteg {
|
||||
|
||||
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(requestBody, headers);
|
||||
|
||||
log.info("请求微信获取用户手机信息接口,url:{}, requestBody:{}", url, requestBody);
|
||||
String response = restTemplate.postForObject(url, requestEntity, String.class);
|
||||
log.info("微信获取用户手机信息接口返回结果,response:{}", response);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> resultMap = objectMapper.readValue(response, Map.class);
|
||||
Reference in New Issue
Block a user