Compare commits
6 Commits
cb44f6839f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1daccbd03b | |||
| a043aa9780 | |||
| 785caaeefc | |||
| 5a684edca6 | |||
| 846498d2df | |||
| 5b325963dc |
@ -4,6 +4,7 @@ package com.sczx.user.config;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
|
@Profile("!prod") // 除了prod环境外都启用
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi() {
|
public Docket createRestApi() {
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
package com.sczx.user.controller;
|
package com.sczx.user.controller;
|
||||||
|
|
||||||
import com.sczx.user.common.Result;
|
import com.sczx.user.common.Result;
|
||||||
import com.sczx.user.dto.AlipayMiniProgramRegRequest;
|
import com.sczx.user.dto.*;
|
||||||
import com.sczx.user.dto.AuthRequest;
|
|
||||||
import com.sczx.user.dto.LoginResponse;
|
|
||||||
import com.sczx.user.dto.WxMiniProgramRegRequest;
|
|
||||||
import com.sczx.user.service.IUserService;
|
import com.sczx.user.service.IUserService;
|
||||||
import com.sczx.user.util.JwtUtil;
|
import com.sczx.user.util.JwtUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -82,4 +79,10 @@ public class AuthController {
|
|||||||
public Result<LoginResponse> getLoginTokenByMobile(@RequestParam("mobile") String mobile) {;
|
public Result<LoginResponse> getLoginTokenByMobile(@RequestParam("mobile") String mobile) {;
|
||||||
return Result.ok(userService.getLoginTokenByMobile(mobile));
|
return Result.ok(userService.getLoginTokenByMobile(mobile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据手机号获取用户信息", notes = "根据手机号获取用户信息")
|
||||||
|
@GetMapping("/getUInfoByMobile")
|
||||||
|
public Result<SimpleUserInfoDTO> getUInfoByMobile(@RequestParam("mobile") String mobile) {;
|
||||||
|
return Result.ok(userService.getUserInfoByMobile(mobile));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,4 +38,10 @@ public class SimpleUserInfoDTO {
|
|||||||
@ApiModelProperty("是否认证0未认证1已认证")
|
@ApiModelProperty("是否认证0未认证1已认证")
|
||||||
private Integer authed;
|
private Integer authed;
|
||||||
|
|
||||||
|
@ApiModelProperty("身份证号")
|
||||||
|
private String idNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("实名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class BaseUserPO implements Serializable {
|
|||||||
@ApiModelProperty("身份证号")
|
@ApiModelProperty("身份证号")
|
||||||
private String idNo;
|
private String idNo;
|
||||||
|
|
||||||
@ApiModelProperty("身份证号")
|
@ApiModelProperty("实名")
|
||||||
private String realName;
|
private String realName;
|
||||||
|
|
||||||
@ApiModelProperty("正面照片")
|
@ApiModelProperty("正面照片")
|
||||||
|
|||||||
@ -76,4 +76,11 @@ public interface IUserService {
|
|||||||
* @return 登录token
|
* @return 登录token
|
||||||
*/
|
*/
|
||||||
LoginResponse getLoginTokenByMobile(String mobile);
|
LoginResponse getLoginTokenByMobile(String mobile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据手机号获取用户信息
|
||||||
|
* @param mobile
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SimpleUserInfoDTO getUserInfoByMobile(String mobile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,7 +175,7 @@ public class UserServiceImpl implements IUserService {
|
|||||||
|
|
||||||
//先根据openid查询用户,如果有则直接返回登录信息
|
//先根据openid查询用户,如果有则直接返回登录信息
|
||||||
LambdaQueryWrapper<BaseUserPO> queryByOpenIdWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseUserPO> queryByOpenIdWrapper = new LambdaQueryWrapper<>();
|
||||||
queryByOpenIdWrapper.eq(BaseUserPO::getWechatOpenid, openid).last(" limit 1");
|
queryByOpenIdWrapper.eq(BaseUserPO::getWechatOpenid, openid).eq(BaseUserPO::getDelFlag, "0").last(" limit 1");
|
||||||
BaseUserPO baseUserPO = baseUserRepo.getOne(queryByOpenIdWrapper);
|
BaseUserPO baseUserPO = baseUserRepo.getOne(queryByOpenIdWrapper);
|
||||||
if(Objects.nonNull(baseUserPO)){
|
if(Objects.nonNull(baseUserPO)){
|
||||||
return getLoginResponse(baseUserPO,MiniProgramTypeEnum.WECHAT);
|
return getLoginResponse(baseUserPO,MiniProgramTypeEnum.WECHAT);
|
||||||
@ -195,6 +195,7 @@ public class UserServiceImpl implements IUserService {
|
|||||||
boolean isNewUser = false;
|
boolean isNewUser = false;
|
||||||
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(BaseUserPO::getPhoneNumber, phoneNumber);
|
queryWrapper.eq(BaseUserPO::getPhoneNumber, phoneNumber);
|
||||||
|
queryWrapper.eq(BaseUserPO::getDelFlag, "0");
|
||||||
baseUserPO = baseUserRepo.getOne(queryWrapper);
|
baseUserPO = baseUserRepo.getOne(queryWrapper);
|
||||||
if(Objects.isNull(baseUserPO)){
|
if(Objects.isNull(baseUserPO)){
|
||||||
baseUserPO = new BaseUserPO();
|
baseUserPO = new BaseUserPO();
|
||||||
@ -260,7 +261,7 @@ public class UserServiceImpl implements IUserService {
|
|||||||
|
|
||||||
// 3. 查询用户是否存在
|
// 3. 查询用户是否存在
|
||||||
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(BaseUserPO::getPhoneNumber, phoneNumber);
|
queryWrapper.eq(BaseUserPO::getPhoneNumber, phoneNumber).eq(BaseUserPO::getDelFlag, "0");
|
||||||
BaseUserPO baseUserPO = baseUserRepo.getOne(queryWrapper);
|
BaseUserPO baseUserPO = baseUserRepo.getOne(queryWrapper);
|
||||||
|
|
||||||
boolean isNewUser = false;
|
boolean isNewUser = false;
|
||||||
@ -319,9 +320,9 @@ public class UserServiceImpl implements IUserService {
|
|||||||
|
|
||||||
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if(MiniProgramTypeEnum.WECHAT.getType().equalsIgnoreCase(programType)){
|
if(MiniProgramTypeEnum.WECHAT.getType().equalsIgnoreCase(programType)){
|
||||||
queryWrapper.eq(BaseUserPO::getWechatOpenid, programId).last(" limit 1");
|
queryWrapper.eq(BaseUserPO::getWechatOpenid, programId).eq(BaseUserPO::getDelFlag, "0").last(" limit 1");
|
||||||
}else {
|
}else {
|
||||||
queryWrapper.eq(BaseUserPO::getAlipayUserid, programId).last(" limit 1");
|
queryWrapper.eq(BaseUserPO::getAlipayUserid, programId).eq(BaseUserPO::getDelFlag, "0").last(" limit 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseUserPO baseUserPO = baseUserRepo.getOne(queryWrapper);
|
BaseUserPO baseUserPO = baseUserRepo.getOne(queryWrapper);
|
||||||
@ -343,6 +344,10 @@ public class UserServiceImpl implements IUserService {
|
|||||||
updateWrapper.set(BaseUserPO::getBackPhoto, authRequest.getBackPhoto());
|
updateWrapper.set(BaseUserPO::getBackPhoto, authRequest.getBackPhoto());
|
||||||
updateWrapper.set(BaseUserPO::getAuthed, 1);
|
updateWrapper.set(BaseUserPO::getAuthed, 1);
|
||||||
baseUserRepo.update(updateWrapper);
|
baseUserRepo.update(updateWrapper);
|
||||||
|
// 推送用户ID
|
||||||
|
ThreadPoolUtils.getThreadPool().execute(() -> {
|
||||||
|
syncInteg.sendUserInfoToBattery(authRequest.getUserId().toString());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -353,6 +358,14 @@ public class UserServiceImpl implements IUserService {
|
|||||||
return getLoginResponse(baseUserPO,MiniProgramTypeEnum.WECHAT);
|
return getLoginResponse(baseUserPO,MiniProgramTypeEnum.WECHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SimpleUserInfoDTO getUserInfoByMobile(String mobile) {
|
||||||
|
LambdaQueryWrapper<BaseUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BaseUserPO::getPhoneNumber, mobile).last( " limit 1");
|
||||||
|
BaseUserPO baseUserPO = baseUserRepo.getOne(queryWrapper);
|
||||||
|
return UserInfoConvert.INSTANCE.poToSimpleDTO(baseUserPO);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录信息
|
* 获取登录信息
|
||||||
* @param programId
|
* @param programId
|
||||||
@ -380,6 +393,9 @@ public class UserServiceImpl implements IUserService {
|
|||||||
*/
|
*/
|
||||||
private LoginResponse getLoginResponse(BaseUserPO baseUserPO,MiniProgramTypeEnum miniProgramTypeEnum) {
|
private LoginResponse getLoginResponse(BaseUserPO baseUserPO,MiniProgramTypeEnum miniProgramTypeEnum) {
|
||||||
SimpleUserInfoDTO simpleUserInfoDTO = UserInfoConvert.INSTANCE.poToSimpleDTO(baseUserPO);
|
SimpleUserInfoDTO simpleUserInfoDTO = UserInfoConvert.INSTANCE.poToSimpleDTO(baseUserPO);
|
||||||
|
if(StringUtils.isNotBlank(baseUserPO.getRealName())){
|
||||||
|
simpleUserInfoDTO.setUserName(baseUserPO.getRealName());
|
||||||
|
}
|
||||||
if(Objects.isNull(simpleUserInfoDTO)){
|
if(Objects.isNull(simpleUserInfoDTO)){
|
||||||
throw new BizException(ApiErrorCode.NO_REG);
|
throw new BizException(ApiErrorCode.NO_REG);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package com.sczx.user.thirdpart.integration;
|
package com.sczx.user.thirdpart.integration;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.AlipayClient;
|
import com.alipay.api.AlipayClient;
|
||||||
@ -148,7 +149,7 @@ public class AlipayInteg {
|
|||||||
tokenRequest.setCode(authCode);
|
tokenRequest.setCode(authCode);
|
||||||
log.info("获取支付宝access_token请求参数: {}", tokenRequest);
|
log.info("获取支付宝access_token请求参数: {}", tokenRequest);
|
||||||
AlipaySystemOauthTokenResponse tokenResponse = alipayClient.certificateExecute(tokenRequest);
|
AlipaySystemOauthTokenResponse tokenResponse = alipayClient.certificateExecute(tokenRequest);
|
||||||
log.info("获取支付宝access_token返回结果: {}", tokenResponse.getBody());
|
log.info("获取支付宝access_token返回结果: {}", JSON.toJSONString(tokenResponse));
|
||||||
|
|
||||||
if (!tokenResponse.isSuccess()) {
|
if (!tokenResponse.isSuccess()) {
|
||||||
log.error("获取支付宝access_token失败: {}", tokenResponse.getSubMsg());
|
log.error("获取支付宝access_token失败: {}", tokenResponse.getSubMsg());
|
||||||
|
|||||||
Reference in New Issue
Block a user