feat: user portal support kyc certification
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package org.wfc.user.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
import org.wfc.common.core.web.page.TableDataInfo;
|
||||
import org.wfc.common.log.annotation.Log;
|
||||
import org.wfc.common.log.enums.BusinessType;
|
||||
import org.wfc.common.security.annotation.RequiresPermissions;
|
||||
import org.wfc.user.domain.UKyc;
|
||||
import org.wfc.user.domain.vo.UKycUserVo;
|
||||
import org.wfc.user.service.IUKycService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户平台-账单表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author sys
|
||||
* @since 2025-01-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/kyc")
|
||||
public class UKycController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IUKycService uKycService;
|
||||
|
||||
@RequiresPermissions("Utem:kyc:query")
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo page() {
|
||||
startPage();
|
||||
List<UKycUserVo> list = uKycService.selectKycByUserId();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@RequiresPermissions("Utem:kyc:add")
|
||||
@Log(title = "User Management", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/verify")
|
||||
public AjaxResult add(@Validated @RequestBody UKyc uKyc) {
|
||||
return toAjax(uKycService.insertUserKyc(uKyc));
|
||||
}
|
||||
|
||||
@RequiresPermissions("Utem:kyc:edit")
|
||||
@Log(title = "User Management", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/verify")
|
||||
public AjaxResult edit(@Validated @RequestBody UKyc uKyc) {
|
||||
return toAjax(uKycService.updateUserKyc(uKyc));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.wfc.user.domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import org.wfc.common.mybatis.domain.BaseData;
|
||||
import org.wfc.user.domain.constant.IdTypeEnum;
|
||||
import org.wfc.user.domain.constant.KycRequestStatusEnum;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("u_kyc")
|
||||
@Schema(name = "UKyc", description = "User portal: u_kyc table")
|
||||
public class UKyc extends BaseData {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "KYC ID")
|
||||
private Long kycId;
|
||||
|
||||
@Schema(description = "User ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "Birth Date")
|
||||
private String birthDate;
|
||||
|
||||
@Schema(description = "Identify Type")
|
||||
private Integer idType;
|
||||
|
||||
@Schema(description = "Identify File")
|
||||
private String idFile;
|
||||
|
||||
@Schema(description = "Identify Picture")
|
||||
private String identifyPicture;
|
||||
|
||||
@Schema(description = "Status")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "Description")
|
||||
private String description;
|
||||
|
||||
// @Schema(description = "Create Time")
|
||||
// private LocalDateTime createTime;
|
||||
|
||||
// @Schema(description = "Update Time")
|
||||
// private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.wfc.user.domain.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @description: 证件类型枚举
|
||||
* @since: 2025-01-08
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum IdTypeEnum {
|
||||
|
||||
DRIVERS_LICENSE(0, "driver's license"),
|
||||
PASSPORT(1, "passport"),
|
||||
RESIDENCE_PERMIT(2, "residence permit"),
|
||||
STUDENT_ID(3, "student ID"),
|
||||
MEDICARE_CARD(4, "medicare card"),
|
||||
BIRTH_CERTIFICATE(5, "birth certificate");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.wfc.user.domain.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @description: KYC request status enum
|
||||
* @since: 2025-01-08
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum KycRequestStatusEnum {
|
||||
|
||||
APPROVED(0, "approved"),
|
||||
REJECTED(1, "rejected"),
|
||||
PENDING(2, "pending");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.wfc.user.domain.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @description: User KYC status enum
|
||||
* @since: 2025-01-08
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum UserKycStatusEnum {
|
||||
|
||||
VERIFIED(0, "verified"),
|
||||
UNVERIFIED(1, "unverified");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.wfc.user.domain.vo;
|
||||
|
||||
import org.wfc.user.domain.constant.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UKycUserVo {
|
||||
|
||||
@Schema(description = "KYC ID")
|
||||
private Long kycId;
|
||||
|
||||
@Schema(description = "User ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "Real Name")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "Birth Date")
|
||||
private String birthDate;
|
||||
|
||||
@Schema(description = "ID Type")
|
||||
private IdTypeEnum idType;
|
||||
|
||||
@Schema(description = "ID File")
|
||||
private String idFile;
|
||||
|
||||
@Schema(description = "Identify Picture")
|
||||
private String identifyPicture;
|
||||
|
||||
@Schema(description = "KYC Request Status")
|
||||
private KycRequestStatusEnum kycRequestStatus;
|
||||
|
||||
@Schema(description = "User KYC Status")
|
||||
private UserKycStatusEnum userKycStatus;
|
||||
|
||||
@Schema(description = "Create Time")
|
||||
private String createTime;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.wfc.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.wfc.user.domain.UKyc;
|
||||
import org.wfc.user.domain.vo.UKycUserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户平台-KYC表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author sys
|
||||
* @since 2025-01-08
|
||||
*/
|
||||
public interface UKycMapper extends BaseMapper<UKyc> {
|
||||
|
||||
public int isExistUserKyc(Long userId);
|
||||
|
||||
public int insertUserKyc(UKyc uKyc);
|
||||
|
||||
public int updateUserKyc(UKyc uKyc);
|
||||
|
||||
List<UKycUserVo> selectKycByUserId(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.wfc.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.wfc.user.domain.UKyc;
|
||||
import org.wfc.user.domain.vo.UKycUserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户平台-KYC表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author sys
|
||||
* @since 2025-01-08
|
||||
*/
|
||||
public interface IUKycService extends IService<UKyc> {
|
||||
|
||||
List<UKycUserVo> selectKycByUserId();
|
||||
|
||||
public int isExistUserKyc(Long userId);
|
||||
|
||||
public int insertUserKyc(UKyc uKyc);
|
||||
|
||||
public int updateUserKyc(UKyc uKyc);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.wfc.user.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.wfc.common.core.domain.LoginUser;
|
||||
import org.wfc.common.security.utils.SecurityUtils;
|
||||
import org.wfc.user.domain.UKyc;
|
||||
import org.wfc.user.domain.constant.IdTypeEnum;
|
||||
import org.wfc.user.domain.constant.KycRequestStatusEnum;
|
||||
import org.wfc.user.domain.vo.UKycUserVo;
|
||||
import org.wfc.user.mapper.UKycMapper;
|
||||
import org.wfc.user.mapper.UUserMapper;
|
||||
import org.wfc.user.service.IUKycService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户平台-KYC表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author sys
|
||||
* @since 2025-01-08
|
||||
*/
|
||||
@Service
|
||||
public class UKycServiceImpl extends ServiceImpl<UKycMapper, UKyc> implements IUKycService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UKycServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private UKycMapper uKycMapper;
|
||||
|
||||
// @Override
|
||||
// public List<UKycUserVo> selectKycByUserId(Long userId) {
|
||||
// return this.baseMapper.selectKycByUserId(userId);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<UKycUserVo> selectKycByUserId() {
|
||||
LoginUser<Object> loginUser = SecurityUtils.getLoginUser();
|
||||
return this.uKycMapper.selectKycByUserId(loginUser.getUserid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isExistUserKyc(Long userId) {
|
||||
return this.uKycMapper.isExistUserKyc(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertUserKyc(UKyc uKyc) {
|
||||
// // Convert string to enum
|
||||
// uKyc.setIdType(uKyc.getIdType());
|
||||
// uKyc.setStatus(uKyc.getStatus());
|
||||
|
||||
log.debug("uKyc: {}", uKyc);
|
||||
if (this.uKycMapper.isExistUserKyc(uKyc.getUserId()) == 0) {
|
||||
return this.uKycMapper.insertUserKyc(uKyc);
|
||||
} else {
|
||||
return this.uKycMapper.updateUserKyc(uKyc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUserKyc(UKyc uKyc) {
|
||||
return this.uKycMapper.updateUserKyc(uKyc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user