2
0

feat: support kyc on user and system module

This commit is contained in:
zhangsz
2025-01-10 11:03:34 +08:00
parent 832b5a86a8
commit 55e7c22469
19 changed files with 405 additions and 40 deletions

View File

@@ -0,0 +1,79 @@
package org.wfc.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.system.domain.UKyc;
import org.wfc.system.domain.bo.UKycUserBo;
import org.wfc.system.domain.constant.KycStatusEnum;
import org.wfc.system.domain.vo.UKycUserVo;
import org.wfc.system.service.IUKycService;
import java.util.List;
/**
* <p>
* User Portal-User KYC table contorller
* </p>
*
* @author sys
* @since 2025-01-08
*/
@RestController
@RequestMapping("/kyc")
public class UKycController extends BaseController {
private static final Logger log = LoggerFactory.getLogger(UKycController.class);
@Autowired
private IUKycService uKycService;
@GetMapping("/page")
public TableDataInfo selectKycByUserId(UKycUserBo item) {
log.debug("item: {}", item);
startPage();
List<UKycUserVo> list = uKycService.selectKycByUserId(item);
return getDataTable(list);
}
@GetMapping("/list")
public AjaxResult list(UKycUserBo item) {
startPage();
List<UKycUserVo> list = uKycService.selectKycByUserId(item);
return success(list);
}
@GetMapping(value = "/{id}")
public AjaxResult getById(@PathVariable("id") Long id) {
return success(uKycService.getById(id));
}
@PutMapping("/approve")
public AjaxResult approve(@RequestBody UKyc uKyc) {
// set user kyc status to verified
uKyc.setStatus(KycStatusEnum.VERIFIED.getCode());
log.debug("uKyc: {}", uKyc);
return toAjax(uKycService.updateKycByUserId(uKyc));
}
@PutMapping("/reject")
public AjaxResult reject(@RequestBody UKyc uKyc) {
// set kyc request status to rejected and put the description in the database
uKyc.setStatus(KycStatusEnum.REJECTED.getCode());
return toAjax(uKycService.updateKycByUserId(uKyc));
}
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Long[] ids) {
// return toAjax(uKycService.removeByIds(CollUtil.newArrayList(ids)));
// }
}

View File

@@ -0,0 +1,48 @@
package org.wfc.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import org.wfc.common.mybatis.domain.BaseData;
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;
}

View File

@@ -0,0 +1,16 @@
package org.wfc.system.domain.bo;
import lombok.Data;
/**
* @description: Kyc User Bo
* @since: 2025-01-09
*/
@Data
public class UKycUserBo {
private Long userId;
private String userName;
private Integer status;
private String createTimeStart;
private String createTimeEnd;
}

View File

@@ -0,0 +1,24 @@
package org.wfc.system.domain.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @description: 证件类型枚举
* @since: 2025-01-08
*/
@Getter
@AllArgsConstructor
public enum IdTypeEnum {
DRIVERS_LICENSE(1, "driver's license"),
PASSPORT(2, "passport"),
RESIDENCE_PERMIT(3, "residence permit"),
STUDENT_ID(4, "student ID"),
MEDICARE_CARD(5, "medicare card"),
BIRTH_CERTIFICATE(6, "birth certificate");
private final Integer code;
private final String desc;
}

View File

@@ -0,0 +1,21 @@
package org.wfc.system.domain.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @description: KYC request status enum
* @since: 2025-01-08
*/
@Getter
@AllArgsConstructor
public enum KycStatusEnum {
VERIFIED(1, "verified"),
UNVERIFIED(2, "unverified"),
PENDING(3, "pending"),
REJECTED(4, "rejected");
private final Integer code;
private final String desc;
}

View File

@@ -0,0 +1,19 @@
package org.wfc.system.domain.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @description: User KYC status enum
* @since: 2025-01-08
*/
@Getter
@AllArgsConstructor
public enum UserKycStatusEnum {
VERIFIED(1, "verified"),
UNVERIFIED(2, "unverified");
private final Integer code;
private final String desc;
}

View File

@@ -0,0 +1,20 @@
package org.wfc.system.domain.vo;
import lombok.Data;
import org.wfc.system.domain.constant.IdTypeEnum;
import org.wfc.system.domain.constant.KycStatusEnum;
@Data
public class UKycUserVo {
private Long kycId;
private Long userId;
private String userName;
private String birthDate;
private IdTypeEnum idType;
private String idFile;
private String identifyPicture;
private KycStatusEnum status;
private String description;
private String createTime;
}

View File

@@ -0,0 +1,24 @@
package org.wfc.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Param;
import org.wfc.system.domain.UKyc;
import org.wfc.system.domain.vo.UKycUserVo;
import org.wfc.system.domain.bo.UKycUserBo;
/**
* <p>
* 用户平台-KYC表 Mapper 接口
* </p>
*
* @author sys
* @since 2025-01-08
*/
@DS("user")
public interface UKycMapper extends BaseMapper<UKyc> {
List<UKycUserVo> selectKycByUserId(@Param("item") UKycUserBo item);
public int updateKycByUserId(UKyc uKyc);
}

View File

@@ -0,0 +1,23 @@
package org.wfc.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import org.wfc.system.domain.UKyc;
import org.wfc.system.domain.bo.UKycUserBo;
import org.wfc.system.domain.vo.UKycUserVo;
/**
* <p>
* 用户平台-KYC表 服务类
* </p>
*
* @author sys
* @since 2025-01-08
*/
public interface IUKycService extends IService<UKyc> {
List<UKycUserVo> selectKycByUserId(UKycUserBo item);
public int updateKycByUserId(UKyc uKyc);
}

View File

@@ -0,0 +1,39 @@
package org.wfc.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.system.domain.UKyc;
import org.wfc.system.domain.vo.UKycUserVo;
import org.wfc.system.domain.bo.UKycUserBo;
import org.wfc.system.mapper.UKycMapper;
import org.wfc.system.service.IUKycService;
/**
* <p>
* 用户平台-KYC表 服务实现类
* </p>
*
* @author sys
* @since 2025-01-09
*/
@Service
public class UKycServiceImpl extends ServiceImpl<UKycMapper, UKyc> implements IUKycService {
@Autowired
private UKycMapper uKycMapper;
@Override
public List<UKycUserVo> selectKycByUserId(UKycUserBo item) {
return this.uKycMapper.selectKycByUserId(item);
}
@Override
public int updateKycByUserId(UKyc uKyc) {
return this.uKycMapper.updateKycByUserId(uKyc);
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.wfc.system.mapper.UKycMapper">
<select id="selectKycByUserId" resultType="org.wfc.system.domain.vo.UKycUserVo">
SELECT
k.kyc_id,
k.user_id,
u.user_name,
k.birth_date,
k.id_type,
k.id_file,
k.identify_picture,
k.`status`,
<!-- u.`kyc_status` as user_kyc_status, -->
k.create_time,
k.update_time
FROM
u_kyc k
LEFT JOIN u_user u ON u.user_id = k.user_id
WHERE
u.del_flag = 0
AND k.del_flag = 0
<if test="item.userId != null and item.userId != ''">
AND k.user_id = #{item.userId}
</if>
<if test="item.userName != null and item.userName != ''">
AND u.user_name like concat('%', #{item.userName}, '%')
</if>
<if test="item.userName != null and item.userName != ''">
AND u.user_name like concat('%', #{item.userName}, '%')
</if>
<if test="item.status != null and item.status != ''">
AND k.`status` = #{item.status}
</if>
<if test="item.createTimeStart != null and item.createTimeStart != ''">
AND k.create_time &gt;= #{item.createTimeStart}
</if>
<if test="item.createTimeEnd != null and item.createTimeEnd != ''">
AND k.create_time &lt;= #{item.createTimeEnd}
</if>
ORDER BY
k.create_time DESC
</select>
<update id="updateKycByUserId" parameterType="UKyc">
UPDATE u_kyc
<set>
<if test="status != null and status != 0">status = #{status},</if>
<if test="description != null and description != ''">description = #{description},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
WHERE user_id = #{userId}
</update>
</mapper>