|
@@ -0,0 +1,78 @@
|
|
|
+package com.sqx.modules.userRealnameInfo.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.sqx.common.utils.Result;
|
|
|
+import com.sqx.modules.app.annotation.Login;
|
|
|
+import com.sqx.modules.common.service.CommonInfoService;
|
|
|
+import com.sqx.modules.userRealnameInfo.entity.UserRealnameInfo;
|
|
|
+import com.sqx.modules.userRealnameInfo.service.UserRealnameInfoService;
|
|
|
+import com.sqx.modules.utils.AESCBCWithRandomIV;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@Api(value = "实名认证", tags = {"实名认证"})
|
|
|
+@RequestMapping("/app/userRealnameInfo")
|
|
|
+public class UserRealnameInfoController {
|
|
|
+ @Resource
|
|
|
+ private UserRealnameInfoService userRealnameInfoService;
|
|
|
+ @Resource
|
|
|
+ private CommonInfoService commonInfoService;
|
|
|
+
|
|
|
+ @Login
|
|
|
+ @GetMapping("/selectByUserId")
|
|
|
+ @ApiOperation("查询实名认证信息")
|
|
|
+ public Result selectByUserId(@RequestAttribute("userId")Long userId, Integer isDriver){
|
|
|
+ String key = commonInfoService.findOne(819).getValue();
|
|
|
+ List<UserRealnameInfo> list = userRealnameInfoService.list(new QueryWrapper<UserRealnameInfo>().eq("user_id", userId).eq("is_driver", isDriver));
|
|
|
+ if (list.size() == 0){
|
|
|
+ UserRealnameInfo userRealnameInfo = new UserRealnameInfo();
|
|
|
+ userRealnameInfo.setUserId(userId);
|
|
|
+ userRealnameInfo.setVerifiedStatus(0);
|
|
|
+ return Result.success().put("data",userRealnameInfo);
|
|
|
+ }
|
|
|
+ //解密身份证号
|
|
|
+ String decrypt = null;
|
|
|
+ try {
|
|
|
+ decrypt = AESCBCWithRandomIV.decrypt(list.get(0).getIdCardNumber(), key);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //脱敏处理
|
|
|
+ list.get(0).setIdCardNumber(userRealnameInfoService.maskIdKeepFront(decrypt));
|
|
|
+ return Result.success().put("data",list.get(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Login
|
|
|
+ @PostMapping("/insertOrUpdate")
|
|
|
+ @ApiOperation("新增或修改实名认证信息")
|
|
|
+ public Result insertOrUpdate(@RequestAttribute("userId")Long userId, UserRealnameInfo userRealnameInfo){
|
|
|
+ String key = commonInfoService.findOne(819).getValue();
|
|
|
+ List<UserRealnameInfo> list = userRealnameInfoService.list(new QueryWrapper<UserRealnameInfo>().eq("user_id", userId).eq("is_driver", userRealnameInfo.getIsDriver()));
|
|
|
+ if (list.size() == 0){
|
|
|
+ userRealnameInfo.setUserId(userId);
|
|
|
+ String encrypt = null;
|
|
|
+ try {
|
|
|
+ encrypt = AESCBCWithRandomIV.encrypt(userRealnameInfo.getIdCardNumber(), key);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ userRealnameInfo.setIdCardNumber(encrypt);
|
|
|
+ userRealnameInfoService.insert(userRealnameInfo);
|
|
|
+ }else if (list.size() == 1){
|
|
|
+ userRealnameInfoService.update(userRealnameInfo);
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/updateRealnameInfo")
|
|
|
+ @ApiOperation("更新实名认证状态")
|
|
|
+ public Result updateRealnameInfo(UserRealnameInfo userRealnameInfo){
|
|
|
+ userRealnameInfoService.update(userRealnameInfo);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+}
|