增加认证接口
This commit is contained in:
5
pom.xml
5
pom.xml
@ -75,6 +75,11 @@
|
|||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-commons</artifactId>
|
<artifactId>spring-cloud-commons</artifactId>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ 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.AlipayMiniProgramRegRequest;
|
||||||
|
import com.sczx.user.dto.AuthRequest;
|
||||||
import com.sczx.user.dto.LoginResponse;
|
import com.sczx.user.dto.LoginResponse;
|
||||||
import com.sczx.user.dto.WxMiniProgramRegRequest;
|
import com.sczx.user.dto.WxMiniProgramRegRequest;
|
||||||
import com.sczx.user.service.IUserService;
|
import com.sczx.user.service.IUserService;
|
||||||
@ -11,6 +12,8 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
@Api(value = "登录控制器", tags = "注册登录")
|
@Api(value = "登录控制器", tags = "注册登录")
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
@RestController
|
@RestController
|
||||||
@ -67,4 +70,10 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "身份认证", notes = "身份认证")
|
||||||
|
@PostMapping("/authUser")
|
||||||
|
public Result<Boolean> authUser(@Valid @RequestBody AuthRequest authRequest) {
|
||||||
|
userService.authUser(authRequest);
|
||||||
|
return Result.ok(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/main/java/com/sczx/user/dto/AuthRequest.java
Normal file
32
src/main/java/com/sczx/user/dto/AuthRequest.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.sczx.user.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ApiModel(value = "AuthRequest对象", description = "认证请求对象")
|
||||||
|
@Data
|
||||||
|
public class AuthRequest {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id", required = false)
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@NotNull(message = "身份证号不能为空")
|
||||||
|
@ApiModelProperty("身份证号")
|
||||||
|
private String idNo;
|
||||||
|
|
||||||
|
@NotNull(message = "真实姓名不能为空")
|
||||||
|
@ApiModelProperty("身份证号")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@NotNull(message = "正面照片不能为空")
|
||||||
|
@ApiModelProperty("正面照片")
|
||||||
|
private String frontPhoto;
|
||||||
|
|
||||||
|
@NotNull(message = "背面照片不能为空")
|
||||||
|
@ApiModelProperty("背面照片")
|
||||||
|
private String backPhoto;
|
||||||
|
}
|
||||||
@ -58,6 +58,18 @@ public class BaseUserPO implements Serializable {
|
|||||||
@ApiModelProperty("是否认证0未认证1已认证")
|
@ApiModelProperty("是否认证0未认证1已认证")
|
||||||
private Integer authed;
|
private Integer authed;
|
||||||
|
|
||||||
|
@ApiModelProperty("身份证号")
|
||||||
|
private String idNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("身份证号")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("正面照片")
|
||||||
|
private String frontPhoto;
|
||||||
|
|
||||||
|
@ApiModelProperty("背面照片")
|
||||||
|
private String backPhoto;
|
||||||
|
|
||||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
package com.sczx.user.service;
|
package com.sczx.user.service;
|
||||||
|
|
||||||
import com.sczx.user.dto.AlipayMiniProgramRegRequest;
|
import com.sczx.user.dto.*;
|
||||||
import com.sczx.user.dto.LoginResponse;
|
|
||||||
import com.sczx.user.dto.SimpleUserInfoDTO;
|
|
||||||
import com.sczx.user.dto.WxMiniProgramRegRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: 张黎
|
* @Author: 张黎
|
||||||
@ -66,4 +63,10 @@ public interface IUserService {
|
|||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
SimpleUserInfoDTO getUserInfoByProgramId(String programId, String programType);
|
SimpleUserInfoDTO getUserInfoByProgramId(String programId, String programType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户认证
|
||||||
|
* @param authRequest 认证请求
|
||||||
|
*/
|
||||||
|
void authUser(AuthRequest authRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,11 @@ package com.sczx.user.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.nacos.common.utils.MD5Utils;
|
import com.alibaba.nacos.common.utils.MD5Utils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.sczx.user.common.enums.ApiErrorCode;
|
import com.sczx.user.common.enums.ApiErrorCode;
|
||||||
import com.sczx.user.common.enums.MiniProgramTypeEnum;
|
import com.sczx.user.common.enums.MiniProgramTypeEnum;
|
||||||
import com.sczx.user.convert.UserInfoConvert;
|
import com.sczx.user.convert.UserInfoConvert;
|
||||||
import com.sczx.user.dto.AlipayMiniProgramRegRequest;
|
import com.sczx.user.dto.*;
|
||||||
import com.sczx.user.dto.LoginResponse;
|
|
||||||
import com.sczx.user.dto.SimpleUserInfoDTO;
|
|
||||||
import com.sczx.user.dto.WxMiniProgramRegRequest;
|
|
||||||
import com.sczx.user.exception.BizException;
|
import com.sczx.user.exception.BizException;
|
||||||
import com.sczx.user.po.BaseUserPO;
|
import com.sczx.user.po.BaseUserPO;
|
||||||
import com.sczx.user.repository.BaseUserRepo;
|
import com.sczx.user.repository.BaseUserRepo;
|
||||||
@ -237,6 +235,21 @@ public class UserServiceImpl implements IUserService {
|
|||||||
return UserInfoConvert.INSTANCE.poToSimpleDTO(baseUserPO);
|
return UserInfoConvert.INSTANCE.poToSimpleDTO(baseUserPO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void authUser(AuthRequest authRequest) {
|
||||||
|
if(Objects.isNull(authRequest.getUserId())){
|
||||||
|
SimpleUserInfoDTO simpleUserInfoDTO = jwtUtil.getUserInfoFromToken();
|
||||||
|
authRequest.setUserId((long)simpleUserInfoDTO.getUserId());
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<BaseUserPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(BaseUserPO::getId, authRequest.getUserId());
|
||||||
|
updateWrapper.set(BaseUserPO::getIdNo, authRequest.getIdNo());
|
||||||
|
updateWrapper.set(BaseUserPO::getRealName, authRequest.getRealName());
|
||||||
|
updateWrapper.set(BaseUserPO::getFrontPhoto, authRequest.getFrontPhoto());
|
||||||
|
updateWrapper.set(BaseUserPO::getBackPhoto, authRequest.getBackPhoto());
|
||||||
|
baseUserRepo.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录信息
|
* 获取登录信息
|
||||||
* @param programId
|
* @param programId
|
||||||
|
|||||||
Reference in New Issue
Block a user