init
This commit is contained in:
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
58
db/聊天功能.sql
Normal file
58
db/聊天功能.sql
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
CREATE TABLE "xs_chat"
|
||||||
|
(
|
||||||
|
"id" BIGINT IDENTITY(1, 1) NOT NULL PRIMARY KEY,
|
||||||
|
"org_id" BIGINT,
|
||||||
|
"org_user_id" BIGINT,
|
||||||
|
"person_user_id" BIGINT,
|
||||||
|
"type" VARCHAR(32),
|
||||||
|
"status" TINYINT,
|
||||||
|
"deleted" BIT DEFAULT 0 NOT NULL,
|
||||||
|
"create_by" BIGINT NOT NULL,
|
||||||
|
"create_time" TIMESTAMP(0) NOT NULL,
|
||||||
|
"update_by" BIGINT,
|
||||||
|
"update_time" TIMESTAMP(0),
|
||||||
|
"proxy_by" BIGINT
|
||||||
|
) ;
|
||||||
|
|
||||||
|
COMMENT ON TABLE "xs_chat" IS '聊天表';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."org_id" IS '机构id';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."org_user_id" IS '机构用户id';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."person_user_id" IS '个人用户id';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."type" IS '类型(chat_type)';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."status" IS '状态:1有效,2关闭';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."create_by" IS '创建人';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."create_time" IS '创建时间';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."deleted" IS '是否逻辑删除';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."proxy_by" IS '代理人';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."update_by" IS '更新人';
|
||||||
|
COMMENT ON COLUMN "xs_chat"."update_time" IS '更新时间';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "xs_chat_msg"
|
||||||
|
(
|
||||||
|
"id" BIGINT IDENTITY(1, 1) NOT NULL PRIMARY KEY,
|
||||||
|
"chat_id" BIGINT,
|
||||||
|
"sender_id" BIGINT,
|
||||||
|
"msg_type" VARCHAR(16),
|
||||||
|
"content" VARCHAR(1024),
|
||||||
|
"msg_status" TINYINT,
|
||||||
|
"deleted" BIT DEFAULT 0 NOT NULL,
|
||||||
|
"create_by" BIGINT NOT NULL,
|
||||||
|
"create_time" TIMESTAMP(0) NOT NULL,
|
||||||
|
"update_by" BIGINT,
|
||||||
|
"update_time" TIMESTAMP(0),
|
||||||
|
"proxy_by" BIGINT
|
||||||
|
) ;
|
||||||
|
COMMENT ON TABLE "xs_chat_msg" IS '聊天消息表';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."chat_id" IS '聊天id';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."sender_id" IS '发送用户id';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."msg_type" IS '消息类型(chat_msg_type):text等';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."content" IS '个人用户id';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."msg_status" IS '消息状态:1未读,2已读';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."create_by" IS '创建人';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."create_time" IS '创建时间';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."deleted" IS '是否逻辑删除';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."proxy_by" IS '代理人';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."update_by" IS '更新人';
|
||||||
|
COMMENT ON COLUMN "xs_chat_msg"."update_time" IS '更新时间';
|
||||||
408
pom.xml
Normal file
408
pom.xml
Normal file
@@ -0,0 +1,408 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
|
<relativePath />
|
||||||
|
</parent>
|
||||||
|
<groupId>com.newyetai</groupId>
|
||||||
|
<artifactId>alita-bjy-uygur</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--引入AOP依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>18.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工具包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
<version>3.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
<version>4.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-jdk8</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>${org.mapstruct.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 使用org.springframework.data.annotation下的注解 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- freemarker -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.freemarker</groupId>
|
||||||
|
<artifactId>freemarker</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>2.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 加解密BC -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
<version>1.55</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 配置加密 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--达梦数据库驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dameng</groupId>
|
||||||
|
<artifactId>Dm8JdbcDriver18</artifactId>
|
||||||
|
<version>8.1.1.49</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--mybatis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--pagehelper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- rabbitmq -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- redis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>3.15.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency> <groupId>org.redisson</groupId> <artifactId>redisson-spring-data-21</artifactId>
|
||||||
|
<version>3.11.0</version> </dependency> <dependency> <groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId> <version>3.11.0</version> </dependency> -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.16</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- pdfbox -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox</artifactId>
|
||||||
|
<version>2.0.20</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>fontbox</artifactId>
|
||||||
|
<version>2.0.20</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spire.Pdf -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>e-iceblue</groupId>
|
||||||
|
<artifactId>spire.pdf</artifactId>
|
||||||
|
<version>3.7.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itextpdf</artifactId>
|
||||||
|
<version>5.5.11</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itext-asian</artifactId>
|
||||||
|
<version>5.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- security -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- oauth2 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- sdk -->
|
||||||
|
<!-- 阿里云sms -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<version>4.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 腾讯云sdk -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tencentcloudapi</groupId>
|
||||||
|
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||||
|
<version>3.1.100</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 钉钉机器人 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 百度sdk -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baidu.aip</groupId>
|
||||||
|
<artifactId>java-sdk</artifactId>
|
||||||
|
<version>4.15.3</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 敏感词检测 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.toolgood</groupId>
|
||||||
|
<artifactId>toolgood-words</artifactId>
|
||||||
|
<version>3.1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.spatial4j</groupId>
|
||||||
|
<artifactId>spatial4j</artifactId>
|
||||||
|
<version>0.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.squareup.okio/okio -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okio</groupId>
|
||||||
|
<artifactId>okio</artifactId>
|
||||||
|
<version>2.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>ws.schild</groupId>
|
||||||
|
<artifactId>jave-core</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Linux 环境 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ws.schild</groupId>
|
||||||
|
<artifactId>jave-nativebin-linux64</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MacOS 环境 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ws.schild</groupId>
|
||||||
|
<artifactId>jave-nativebin-osx64</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Win64 环境 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ws.schild</groupId>
|
||||||
|
<artifactId>jave-nativebin-win64</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
<includes>
|
||||||
|
<!--指定打包的文件格式 -->
|
||||||
|
<include>**/*.xml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>application.yml</include>
|
||||||
|
<include>bootstrap.yml</include>
|
||||||
|
<include>${project.artifactId}-${profile.active}.yaml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<!-- docker -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${project.build.finalName}:${project.version}</imageName>
|
||||||
|
<dockerDirectory>${project.build.outputDirectory}</dockerDirectory>
|
||||||
|
<buildArgs>
|
||||||
|
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
|
||||||
|
</buildArgs>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<dockerHost>${docker.host}</dockerHost>
|
||||||
|
<dockerCertPath>${docker.certPath}</dockerCertPath>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
22
src/main/java/com/newyetai/AlitaBjyUygurApplication.java
Normal file
22
src/main/java/com/newyetai/AlitaBjyUygurApplication.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package com.newyetai;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author sr on 2020-04-16
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(scanBasePackages = {"com.newyetai"})
|
||||||
|
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
|
||||||
|
@EnableScheduling
|
||||||
|
public class AlitaBjyUygurApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AlitaBjyUygurApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.newyetai.ai.interview.controller;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.util.JsonUtils;
|
||||||
|
import com.newyetai.common.validation.Create;
|
||||||
|
import com.newyetai.common.validation.Update;
|
||||||
|
import com.newyetai.tkmybatis.pojo.Page;
|
||||||
|
import com.newyetai.ai.interview.dto.*;
|
||||||
|
import com.newyetai.ai.interview.service.InterviewRecordService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@Api(tags = "ai面试记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ai/interviewRecord")
|
||||||
|
public class InterviewRecordController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InterviewRecordService interviewRecordService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@ApiOperation("ai面试记录-创建")
|
||||||
|
public AlitaResult<InterviewRecordDTO> create(@RequestBody @Validated(value = Create.class) InterviewRecordOperatorDTO operatorDTO) {
|
||||||
|
return AlitaResult.success(interviewRecordService.create(operatorDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/modify")
|
||||||
|
@ApiOperation("ai面试记录-修改")
|
||||||
|
public AlitaResult<InterviewRecordDTO> modify(@RequestBody @Validated(value = Update.class) InterviewRecordOperatorDTO operatorDTO) {
|
||||||
|
return AlitaResult.success(interviewRecordService.modify(operatorDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
@ApiOperation("ai面试记录-删除")
|
||||||
|
public AlitaResult<InterviewRecordDTO> delete(@PathVariable("id") Long id) {
|
||||||
|
return AlitaResult.success(interviewRecordService.delete(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@ApiOperation("ai面试记录-查询单个")
|
||||||
|
public AlitaResult<InterviewRecordDTO> findById(@PathVariable("id") Long id) {
|
||||||
|
return AlitaResult.success(interviewRecordService.findById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
@ApiOperation("ai面试记录-列表查询")
|
||||||
|
public AlitaResult<List<InterviewRecordDTO>> list(InterviewRecordQueryDTO queryDTO) {
|
||||||
|
return AlitaResult.success(interviewRecordService.list(queryDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("ai面试记录-分页查询")
|
||||||
|
public AlitaResult<Page<InterviewRecordDTO>> page(InterviewRecordPageQueryDTO queryDTO) {
|
||||||
|
interviewRecordService.page(queryDTO);
|
||||||
|
return AlitaResult.success(queryDTO.getPageResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.newyetai.ai.interview.convert;
|
||||||
|
|
||||||
|
import com.newyetai.ai.interview.entity.InterviewRecord;
|
||||||
|
import com.newyetai.ai.interview.dto.InterviewRecordDTO;
|
||||||
|
import com.newyetai.ai.interview.dto.InterviewRecordOperatorDTO;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface InterviewRecordConvert {
|
||||||
|
InterviewRecordConvert INSTANCE = Mappers.getMapper(InterviewRecordConvert.class);
|
||||||
|
|
||||||
|
InterviewRecord convert(InterviewRecordDTO dto);
|
||||||
|
|
||||||
|
InterviewRecordDTO convert(InterviewRecord entity);
|
||||||
|
|
||||||
|
InterviewRecord convert(InterviewRecordOperatorDTO dto);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.newyetai.ai.interview.dao;
|
||||||
|
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import com.newyetai.ai.interview.entity.InterviewRecord;
|
||||||
|
import com.newyetai.ai.interview.dto.InterviewRecordDTO;
|
||||||
|
import com.newyetai.ai.interview.dto.InterviewRecordQueryDTO;
|
||||||
|
import com.newyetai.ai.interview.dto.InterviewRecordPageQueryDTO;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface InterviewRecordMapper extends MyMapper<InterviewRecord> {
|
||||||
|
|
||||||
|
List<InterviewRecordDTO> page(@Param("param") InterviewRecordPageQueryDTO queryDTO);
|
||||||
|
|
||||||
|
List<InterviewRecordDTO> list(@Param("param") InterviewRecordQueryDTO queryDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.newyetai.ai.interview.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@ApiModel("ai面试记录")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class InterviewRecordDTO extends BaseDTO {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID(xs_user)")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模拟岗位名称")
|
||||||
|
private String positionName;
|
||||||
|
|
||||||
|
@ApiModelProperty("面试状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.newyetai.ai.interview.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.newyetai.common.validation.Create;
|
||||||
|
import com.newyetai.common.validation.Update;
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@ApiModel("ai面试记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class InterviewRecordOperatorDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "id不能为空",groups = Update.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID(xs_user)")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
|
||||||
|
@Length(max = 32,message = "模拟岗位名称超长")
|
||||||
|
@NotBlank(message = "模拟岗位名称不能为空",groups = {Create.class})
|
||||||
|
@ApiModelProperty("模拟岗位名称")
|
||||||
|
private String positionName;
|
||||||
|
|
||||||
|
@ApiModelProperty("面试状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
@NotNull(message = "数据不能为空",groups = {Update.class})
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
@NotNull(message = "节点不能为空",groups = {Update.class})
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
//是否评分
|
||||||
|
@Builder.Default
|
||||||
|
private Boolean gradeInterview = Boolean.FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.newyetai.ai.interview.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.PageQueryDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel("ai面试记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class InterviewRecordPageQueryDTO extends PageQueryDTO<InterviewRecordDTO> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID(xs_user)")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模拟岗位名称 (模糊匹配)")
|
||||||
|
private String positionNameLike;
|
||||||
|
|
||||||
|
@ApiModelProperty("面试状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("修改时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("修改时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.newyetai.ai.interview.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@ApiModel("ai面试记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class InterviewRecordQueryDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户ID(xs_user)")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("模拟岗位名称 (模糊匹配)")
|
||||||
|
private String positionNameLike;
|
||||||
|
|
||||||
|
@ApiModelProperty("面试状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("修改时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("修改时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.newyetai.ai.interview.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@TableName(value = "ai_interview_record")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class InterviewRecord extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID(xs_user)
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 模拟岗位名称
|
||||||
|
*/
|
||||||
|
private String positionName;
|
||||||
|
/**
|
||||||
|
* 面试状态(1.待开始、2.待继续、3.已完成)
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 报告出具状态(1.未出具 2.已出具)
|
||||||
|
*/
|
||||||
|
private Integer reportStatus;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String jsonData;
|
||||||
|
/**
|
||||||
|
* 节点
|
||||||
|
*/
|
||||||
|
private Integer node;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.newyetai.ai.interview.enums;
|
||||||
|
/**
|
||||||
|
* @description: 面试状态
|
||||||
|
* @return:
|
||||||
|
* @author: guixinman
|
||||||
|
* @param:
|
||||||
|
*/
|
||||||
|
public enum InterviewRecordEnum {
|
||||||
|
INIT(1,"待开始"),
|
||||||
|
TO_BE_CONTINUED(2,"待继续"),
|
||||||
|
SUCCESS(3,"已完成"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 类型描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
InterviewRecordEnum(Integer status, String desc) {
|
||||||
|
this.status = status;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.newyetai.ai.interview.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 报告出具状态
|
||||||
|
* @return:
|
||||||
|
* @author: guixinman
|
||||||
|
* @param:
|
||||||
|
*/
|
||||||
|
public enum InterviewRecordReportStatusEnum {
|
||||||
|
INIT(1,"未出具"),
|
||||||
|
SUCCESS(2,"已出具"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 类型描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
InterviewRecordReportStatusEnum(Integer status, String desc) {
|
||||||
|
this.status = status;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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="com.newyetai.ai.interview.dao.InterviewRecordMapper">
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.ai.interview.dto.InterviewRecordDTO">
|
||||||
|
SELECT t.*
|
||||||
|
<include refid="queryFromSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="page" resultType="com.newyetai.ai.interview.dto.InterviewRecordDTO">
|
||||||
|
SELECT t.*
|
||||||
|
<include refid="queryFromSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryFromSql">
|
||||||
|
FROM
|
||||||
|
ai_interview_record t
|
||||||
|
WHERE t.deleted = 0
|
||||||
|
<if test='param.id != null'>
|
||||||
|
AND t.id = #{param.id}
|
||||||
|
</if>
|
||||||
|
<if test='param.userId != null'>
|
||||||
|
AND t.user_id = #{param.userId}
|
||||||
|
</if>
|
||||||
|
<if test='param.positionNameLike != null and param.positionNameLike.trim() != ""'>
|
||||||
|
<bind name="positionNameLike" value="'%' + param.positionNameLike + '%'"/>
|
||||||
|
AND t.position_name like #{positionNameLike}
|
||||||
|
</if>
|
||||||
|
<if test='param.state != null'>
|
||||||
|
AND t.state = #{param.state}
|
||||||
|
</if>
|
||||||
|
<if test='param.reportStatus != null'>
|
||||||
|
AND t.report_status = #{param.reportStatus}
|
||||||
|
</if>
|
||||||
|
<if test='param.jsonData != null and param.jsonData.trim() != ""'>
|
||||||
|
AND t.json_data = #{param.jsonData}
|
||||||
|
</if>
|
||||||
|
<if test='param.node != null'>
|
||||||
|
AND t.node = #{param.node}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeStart != null'>
|
||||||
|
AND t.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeEnd != null'>
|
||||||
|
AND t.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeStart != null'>
|
||||||
|
AND t.update_time >= #{param.updateTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeEnd != null'>
|
||||||
|
AND t.update_time <= #{param.updateTimeEnd}
|
||||||
|
</if>
|
||||||
|
ORDER BY t.id DESC
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.newyetai.ai.interview.service;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.groups.Default;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.newyetai.ai.interview.dto.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@Validated(Default.class)
|
||||||
|
public interface InterviewRecordService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 创建
|
||||||
|
*
|
||||||
|
* @param operatorDto 操作dto
|
||||||
|
* @return {@link InterviewRecordDTO}
|
||||||
|
*/
|
||||||
|
InterviewRecordDTO create(@Valid InterviewRecordOperatorDTO operatorDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 修改
|
||||||
|
*
|
||||||
|
* @param operatorDto 操作dto
|
||||||
|
* @return {@link InterviewRecordDTO}
|
||||||
|
*/
|
||||||
|
InterviewRecordDTO modify(@Valid InterviewRecordOperatorDTO operatorDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 删除
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return {@link InterviewRecordDTO}
|
||||||
|
*/
|
||||||
|
InterviewRecordDTO delete(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 根据ID查询单个
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return {@link InterviewRecordDTO}
|
||||||
|
*/
|
||||||
|
InterviewRecordDTO findById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 列表查询
|
||||||
|
*
|
||||||
|
* @param queryDTO 列表查询dto
|
||||||
|
* @return {@link List}<{@link InterviewRecordDTO}>
|
||||||
|
*/
|
||||||
|
List<InterviewRecordDTO> list(InterviewRecordQueryDTO queryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录 - 分页查询
|
||||||
|
*
|
||||||
|
* @param queryDTO 分页查询dto
|
||||||
|
* @return {@link InterviewRecordDTO}
|
||||||
|
*/
|
||||||
|
List<InterviewRecordDTO> page(InterviewRecordPageQueryDTO queryDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package com.newyetai.ai.interview.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import com.newyetai.ai.interview.convert.InterviewRecordConvert;
|
||||||
|
import com.newyetai.ai.interview.entity.InterviewRecord;
|
||||||
|
import com.newyetai.ai.interview.dto.*;
|
||||||
|
import com.newyetai.ai.interview.dao.InterviewRecordMapper;
|
||||||
|
import com.newyetai.ai.interview.enums.InterviewRecordEnum;
|
||||||
|
import com.newyetai.ai.interview.enums.InterviewRecordReportStatusEnum;
|
||||||
|
import com.newyetai.ai.interview.service.InterviewRecordService;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.newyetai.common.exception.BusinessException;
|
||||||
|
import com.newyetai.common.util.JsonUtils;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.sdk.xf.dto.InterviewContentDTO;
|
||||||
|
import com.newyetai.sdk.xf.util.XfUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ai面试记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-11
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class InterviewRecordServiceImpl implements InterviewRecordService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private InterviewRecordMapper interviewRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InterviewRecordDTO create(InterviewRecordOperatorDTO operatorDto) {
|
||||||
|
InterviewRecord interviewRecord = InterviewRecordConvert.INSTANCE.convert(operatorDto);
|
||||||
|
interviewRecord.setUserId(UserContextHolder.getExistLoginUserId());
|
||||||
|
interviewRecord.setNode(1);
|
||||||
|
interviewRecord.setState(InterviewRecordEnum.INIT.getStatus());
|
||||||
|
interviewRecord.setReportStatus(InterviewRecordReportStatusEnum.INIT.getStatus());
|
||||||
|
|
||||||
|
String data = XfUtils.generateInterviewQuestion(InterviewContentDTO.builder().positionName(operatorDto.getPositionName()).build());
|
||||||
|
interviewRecord.setJsonData(data);
|
||||||
|
interviewRecordMapper.saveEntity(interviewRecord);
|
||||||
|
return InterviewRecordConvert.INSTANCE.convert(interviewRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InterviewRecordDTO modify(InterviewRecordOperatorDTO operatorDto) {
|
||||||
|
InterviewRecordDTO interviewRecordDto = this.findById(operatorDto.getId());
|
||||||
|
if (Objects.isNull(interviewRecordDto)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
InterviewRecord interviewRecord = InterviewRecordConvert.INSTANCE.convert(operatorDto);
|
||||||
|
|
||||||
|
String jsonData = interviewRecord.getJsonData();
|
||||||
|
InterviewContentDTO interviewContentDTO = JsonUtils.toObject(jsonData, InterviewContentDTO.class);
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(operatorDto.getGradeInterview())) {
|
||||||
|
String jsonDataNew = XfUtils.gradeInterview(interviewContentDTO);
|
||||||
|
interviewRecord.setReportStatus(InterviewRecordReportStatusEnum.SUCCESS.getStatus());
|
||||||
|
interviewRecord.setJsonData(jsonDataNew);
|
||||||
|
interviewRecord.setState(InterviewRecordEnum.SUCCESS.getStatus());
|
||||||
|
}else {
|
||||||
|
interviewRecord.setState(InterviewRecordEnum.TO_BE_CONTINUED.getStatus());
|
||||||
|
}
|
||||||
|
interviewRecordMapper.updateEntitySelective(interviewRecord);
|
||||||
|
|
||||||
|
return this.findById(operatorDto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InterviewRecordDTO delete(Long id) {
|
||||||
|
InterviewRecordDTO interviewRecordDto = this.findById(id);
|
||||||
|
if (Objects.isNull(interviewRecordDto)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
InterviewRecord interviewRecord = InterviewRecord.builder().build();
|
||||||
|
interviewRecord.setId(id);
|
||||||
|
interviewRecordMapper.deleteEntity(interviewRecord, UserContextHolder.getLoginUserId());
|
||||||
|
return interviewRecordDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InterviewRecordDTO findById(Long id) {
|
||||||
|
InterviewRecord interviewRecord = interviewRecordMapper.getById(id);
|
||||||
|
if (Objects.isNull(interviewRecord)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return InterviewRecordConvert.INSTANCE.convert(interviewRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<InterviewRecordDTO> list(InterviewRecordQueryDTO queryDTO) {
|
||||||
|
return interviewRecordMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<InterviewRecordDTO> page(InterviewRecordPageQueryDTO queryDTO) {
|
||||||
|
queryDTO.setUserId(UserContextHolder.getExistLoginUserId());
|
||||||
|
return interviewRecordMapper.page(queryDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.newyetai.ai.mbti.controller;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.validation.Create;
|
||||||
|
import com.newyetai.common.validation.Update;
|
||||||
|
import com.newyetai.tkmybatis.pojo.Page;
|
||||||
|
import com.newyetai.ai.mbti.dto.*;
|
||||||
|
import com.newyetai.ai.mbti.service.MbtiRecordService;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@Api(tags = "AI测评记录")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ai/mbtiRecord")
|
||||||
|
public class MbtiRecordController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MbtiRecordService mbtiRecordService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@ApiOperation("AI测评记录-创建")
|
||||||
|
public AlitaResult<MbtiRecordDTO> create(@RequestBody @Validated(value = Create.class) MbtiRecordOperatorDTO operatorDTO) {
|
||||||
|
return AlitaResult.success(mbtiRecordService.create(operatorDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/modify")
|
||||||
|
@ApiOperation("AI测评记录-修改")
|
||||||
|
public AlitaResult<MbtiRecordDTO> modify(@RequestBody @Validated(value = Update.class) MbtiRecordOperatorDTO operatorDTO) {
|
||||||
|
return AlitaResult.success(mbtiRecordService.modify(operatorDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("AI测评记录-出具报告")
|
||||||
|
@PostMapping("/report")
|
||||||
|
public AlitaResult<Void> report(@RequestParam("id") Long id){
|
||||||
|
mbtiRecordService.report(id);
|
||||||
|
return AlitaResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
@ApiOperation("AI测评记录-删除")
|
||||||
|
public AlitaResult<MbtiRecordDTO> delete(@PathVariable("id") Long id) {
|
||||||
|
return AlitaResult.success(mbtiRecordService.delete(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@ApiOperation("AI测评记录-查询单个")
|
||||||
|
public AlitaResult<MbtiRecordDTO> findById(@PathVariable("id") Long id) {
|
||||||
|
return AlitaResult.success(mbtiRecordService.findById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
@ApiOperation("AI测评记录-列表查询")
|
||||||
|
public AlitaResult<List<MbtiRecordDTO>> list(MbtiRecordQueryDTO queryDTO) {
|
||||||
|
return AlitaResult.success(mbtiRecordService.list(queryDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("AI测评记录-分页查询")
|
||||||
|
public AlitaResult<Page<MbtiRecordDTO>> page(MbtiRecordPageQueryDTO queryDTO) {
|
||||||
|
mbtiRecordService.page(queryDTO);
|
||||||
|
return AlitaResult.success(queryDTO.getPageResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.newyetai.ai.mbti.convert;
|
||||||
|
|
||||||
|
import com.newyetai.ai.mbti.entity.MbtiRecord;
|
||||||
|
import com.newyetai.ai.mbti.dto.MbtiRecordDTO;
|
||||||
|
import com.newyetai.ai.mbti.dto.MbtiRecordOperatorDTO;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MbtiRecordConvert {
|
||||||
|
MbtiRecordConvert INSTANCE = Mappers.getMapper(MbtiRecordConvert.class);
|
||||||
|
|
||||||
|
MbtiRecord convert(MbtiRecordDTO dto);
|
||||||
|
|
||||||
|
MbtiRecordDTO convert(MbtiRecord entity);
|
||||||
|
|
||||||
|
MbtiRecord convert(MbtiRecordOperatorDTO dto);
|
||||||
|
|
||||||
|
}
|
||||||
26
src/main/java/com/newyetai/ai/mbti/dao/MbtiRecordMapper.java
Normal file
26
src/main/java/com/newyetai/ai/mbti/dao/MbtiRecordMapper.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.newyetai.ai.mbti.dao;
|
||||||
|
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import com.newyetai.ai.mbti.entity.MbtiRecord;
|
||||||
|
import com.newyetai.ai.mbti.dto.MbtiRecordDTO;
|
||||||
|
import com.newyetai.ai.mbti.dto.MbtiRecordQueryDTO;
|
||||||
|
import com.newyetai.ai.mbti.dto.MbtiRecordPageQueryDTO;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MbtiRecordMapper extends MyMapper<MbtiRecord> {
|
||||||
|
|
||||||
|
List<MbtiRecordDTO> page(@Param("param") MbtiRecordPageQueryDTO queryDTO);
|
||||||
|
|
||||||
|
List<MbtiRecordDTO> list(@Param("param") MbtiRecordQueryDTO queryDTO);
|
||||||
|
}
|
||||||
51
src/main/java/com/newyetai/ai/mbti/dto/MbtiRecordDTO.java
Normal file
51
src/main/java/com/newyetai/ai/mbti/dto/MbtiRecordDTO.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.newyetai.ai.mbti.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@ApiModel("AI测评记录")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MbtiRecordDTO extends BaseDTO {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String liangBiaoId;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private String reportId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.newyetai.ai.mbti.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.newyetai.common.validation.Create;
|
||||||
|
import com.newyetai.common.validation.Update;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@ApiModel("AI测评记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MbtiRecordOperatorDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotNull(message = "id不能为空",groups = Update.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@NotBlank(message = "liangBiaoId不能为空",groups = {Create.class, Update.class})
|
||||||
|
private String liangBiaoId;
|
||||||
|
|
||||||
|
@NotNull(message = "节点不能为空",groups = {Update.class})
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@NotNull(message = "数据不能为空",groups = {Update.class})
|
||||||
|
private Map<String, String> answers;
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Boolean submit = Boolean.FALSE;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private String reportId;
|
||||||
|
|
||||||
|
@NotBlank(message = "name不能为空",groups = {Create.class, Update.class})
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@NotBlank(message = "phone不能为空",groups = {Create.class, Update.class})
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.newyetai.ai.mbti.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.PageQueryDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel("AI测评记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MbtiRecordPageQueryDTO extends PageQueryDTO<MbtiRecordDTO> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String liangBiaoId;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.newyetai.ai.mbti.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@ApiModel("AI测评记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MbtiRecordQueryDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String liangBiaoId;
|
||||||
|
|
||||||
|
@ApiModelProperty("节点")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
private String jsonData;
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1.待开始、2.待继续、3.已完成)")
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告出具状态(1.未出具 2.已出具)")
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
63
src/main/java/com/newyetai/ai/mbti/entity/MbtiRecord.java
Normal file
63
src/main/java/com/newyetai/ai/mbti/entity/MbtiRecord.java
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package com.newyetai.ai.mbti.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@TableName(value = "ai_mbti_record")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MbtiRecord extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String liangBiaoId;
|
||||||
|
/**
|
||||||
|
* 节点
|
||||||
|
*/
|
||||||
|
private Integer node;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String jsonData;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(1.待开始、2.待继续、3.已完成)
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
/**
|
||||||
|
* 报告出具状态(1.未出具 2.已出具)
|
||||||
|
*/
|
||||||
|
private Integer reportStatus;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private String reportId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
32
src/main/java/com/newyetai/ai/mbti/enums/MbtiRecordEnum.java
Normal file
32
src/main/java/com/newyetai/ai/mbti/enums/MbtiRecordEnum.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.newyetai.ai.mbti.enums;
|
||||||
|
/**
|
||||||
|
* @description: 状态
|
||||||
|
* @return:
|
||||||
|
* @author: guixinman
|
||||||
|
* @param:
|
||||||
|
*/
|
||||||
|
public enum MbtiRecordEnum {
|
||||||
|
TO_BE_CONTINUED(2,"待继续"),
|
||||||
|
SUCCESS(3,"已完成"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 类型描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
MbtiRecordEnum(Integer status, String desc) {
|
||||||
|
this.status = status;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.newyetai.ai.mbti.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 报告出具状态
|
||||||
|
* @return:
|
||||||
|
* @author: guixinman
|
||||||
|
* @param:
|
||||||
|
*/
|
||||||
|
public enum MbtiRecordReportStatusEnum {
|
||||||
|
INIT(1,"未出具"),
|
||||||
|
SUCCESS(2,"已出具"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 类型描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
MbtiRecordReportStatusEnum(Integer status, String desc) {
|
||||||
|
this.status = status;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?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="com.newyetai.ai.mbti.dao.MbtiRecordMapper">
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.ai.mbti.dto.MbtiRecordDTO">
|
||||||
|
SELECT t.*
|
||||||
|
<include refid="queryFromSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="page" resultType="com.newyetai.ai.mbti.dto.MbtiRecordDTO">
|
||||||
|
SELECT t.*
|
||||||
|
<include refid="queryFromSql"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryFromSql">
|
||||||
|
FROM
|
||||||
|
ai_mbti_record t
|
||||||
|
WHERE t.deleted = 0
|
||||||
|
<if test='param.id != null'>
|
||||||
|
AND t.id = #{param.id}
|
||||||
|
</if>
|
||||||
|
<if test='param.userId != null'>
|
||||||
|
AND t.user_id = #{param.userId}
|
||||||
|
</if>
|
||||||
|
<if test='param.liangBiaoId != null and param.liangBiaoId.trim() != ""'>
|
||||||
|
AND t.liang_biao_id = #{param.liangBiaoId}
|
||||||
|
</if>
|
||||||
|
<if test='param.node != null'>
|
||||||
|
AND t.node = #{param.node}
|
||||||
|
</if>
|
||||||
|
<if test='param.jsonData != null and param.jsonData.trim() != ""'>
|
||||||
|
AND t.json_data = #{param.jsonData}
|
||||||
|
</if>
|
||||||
|
<if test='param.orderId != null'>
|
||||||
|
AND t.order_id = #{param.orderId}
|
||||||
|
</if>
|
||||||
|
<if test='param.state != null'>
|
||||||
|
AND t.state = #{param.state}
|
||||||
|
</if>
|
||||||
|
<if test='param.reportStatus != null'>
|
||||||
|
AND t.report_status = #{param.reportStatus}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeStart != null'>
|
||||||
|
AND t.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeEnd != null'>
|
||||||
|
AND t.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeStart != null'>
|
||||||
|
AND t.update_time >= #{param.updateTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeEnd != null'>
|
||||||
|
AND t.update_time <= #{param.updateTimeEnd}
|
||||||
|
</if>
|
||||||
|
ORDER BY t.id DESC
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.newyetai.ai.mbti.service;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.groups.Default;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.newyetai.ai.mbti.dto.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@Validated(Default.class)
|
||||||
|
public interface MbtiRecordService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 创建
|
||||||
|
*
|
||||||
|
* @param operatorDto 操作dto
|
||||||
|
* @return {@link MbtiRecordDTO}
|
||||||
|
*/
|
||||||
|
MbtiRecordDTO create(@Valid MbtiRecordOperatorDTO operatorDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 修改
|
||||||
|
*
|
||||||
|
* @param operatorDto 操作dto
|
||||||
|
* @return {@link MbtiRecordDTO}
|
||||||
|
*/
|
||||||
|
MbtiRecordDTO modify(@Valid MbtiRecordOperatorDTO operatorDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 出具报告
|
||||||
|
* @return:
|
||||||
|
* @author: guixinman
|
||||||
|
* @param:
|
||||||
|
*/
|
||||||
|
void report(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 删除
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return {@link MbtiRecordDTO}
|
||||||
|
*/
|
||||||
|
MbtiRecordDTO delete(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 根据ID查询单个
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return {@link MbtiRecordDTO}
|
||||||
|
*/
|
||||||
|
MbtiRecordDTO findById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 列表查询
|
||||||
|
*
|
||||||
|
* @param queryDTO 列表查询dto
|
||||||
|
* @return {@link List}<{@link MbtiRecordDTO}>
|
||||||
|
*/
|
||||||
|
List<MbtiRecordDTO> list(MbtiRecordQueryDTO queryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录 - 分页查询
|
||||||
|
*
|
||||||
|
* @param queryDTO 分页查询dto
|
||||||
|
* @return {@link MbtiRecordDTO}
|
||||||
|
*/
|
||||||
|
List<MbtiRecordDTO> page(MbtiRecordPageQueryDTO queryDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package com.newyetai.ai.mbti.service.impl;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import com.newyetai.ai.interview.enums.InterviewRecordEnum;
|
||||||
|
import com.newyetai.ai.interview.enums.InterviewRecordReportStatusEnum;
|
||||||
|
import com.newyetai.ai.mbti.convert.MbtiRecordConvert;
|
||||||
|
import com.newyetai.ai.mbti.entity.MbtiRecord;
|
||||||
|
import com.newyetai.ai.mbti.dto.*;
|
||||||
|
import com.newyetai.ai.mbti.dao.MbtiRecordMapper;
|
||||||
|
import com.newyetai.ai.mbti.enums.MbtiRecordEnum;
|
||||||
|
import com.newyetai.ai.mbti.enums.MbtiRecordReportStatusEnum;
|
||||||
|
import com.newyetai.ai.mbti.service.MbtiRecordService;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.exception.BusinessException;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.sensitive.SensitiveInfoUtils;
|
||||||
|
import com.newyetai.common.util.JsonUtils;
|
||||||
|
import com.newyetai.common.util.RandomUtils;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.AnswerReq;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.AnswerReqDTO;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.AnswerRes;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.OrderQueryReq;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.OrderQueryRes;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.ReportReq;
|
||||||
|
import com.newyetai.sdk.mbti.mobel.ReportRes;
|
||||||
|
import com.newyetai.sdk.mbti.service.MbtiProvider;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AI测评记录
|
||||||
|
*
|
||||||
|
* @author guixinman
|
||||||
|
* @since 1.0.0 2024-12-20
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MbtiRecordServiceImpl implements MbtiRecordService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MbtiRecordMapper mbtiRecordMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MbtiProvider mbtiProvider;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MbtiRecordDTO create(MbtiRecordOperatorDTO operatorDto) {
|
||||||
|
MbtiRecord mbtiRecord = MbtiRecordConvert.INSTANCE.convert(operatorDto);
|
||||||
|
mbtiRecord.setUserId(UserContextHolder.getExistLoginUserId());
|
||||||
|
mbtiRecord.setState(MbtiRecordEnum.TO_BE_CONTINUED.getStatus());
|
||||||
|
mbtiRecord.setReportStatus(MbtiRecordReportStatusEnum.INIT.getStatus());
|
||||||
|
mbtiRecord.setJsonData(JsonUtils.toJsonString(operatorDto.getAnswers()));
|
||||||
|
mbtiRecord.setName(operatorDto.getName());
|
||||||
|
mbtiRecord.setPhone(operatorDto.getPhone());
|
||||||
|
|
||||||
|
if (operatorDto.getSubmit()) {
|
||||||
|
if (Objects.isNull(operatorDto.getAnswers())) {
|
||||||
|
throw new BusinessException("answers不能为空");
|
||||||
|
}
|
||||||
|
AnswerReq answerReq = new AnswerReq();
|
||||||
|
AnswerReqDTO answerData = AnswerReqDTO.builder()
|
||||||
|
.Answers(operatorDto.getAnswers())
|
||||||
|
.test_name(SensitiveInfoUtils.mobilePhone2(operatorDto.getPhone()) + RandomUtils.getRandomString(5))
|
||||||
|
.test_email(RandomUtils.getRandomString(5))
|
||||||
|
.build();
|
||||||
|
answerReq.setLiangbiaoId(operatorDto.getLiangBiaoId());
|
||||||
|
answerReq.setAnswerData(answerData);
|
||||||
|
AlitaResult<AnswerRes> answerResAlitaResult = mbtiProvider.http(answerReq);
|
||||||
|
Assert.isTrue(answerResAlitaResult.getSuccess(),answerResAlitaResult.getMsg());
|
||||||
|
AnswerRes answerRes = answerResAlitaResult.getData();
|
||||||
|
mbtiRecord.setOrderId(answerRes.getOrderId());
|
||||||
|
mbtiRecord.setState(MbtiRecordEnum.SUCCESS.getStatus());
|
||||||
|
}
|
||||||
|
mbtiRecordMapper.saveEntity(mbtiRecord);
|
||||||
|
return MbtiRecordConvert.INSTANCE.convert(mbtiRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MbtiRecordDTO modify(MbtiRecordOperatorDTO operatorDto) {
|
||||||
|
MbtiRecordDTO mbtiRecordDto = this.findById(operatorDto.getId());
|
||||||
|
if (Objects.isNull(mbtiRecordDto)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MbtiRecord mbtiRecord = MbtiRecordConvert.INSTANCE.convert(operatorDto);
|
||||||
|
mbtiRecord.setJsonData(JsonUtils.toJsonString(operatorDto.getAnswers()));
|
||||||
|
mbtiRecord.setName(operatorDto.getName());
|
||||||
|
mbtiRecord.setPhone(operatorDto.getPhone());
|
||||||
|
if (operatorDto.getSubmit()) {
|
||||||
|
AnswerReq answerReq = new AnswerReq();
|
||||||
|
answerReq.setLiangbiaoId(operatorDto.getLiangBiaoId());
|
||||||
|
answerReq.setAnswerData(AnswerReqDTO.builder()
|
||||||
|
.Answers(operatorDto.getAnswers())
|
||||||
|
.test_name(SensitiveInfoUtils.mobilePhone2(operatorDto.getPhone()) + RandomUtils.getRandomString(5))
|
||||||
|
.test_email(RandomUtils.getRandomString(5))
|
||||||
|
.build());
|
||||||
|
AlitaResult<AnswerRes> answerResAlitaResult = mbtiProvider.http(answerReq);
|
||||||
|
Assert.isTrue(answerResAlitaResult.getSuccess(),answerResAlitaResult.getMsg());
|
||||||
|
AnswerRes answerRes = answerResAlitaResult.getData();
|
||||||
|
mbtiRecord.setOrderId(answerRes.getOrderId());
|
||||||
|
mbtiRecord.setState(MbtiRecordEnum.SUCCESS.getStatus());
|
||||||
|
}
|
||||||
|
mbtiRecordMapper.updateEntitySelective(mbtiRecord);
|
||||||
|
return this.findById(operatorDto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void report(Long id) {
|
||||||
|
MbtiRecordDTO mbtiRecordDto = this.findById(id);
|
||||||
|
if (Objects.isNull(mbtiRecordDto)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AlitaResult<OrderQueryRes> queryRes = mbtiProvider.http(OrderQueryReq.builder().liangbiaoId(mbtiRecordDto.getLiangBiaoId()).orderId(mbtiRecordDto.getOrderId()).build());
|
||||||
|
Assert.isTrue(queryRes.getSuccess(),queryRes.getMsg());
|
||||||
|
|
||||||
|
AlitaResult<ReportRes> reportRes = mbtiProvider.http(ReportReq.builder().liangbiaoId(mbtiRecordDto.getLiangBiaoId()).reportId(queryRes.getData().getReportId()).build());
|
||||||
|
Assert.isTrue(reportRes.getSuccess(),reportRes.getMsg());
|
||||||
|
|
||||||
|
MbtiRecord mbtiRecord = MbtiRecordConvert.INSTANCE.convert(mbtiRecordDto);
|
||||||
|
mbtiRecord.setReportId(queryRes.getData().getReportId());
|
||||||
|
mbtiRecord.setReportStatus(MbtiRecordReportStatusEnum.SUCCESS.getStatus());
|
||||||
|
mbtiRecord.setContent(reportRes.getData().getContent());
|
||||||
|
mbtiRecordMapper.updateEntitySelective(mbtiRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MbtiRecordDTO delete(Long id) {
|
||||||
|
MbtiRecordDTO mbtiRecordDto = this.findById(id);
|
||||||
|
if (Objects.isNull(mbtiRecordDto)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MbtiRecord mbtiRecord = MbtiRecord.builder().build();
|
||||||
|
mbtiRecord.setId(id);
|
||||||
|
mbtiRecordMapper.deleteEntity(mbtiRecord, UserContextHolder.getLoginUserId());
|
||||||
|
return mbtiRecordDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MbtiRecordDTO findById(Long id) {
|
||||||
|
MbtiRecord mbtiRecord = mbtiRecordMapper.getById(id);
|
||||||
|
if (Objects.isNull(mbtiRecord)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return MbtiRecordConvert.INSTANCE.convert(mbtiRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MbtiRecordDTO> list(MbtiRecordQueryDTO queryDTO) {
|
||||||
|
return mbtiRecordMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MbtiRecordDTO> page(MbtiRecordPageQueryDTO queryDTO) {
|
||||||
|
queryDTO.setUserId(UserContextHolder.getExistLoginUserId());
|
||||||
|
return mbtiRecordMapper.page(queryDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.newyetai.ai.resume.controller;
|
||||||
|
|
||||||
|
import com.newyetai.ai.resume.dto.AiResumeReqDTO;
|
||||||
|
import com.newyetai.ai.resume.service.AiResumeService;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.sdk.xf.util.XfUtils;
|
||||||
|
|
||||||
|
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.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: guixinman
|
||||||
|
* @create: 2024-12-12 10:03
|
||||||
|
**/
|
||||||
|
@Api(tags = "AI简历")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ai/resume")
|
||||||
|
public class AiResumeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AiResumeService aiResumeService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@ApiOperation("ai简历-创建")
|
||||||
|
public AlitaResult<Long> create(@RequestBody @Validated AiResumeReqDTO reqDto) {
|
||||||
|
aiResumeService.create(reqDto);
|
||||||
|
return AlitaResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/iat")
|
||||||
|
@ApiOperation("ai简历-语音听写")
|
||||||
|
public AlitaResult<String> iat(@RequestParam("fileCode") String fileCode) {
|
||||||
|
return AlitaResult.success(XfUtils.iat(fileCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/tts")
|
||||||
|
@ApiOperation("ai简历-语音合成")
|
||||||
|
public AlitaResult<String> tts(@RequestParam("text") String text) {
|
||||||
|
return AlitaResult.success(XfUtils.tts(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/analyseResume")
|
||||||
|
@ApiOperation("分析简历")
|
||||||
|
public AlitaResult<String> analyseResume(@RequestParam("text") String text) {
|
||||||
|
return AlitaResult.success(XfUtils.analyseResume(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/generateSelfEvaluate")
|
||||||
|
@ApiOperation("生成自我评价")
|
||||||
|
public AlitaResult<String> generateSelfEvaluate(@RequestBody Map<String,Object> map) {
|
||||||
|
return AlitaResult.success(XfUtils.generateSelfEvaluate(JSONUtil.toJsonStr(map)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/generateWorkExperience")
|
||||||
|
@ApiOperation("生成工作经历")
|
||||||
|
public AlitaResult<String> generateWorkExperience(@RequestBody Map<String,Object> map) {
|
||||||
|
return AlitaResult.success(XfUtils.generateWorkExperience(JSONUtil.toJsonStr(map)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
src/main/java/com/newyetai/ai/resume/dto/AiResumeReqDTO.java
Normal file
43
src/main/java/com/newyetai/ai/resume/dto/AiResumeReqDTO.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.newyetai.ai.resume.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.validation.Create;
|
||||||
|
import com.newyetai.common.validation.Update;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: guixinman
|
||||||
|
* @create: 2024-12-12 10:07
|
||||||
|
**/
|
||||||
|
@ApiModel("ai面试记录")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AiResumeReqDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@NotBlank(message = "请输入内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty("岗位类型")
|
||||||
|
private String typeCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("期望城市")
|
||||||
|
private String expectCity;
|
||||||
|
|
||||||
|
@ApiModelProperty("期望月薪")
|
||||||
|
private BigDecimal expectSalary;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.newyetai.ai.resume.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Ai生成简历返回model
|
||||||
|
* @author: guixinman
|
||||||
|
* @create: 2024-12-12 11:31
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AiResumeModel implements Serializable {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String birthday;
|
||||||
|
@ApiModelProperty("期望工作地")
|
||||||
|
private String desiredWorkLocation;
|
||||||
|
@ApiModelProperty("期望最低薪资")
|
||||||
|
private String desiredSalaryMin;
|
||||||
|
@ApiModelProperty("期望最高薪资")
|
||||||
|
private String desiredSalaryMax;
|
||||||
|
@ApiModelProperty("期望岗位性质")
|
||||||
|
private String desiredPositionNature;
|
||||||
|
@ApiModelProperty("期望岗位")
|
||||||
|
private String desiredPosition;
|
||||||
|
@ApiModelProperty("最高学历")
|
||||||
|
private String highestDegree;
|
||||||
|
@ApiModelProperty("到岗状态")
|
||||||
|
private String reportStatus;
|
||||||
|
@ApiModelProperty("自我介绍")
|
||||||
|
private String selfIntroduction;
|
||||||
|
// @ApiModelProperty("简历标签")
|
||||||
|
// private String tags;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.newyetai.ai.resume.service;
|
||||||
|
|
||||||
|
import com.newyetai.ai.resume.dto.AiResumeReqDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: guixinman
|
||||||
|
* @create: 2024-12-12 10:57
|
||||||
|
**/
|
||||||
|
public interface AiResumeService {
|
||||||
|
|
||||||
|
void create(AiResumeReqDTO reqDto);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package com.newyetai.ai.resume.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.newyetai.ai.resume.dto.AiResumeReqDTO;
|
||||||
|
import com.newyetai.ai.resume.model.AiResumeModel;
|
||||||
|
import com.newyetai.ai.resume.service.AiResumeService;
|
||||||
|
import com.newyetai.common.constant.CommonConstants;
|
||||||
|
import com.newyetai.common.exception.BusinessException;
|
||||||
|
import com.newyetai.common.util.JsonUtils;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.component.dict.util.DictUtils;
|
||||||
|
import com.newyetai.config.service.ConfigService;
|
||||||
|
import com.newyetai.recruit.position.dao.PositionTypeMapper;
|
||||||
|
import com.newyetai.recruit.position.entity.PositionType;
|
||||||
|
import com.newyetai.recruit.user.dao.JobExpectMapper;
|
||||||
|
import com.newyetai.recruit.user.dao.ResumeMapper;
|
||||||
|
import com.newyetai.recruit.user.dto.JobExpectOperateDTO;
|
||||||
|
import com.newyetai.recruit.user.dto.ResumeDTO;
|
||||||
|
import com.newyetai.recruit.user.dto.ResumeOperatorDTO;
|
||||||
|
import com.newyetai.recruit.user.entity.Resume;
|
||||||
|
import com.newyetai.recruit.user.enums.InductionCycleEnum;
|
||||||
|
import com.newyetai.recruit.user.service.JobExpectService;
|
||||||
|
import com.newyetai.recruit.user.service.ResumeService;
|
||||||
|
import com.newyetai.sdk.xf.util.XfUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: guixinman
|
||||||
|
* @create: 2024-12-12 10:57
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class AiResumeServiceImpl implements AiResumeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfigService configService;
|
||||||
|
@Autowired
|
||||||
|
private ResumeService resumeService;
|
||||||
|
@Resource
|
||||||
|
private ResumeMapper resumeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JobExpectService jobExpectService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PositionTypeMapper positionTypeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public void create(AiResumeReqDTO reqDto) {
|
||||||
|
String errMsg = "抱歉,我无法回答,请告诉我你想找什么样的工作";
|
||||||
|
try {
|
||||||
|
String jsonData = XfUtils.generateResume(reqDto.getContent());
|
||||||
|
if (StringUtils.equalsAny(jsonData, errMsg)) {
|
||||||
|
throw new BusinessException(jsonData);
|
||||||
|
}
|
||||||
|
AiResumeModel aiResumeModel = JsonUtils.toObject(jsonData, AiResumeModel.class);
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(aiResumeModel.getDesiredPosition())) {
|
||||||
|
throw new BusinessException(errMsg);
|
||||||
|
}
|
||||||
|
//学历
|
||||||
|
String education = DictUtils.getNameCodeMap("education").get(StringUtils.isNotBlank(aiResumeModel.getHighestDegree()) ? aiResumeModel.getHighestDegree() : "");
|
||||||
|
|
||||||
|
jobExpectService.removeByUserId();
|
||||||
|
jobExpectService.create(
|
||||||
|
JobExpectOperateDTO.builder()
|
||||||
|
.userId(UserContextHolder.getExistLoginUserId())
|
||||||
|
.typeCode(reqDto.getTypeCode())
|
||||||
|
.expectCity(reqDto.getExpectCity())
|
||||||
|
.expectSalary(reqDto.getExpectSalary())
|
||||||
|
.onDuty(false)
|
||||||
|
.inductionCycle(InductionCycleEnum.findTypeByDesc(aiResumeModel.getReportStatus()))
|
||||||
|
.positionName(aiResumeModel.getDesiredPosition())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
throw new BusinessException(errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.newyetai.alitaforward.common.mq.constant;
|
||||||
|
|
||||||
|
import com.newyetai.common.constant.CommonConstants;
|
||||||
|
import com.newyetai.common.constant.SystemCodeEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mq常量类(routingkey)
|
||||||
|
* @author sr on 2021-08-09
|
||||||
|
*/
|
||||||
|
public interface ForwardMqConstants {
|
||||||
|
|
||||||
|
/** 用户中心系统mq前缀 **/
|
||||||
|
String MQ_PREFIX = SystemCodeEnum.ALITA_FORWARD.getName() + CommonConstants.POINT;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-21
|
||||||
|
*/
|
||||||
|
public enum FactorVerificationSourceTypeEnum {
|
||||||
|
|
||||||
|
FXQ("放心签", 1),
|
||||||
|
CL("创蓝", 2),
|
||||||
|
SYS("系统", 3);
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
private final Integer type;
|
||||||
|
|
||||||
|
FactorVerificationSourceTypeEnum(String desc, Integer type) {
|
||||||
|
this.desc = desc;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.constants;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.common.mq.constant.ForwardMqConstants;
|
||||||
|
|
||||||
|
public enum VerificationTypeEnum {
|
||||||
|
|
||||||
|
/** 二要素认证 */
|
||||||
|
TWO("real_name_two_verification"),
|
||||||
|
/** 银行卡三要素认证 */
|
||||||
|
THREE("three_verification"),
|
||||||
|
/** 手机三要素认证 **/
|
||||||
|
PHONE_THREE("phone_three_verification"),
|
||||||
|
/** 银行卡四要素认证 **/
|
||||||
|
FOUR("four_verification");
|
||||||
|
|
||||||
|
private String fullname;
|
||||||
|
VerificationTypeEnum(String fullname){
|
||||||
|
this.fullname = fullname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFullName() {
|
||||||
|
return this.fullname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAsyncKey() {
|
||||||
|
return ForwardMqConstants.MQ_PREFIX + this.fullname ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatusChangeKey() {
|
||||||
|
return getAsyncKey() + "_status_update";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.consumer.providers;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.PhoneThreeVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.ThreeVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.service.FourFactorVerificationProvider;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.mq.dto.TopicMqMessage;
|
||||||
|
import com.newyetai.usercenter.user.consumer.FourFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SystemFourFactorVerificationProvider implements FourFactorVerificationProvider {
|
||||||
|
@Autowired
|
||||||
|
private FourFactorVerifyStatusUpdateHandler fourFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(TopicMqMessage<FourFactorVerificationDTO> message) {
|
||||||
|
log.info("系统手机号四要素处理->生成三要素数据 开始,参数:{}", JSONUtil.toJsonStr(message));
|
||||||
|
FourFactorVerificationDTO verificationDTO = message.getData();
|
||||||
|
Integer status = verificationDTO.getStatus();
|
||||||
|
if (!AuthStatusEnum.AUTH_SUCCESS.getType().equals(status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fourFactorVerifyStatusUpdateHandler.onMessage(verificationDTO);
|
||||||
|
try {
|
||||||
|
ThreeFactorVerificationDTO threeFactorVerificationDTO = ThreeFactorVerificationDTO.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.bankAccountNo(verificationDTO.getBankAccountNo())
|
||||||
|
.build();
|
||||||
|
threeFactorVerificationDTO.setStatus(verificationDTO.getStatus());
|
||||||
|
threeVerify.autoVerify(threeFactorVerificationDTO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("系统手机号四要素处理->生成三要素数据 异常,", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PhoneThreeFactorVerificationDTO phoneThreeFactorVerificationDTO = PhoneThreeFactorVerificationDTO.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.phone(verificationDTO.getPhone())
|
||||||
|
.build();
|
||||||
|
phoneThreeFactorVerificationDTO.setStatus(verificationDTO.getStatus());
|
||||||
|
phoneThreeVerify.autoVerify(phoneThreeFactorVerificationDTO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("系统手机号四要素处理->生成手机三要素数据 异常,", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PhoneThreeVerify phoneThreeVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreeVerify threeVerify;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.consumer.providers;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.RealNameTwoVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.service.PhoneThreeFactorVerificationProvider;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.mq.dto.TopicMqMessage;
|
||||||
|
import com.newyetai.usercenter.user.consumer.PhoneThreeFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SystemPhoneThreeFactorVerificationProvider implements PhoneThreeFactorVerificationProvider {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RealNameTwoVerify realNameTwoVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PhoneThreeFactorVerifyStatusUpdateHandler phoneThreeFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(TopicMqMessage<PhoneThreeFactorVerificationDTO> message) {
|
||||||
|
log.info("系统手机号三要素成功处理->生成二要素数据 开始,参数:{}", JSONUtil.toJsonStr(message));
|
||||||
|
PhoneThreeFactorVerificationDTO verificationDTO = message.getData();
|
||||||
|
Integer status = verificationDTO.getStatus();
|
||||||
|
if (!AuthStatusEnum.AUTH_SUCCESS.getType().equals(status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
phoneThreeFactorVerifyStatusUpdateHandler.onMessage(verificationDTO);
|
||||||
|
try {
|
||||||
|
RealNameTwoFactorVerificationDTO realNameTwoFactorVerificationDTO = RealNameTwoFactorVerificationDTO.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.build();
|
||||||
|
realNameTwoFactorVerificationDTO.setStatus(status);
|
||||||
|
realNameTwoVerify.autoVerify(realNameTwoFactorVerificationDTO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("系统手机号三要素处理->生成二要素数据 异常,", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.consumer.providers;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.RealNameTwoVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.service.ThreeFactorVerificationProvider;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.mq.dto.TopicMqMessage;
|
||||||
|
import com.newyetai.usercenter.user.consumer.ThreeFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SystemThreeFactorVerificationProvider implements ThreeFactorVerificationProvider {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RealNameTwoVerify realNameTwoVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreeFactorVerifyStatusUpdateHandler threeFactorVerifyStatusUpdateHandler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(TopicMqMessage<ThreeFactorVerificationDTO> message) {
|
||||||
|
log.info("系统三要素成功处理->生成二要素数据 开始,参数:{}", JSONUtil.toJsonStr(message));
|
||||||
|
ThreeFactorVerificationDTO verificationDTO = message.getData();
|
||||||
|
Integer status = verificationDTO.getStatus();
|
||||||
|
if (!AuthStatusEnum.AUTH_SUCCESS.getType().equals(status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
threeFactorVerifyStatusUpdateHandler.onMessage(verificationDTO);
|
||||||
|
try {
|
||||||
|
RealNameTwoFactorVerificationDTO realNameTwoFactorVerificationDTO = RealNameTwoFactorVerificationDTO.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.build();
|
||||||
|
realNameTwoFactorVerificationDTO.setStatus(verificationDTO.getStatus());
|
||||||
|
realNameTwoVerify.autoVerify(realNameTwoFactorVerificationDTO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("系统三要素处理->生成二要素数据 异常,", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.controller;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.*;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.FourVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.PhoneThreeVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.RealNameTwoVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.ThreeVerify;
|
||||||
|
import com.newyetai.alitaforward.verification.service.BankCardVerificationService;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.tkmybatis.pojo.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-21
|
||||||
|
*/
|
||||||
|
@Api("要素认证")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("factor_verify")
|
||||||
|
public class FactorVerificationContorller {
|
||||||
|
@Autowired
|
||||||
|
private FourVerify fourVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BankCardVerificationService bankCardVerificationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RealNameTwoVerify realNameTwoVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreeVerify threeVerify;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PhoneThreeVerify phoneThreeVerify;
|
||||||
|
|
||||||
|
@ApiOperation("二要素认证(同步)")
|
||||||
|
@PostMapping("/real_name/two/sync")
|
||||||
|
public AlitaResult<RealNameTwoFactorVerificationDTO> syncRealNameTwoAuthenticate(
|
||||||
|
@Validated @RequestBody RealNameTwoFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(realNameTwoVerify.sync(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("二要素认证(批量、同步)")
|
||||||
|
@PostMapping("/real_name/two/sync/batch")
|
||||||
|
public AlitaResult<List<RealNameTwoFactorVerificationDTO>> syncRealNameTwoAuthenticate(
|
||||||
|
@Validated @RequestBody List<RealNameTwoFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(realNameTwoVerify.sync(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("二要素认证(异步)")
|
||||||
|
@PostMapping("/real_name/two/async")
|
||||||
|
public AlitaResult<RealNameTwoFactorVerificationDTO> asyncRealNameTwoAuthenticate(
|
||||||
|
@Validated @RequestBody RealNameTwoFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(realNameTwoVerify.async(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("二要素认证(批量、异步)")
|
||||||
|
@PostMapping("/real_name/two/async/batch")
|
||||||
|
public AlitaResult<List<RealNameTwoFactorVerificationDTO>> asyncRealNameTwoAuthenticate(
|
||||||
|
@Validated @RequestBody List<RealNameTwoFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(realNameTwoVerify.async(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("手机三要素认证(同步)")
|
||||||
|
@PostMapping("/phone/three/sync")
|
||||||
|
public AlitaResult<PhoneThreeFactorVerificationDTO> syncPhoneThreeAuthenticate(
|
||||||
|
@Validated @RequestBody PhoneThreeFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(phoneThreeVerify.sync(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("手机三要素认证(批量、同步)")
|
||||||
|
@PostMapping("/phone/three/sync/batch")
|
||||||
|
public AlitaResult<List<PhoneThreeFactorVerificationDTO>> syncPhoneThreeAuthenticate(
|
||||||
|
@Validated @RequestBody List<PhoneThreeFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(phoneThreeVerify.sync(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("手机三要素认证(异步)")
|
||||||
|
@PostMapping("/phone/three/async")
|
||||||
|
public AlitaResult<PhoneThreeFactorVerificationDTO> asyncPhoneThreeAuthenticate(
|
||||||
|
@Validated @RequestBody PhoneThreeFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(phoneThreeVerify.async(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("手机三要素认证(批量、异步)")
|
||||||
|
@PostMapping("/phone/three/async/batch")
|
||||||
|
public AlitaResult<List<PhoneThreeFactorVerificationDTO>> asyncPhoneThreeAuthenticate(
|
||||||
|
@Validated @RequestBody List<PhoneThreeFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(phoneThreeVerify.async(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证(同步)")
|
||||||
|
@PostMapping("/three/sync")
|
||||||
|
public AlitaResult<ThreeFactorVerificationDTO> syncThreeAuthenticate(
|
||||||
|
@Validated @RequestBody ThreeFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(threeVerify.sync(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证(批量、同步)")
|
||||||
|
@PostMapping("/three/sync/batch")
|
||||||
|
public AlitaResult<List<ThreeFactorVerificationDTO>> syncThreeAuthenticate(
|
||||||
|
@Validated @RequestBody List<ThreeFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(threeVerify.sync(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证(异步)")
|
||||||
|
@PostMapping("/three/async")
|
||||||
|
public AlitaResult<ThreeFactorVerificationDTO> asyncThreeAuthenticate(
|
||||||
|
@Validated @RequestBody ThreeFactorVerificationDTO verificationInfo) {
|
||||||
|
return AlitaResult.success(threeVerify.async(verificationInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证(批量、异步)")
|
||||||
|
@PostMapping("/three/async/batch")
|
||||||
|
public AlitaResult<List<ThreeFactorVerificationDTO>> asyncThreeAuthenticate(
|
||||||
|
@Validated @RequestBody List<ThreeFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(threeVerify.async(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取匹配请求内容的三要素认证数据")
|
||||||
|
@PostMapping("/match_three/list")
|
||||||
|
public AlitaResult<List<ThreeFactorVerificationDTO>> queryMatchThreeList(@RequestBody List<FactorVerificationQueryDTO> queryDtoList){
|
||||||
|
return AlitaResult.success(threeVerify.queryListByData(queryDtoList));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证根据id获取")
|
||||||
|
@PostMapping("/three/find/id")
|
||||||
|
public AlitaResult<ThreeFactorVerificationDTO> threeFindById(@RequestParam("id") Long id){
|
||||||
|
return AlitaResult.success(threeVerify.findById(id));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证根据查询条件获取列表")
|
||||||
|
@PostMapping("/three/list")
|
||||||
|
public AlitaResult<List<ThreeFactorVerificationDTO>> threeList(@RequestBody FactorVerificationQueryDTO query){
|
||||||
|
query.setNeedPage(Boolean.FALSE);
|
||||||
|
return AlitaResult.success(threeVerify.list(query));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("三要素认证根据查询条件获取列表(分页)")
|
||||||
|
@PostMapping("/three/page")
|
||||||
|
public AlitaResult<Page<ThreeFactorVerificationDTO>> threePage(@RequestBody FactorVerificationQueryDTO query){
|
||||||
|
threeVerify.list(query);
|
||||||
|
return AlitaResult.success(query.getPageResult());
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证(同步)")
|
||||||
|
@PostMapping("/four/sync")
|
||||||
|
public AlitaResult<FourFactorVerificationDTO> syncFourAuthenticate(
|
||||||
|
@Validated @RequestBody FourFactorVerificationDTO verificationInfoList) {
|
||||||
|
return AlitaResult.success(fourVerify.sync(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证(批量、同步)")
|
||||||
|
@PostMapping("/four/sync/batch")
|
||||||
|
public AlitaResult<List<FourFactorVerificationDTO>> syncFourAuthenticate(
|
||||||
|
@Validated @RequestBody List<FourFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(fourVerify.sync(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证(异步)")
|
||||||
|
@PostMapping("/four/async")
|
||||||
|
public AlitaResult<FourFactorVerificationDTO> asyncFourAuthenticate(
|
||||||
|
@Validated @RequestBody FourFactorVerificationDTO verificationInfoList) {
|
||||||
|
return AlitaResult.success(fourVerify.async(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证(批量、异步)")
|
||||||
|
@PostMapping("/four/async/batch")
|
||||||
|
public AlitaResult<List<FourFactorVerificationDTO>> asyncFourAuthenticate(
|
||||||
|
@Validated @RequestBody List<FourFactorVerificationDTO> verificationInfoList) {
|
||||||
|
return AlitaResult.success(fourVerify.async(verificationInfoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证根据id获取")
|
||||||
|
@PostMapping("/four/find/id")
|
||||||
|
public AlitaResult<FourFactorVerificationDTO> fourFindById(@RequestParam("id") Long id){
|
||||||
|
return AlitaResult.success(fourVerify.findById(id));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("获取匹配请求内容的四要素认证数据")
|
||||||
|
@PostMapping("/match_four/list")
|
||||||
|
public AlitaResult<List<FourFactorVerificationDTO>> queryMatchFourList(@RequestBody List<FactorVerificationQueryDTO> queryDtoList){
|
||||||
|
return AlitaResult.success(fourVerify.queryListByData(queryDtoList));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证根据查询条件获取列表")
|
||||||
|
@PostMapping("/four/list")
|
||||||
|
public AlitaResult<List<FourFactorVerificationDTO>> fourList(@RequestBody FactorVerificationQueryDTO query){
|
||||||
|
query.setNeedPage(Boolean.FALSE);
|
||||||
|
return AlitaResult.success(fourVerify.list(query));
|
||||||
|
};
|
||||||
|
|
||||||
|
@ApiOperation("四要素认证根据查询条件获取列表(分页)")
|
||||||
|
@PostMapping("/four/page")
|
||||||
|
public AlitaResult<Page<FourFactorVerificationDTO>> fourPage(@RequestBody FactorVerificationQueryDTO query){
|
||||||
|
fourVerify.list(query);
|
||||||
|
return AlitaResult.success(query.getPageResult());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("白名单管理-->三、四要素查询合并为银行卡查询")
|
||||||
|
@PostMapping("/bank_card/page")
|
||||||
|
AlitaResult<List<BankCordVerificationResDTO>> bankCardPage(String cardNo,Integer status){
|
||||||
|
return AlitaResult.success(bankCardVerificationService.list(cardNo, status));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dao;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.BankCordVerificationResDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.entity.BankCardFourVerification;
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fzp
|
||||||
|
* @date 2021年9月6日13:42:17
|
||||||
|
*/
|
||||||
|
public interface BankCardVerificationMapper{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白名单管理-->三、四要素查询合并为银行卡查询
|
||||||
|
* @param cardNo
|
||||||
|
*/
|
||||||
|
@Select("select "
|
||||||
|
+ " t.id,t.card_no,t.real_name,t.bank_account_no,'' as phone,'三要素' as `type`, "
|
||||||
|
+ " (case t.authentication_source when '1' then '放心签' when '2' then '创蓝' when '3' then '系统' else '' end) as source, "
|
||||||
|
+ " t.status,t.fail_reason,t.deleted "
|
||||||
|
+ "from bank_card_three_verification t "
|
||||||
|
+ "where t.deleted = 0 and t.card_no = #{cardNo} "
|
||||||
|
+ "union all "
|
||||||
|
+ "select "
|
||||||
|
+ " f.id,f.card_no,f.real_name,f.bank_account_no,f.phone,'四要素' as `type`, "
|
||||||
|
+ " (case f.authentication_source when '1' then '放心签' when '2' then '创蓝' when '3' then '系统' else '' end) as source, "
|
||||||
|
+ " f.status,f.fail_reason,f.deleted "
|
||||||
|
+ "from bank_card_four_verification f "
|
||||||
|
+ "where f.deleted = 0 and f.card_no = #{cardNo} ")
|
||||||
|
List<BankCordVerificationResDTO> list(@Param("cardNo") String cardNo);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fzp
|
||||||
|
* @date 三、四要素合并银行卡查询
|
||||||
|
*/
|
||||||
|
@ApiModel("三、四要素合并银行卡查询")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class BankCordVerificationResDTO extends BaseDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 4820612112161649806L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@ApiModelProperty("要素类型")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源 1系统,2放心签,3创蓝")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@ApiModel("要素认证DTO")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@SuperBuilder
|
||||||
|
public class FactorVerificationDTO extends BaseDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2838128328843902963L;
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.annotation.trimAndUpper.TrimAndUpper;
|
||||||
|
import com.newyetai.common.dto.PageQueryDTO;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-07-01
|
||||||
|
*/
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class FactorVerificationQueryDTO extends PageQueryDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2357416347060650749L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Set<Long> ids;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.annotation.trimAndUpper.TrimAndUpper;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@ApiModel("四要素认证DTO")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class FourFactorVerificationDTO extends FactorVerificationDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -5514764157174505641L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
@NotBlank(message = "姓名不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
@NotBlank(message = "证件号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
@NotBlank(message = "银行卡号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
@NotBlank(message = "手机号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.annotation.trimAndUpper.TrimAndUpper;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel("手机号三要素认证DTO")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class PhoneThreeFactorVerificationDTO extends FactorVerificationDTO {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1594482919800883278L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
@NotBlank(message = "姓名不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
@NotBlank(message = "证件号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
@NotBlank(message = "手机号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.annotation.trimAndUpper.TrimAndUpper;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证DTO
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
* @date 2022/07/22
|
||||||
|
*/
|
||||||
|
@ApiModel("二要素认证DTO")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RealNameTwoFactorVerificationDTO extends FactorVerificationDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2114148883543603016L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
@NotBlank(message = "姓名不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
@NotBlank(message = "证件号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String cardNo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.annotation.trimAndUpper.TrimAndUpper;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@ApiModel("三要素认证DTO")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class ThreeFactorVerificationDTO extends FactorVerificationDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 656164023756231640L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
@NotBlank(message = "姓名不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
@NotBlank(message = "证件号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
@NotBlank(message = "银行卡号不能为空")
|
||||||
|
@TrimAndUpper
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.aop.framework.AopContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.source.FactorVerificationSourceService;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.util.EnvironmentUtils;
|
||||||
|
import com.newyetai.common.util.JsonUtils;
|
||||||
|
import com.newyetai.frame.redis.dto.LockDTO;
|
||||||
|
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||||
|
import com.newyetai.mq.consumer.handler.ITopicMqHandler;
|
||||||
|
import com.newyetai.mq.dto.TopicMqMessage;
|
||||||
|
import com.newyetai.mq.util.MqSendUtils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要素校验顶层接口
|
||||||
|
*
|
||||||
|
* @author cheny
|
||||||
|
* @date 2022/08/11
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@SuppressWarnings("rawtypes,unchecked")
|
||||||
|
public abstract class AbstractVerify<T extends FactorVerificationDTO> implements IVerify<T>, ITopicMqHandler<T>{
|
||||||
|
|
||||||
|
private static final Integer DEFAULT_TYPE = FactorVerificationSourceTypeEnum.CL.getType();
|
||||||
|
|
||||||
|
static final Map<Integer, FactorVerificationSourceService> SOURCE_SERVICE_MAP = Maps.newConcurrentMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终态通知key
|
||||||
|
* @return
|
||||||
|
* @author sr on 2023-11-27
|
||||||
|
*/
|
||||||
|
final String statusChangeRoutingKey() {
|
||||||
|
return getType().getStatusChangeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getRoutingKey() {
|
||||||
|
return getType().getAsyncKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void onMessage(TopicMqMessage<T> message) {
|
||||||
|
T verificationDTO = message.getData();
|
||||||
|
log.info("【MQ】异步处理认证开始,参数:{}", JsonUtils.toJsonString(verificationDTO));
|
||||||
|
if (verificationDTO == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
T sync = this.sync(verificationDTO);
|
||||||
|
log.info("【MQ】异步处理认证结束,参数:{}", JsonUtils.toJsonString(sync));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("【MQ】异步处理认证异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 幂等创建
|
||||||
|
abstract T createAndGet(T t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到锁
|
||||||
|
*
|
||||||
|
* @param t t
|
||||||
|
* @return {@link LockDTO}
|
||||||
|
*/
|
||||||
|
abstract LockDTO getLock(T t);
|
||||||
|
|
||||||
|
// 上一级认证创建
|
||||||
|
abstract void autoVerify(T t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步校验前置hook
|
||||||
|
*
|
||||||
|
* @param t t
|
||||||
|
* @return {@link T}
|
||||||
|
*/
|
||||||
|
protected T syncBeforeVerify(T t) {
|
||||||
|
// 认证源根据配置文件不同调用不同SDK 1放心签、2创蓝
|
||||||
|
String source = EnvironmentUtils.getProperty("alita.authenticationSource");
|
||||||
|
int authenticationSource = DEFAULT_TYPE;
|
||||||
|
try {
|
||||||
|
authenticationSource = Integer.parseInt(source);
|
||||||
|
//如果不是这两种认证源,用默认的源
|
||||||
|
if (!(FactorVerificationSourceTypeEnum.CL.getType().equals(authenticationSource)
|
||||||
|
|| FactorVerificationSourceTypeEnum.FXQ.getType().equals(authenticationSource))) {
|
||||||
|
authenticationSource = DEFAULT_TYPE;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
//doNothing
|
||||||
|
}
|
||||||
|
t.setAuthenticationSource(authenticationSource);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 真正执行校验逻辑的方法
|
||||||
|
*
|
||||||
|
* @param verifyDto 验证dto
|
||||||
|
* @return {@link T}
|
||||||
|
*/
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
|
public T doSyncVerify(T verifyDto) {
|
||||||
|
String failReason = verifyDto.getFailReason();
|
||||||
|
//如果校验失败了 直接返回
|
||||||
|
if (StringUtils.isNotEmpty(failReason)) {
|
||||||
|
return verifyDto;
|
||||||
|
}
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verifyDto);
|
||||||
|
try {
|
||||||
|
Assert.isTrue(RedissonUtils.tryLock(lockDTO), "要素认证正在处理中,请稍后再试");
|
||||||
|
T preVerifyDto = createAndGet(verifyDto);
|
||||||
|
//如果不是待认证的数直接返回
|
||||||
|
if (!AuthStatusEnum.NOT_AUTH.getType().equals(preVerifyDto.getStatus())) {
|
||||||
|
return preVerifyDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
return realVerification(preVerifyDto);
|
||||||
|
} finally {
|
||||||
|
RedissonUtils.unlock(lockDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract T realVerification(T verificationDTO);
|
||||||
|
|
||||||
|
T syncVerifyWrapper(T t) {
|
||||||
|
T beforeVerify = syncBeforeVerify(t);
|
||||||
|
|
||||||
|
T doVerify = (T) ((AbstractVerify) AopContext.currentProxy()).doSyncVerify(beforeVerify);
|
||||||
|
|
||||||
|
Integer status = doVerify.getStatus();
|
||||||
|
//如果执行到了终态 发送消息通知
|
||||||
|
if (AuthStatusEnum.AUTH_FAIL.getType().equals(status)
|
||||||
|
|| AuthStatusEnum.AUTH_SUCCESS.getType().equals(status)) {
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(doVerify));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), doVerify);
|
||||||
|
}
|
||||||
|
return doVerify;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步校验
|
||||||
|
*
|
||||||
|
* @param list 列表
|
||||||
|
* @return {@link List}<{@link T}>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<T> sync(List<T> list) {
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
return list.stream().map(this::syncVerifyWrapper).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------- async -------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步校验前置hook
|
||||||
|
*
|
||||||
|
* @param t t
|
||||||
|
* @return {@link T}
|
||||||
|
*/
|
||||||
|
protected T asyncBeforeVerify(T t) {
|
||||||
|
return syncBeforeVerify(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 真正执行校验逻辑的方法
|
||||||
|
*
|
||||||
|
* @param verifyDto 验证dto
|
||||||
|
* @return {@link T}
|
||||||
|
*/
|
||||||
|
protected T doAsyncVerify(T verifyDto) {
|
||||||
|
String failReason = verifyDto.getFailReason();
|
||||||
|
//如果校验失败了 直接返回
|
||||||
|
if (StringUtils.isNotEmpty(failReason)) {
|
||||||
|
return verifyDto;
|
||||||
|
}
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verifyDto);
|
||||||
|
try {
|
||||||
|
Assert.isTrue(RedissonUtils.tryLock(lockDTO), "要素认证正在处理中,请稍后再试");
|
||||||
|
T preVerifyDto = createAndGet(verifyDto);
|
||||||
|
//如果不是待认证的数直接返回
|
||||||
|
if (AuthStatusEnum.NOT_AUTH.getType().equals(preVerifyDto.getStatus())) {
|
||||||
|
//mq异步处理认证
|
||||||
|
log.info("async【MQ】要素认证异步处理,参数:{}", JSONUtil.toJsonStr(preVerifyDto));
|
||||||
|
MqSendUtils.send(getRoutingKey(), preVerifyDto);
|
||||||
|
}
|
||||||
|
return preVerifyDto;
|
||||||
|
} finally {
|
||||||
|
RedissonUtils.unlock(lockDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
T asyncVerifyWrapper(T t) {
|
||||||
|
T beforeVerify = asyncBeforeVerify(t);
|
||||||
|
|
||||||
|
T doVerify = doAsyncVerify(beforeVerify);
|
||||||
|
|
||||||
|
Integer status = doVerify.getStatus();
|
||||||
|
//如果执行到了终态 发送消息通知
|
||||||
|
if (AuthStatusEnum.AUTH_FAIL.getType().equals(status)
|
||||||
|
|| AuthStatusEnum.AUTH_SUCCESS.getType().equals(status)) {
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(doVerify));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), doVerify);
|
||||||
|
}
|
||||||
|
return doVerify;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<T> async(List<T> list) {
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
return list.stream().map(this::asyncVerifyWrapper).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.dao.FourVerificationMapper;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.entity.BankCardFourVerification;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.mapstruct.FourVerificationMapMapper;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.common.validation.util.ValidateUtils;
|
||||||
|
import com.newyetai.frame.redis.aop.annotation.AutoUnLock;
|
||||||
|
import com.newyetai.frame.redis.dto.LockDTO;
|
||||||
|
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||||
|
import com.newyetai.mq.util.MqSendUtils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class FourVerify extends AbstractVerify<FourFactorVerificationDTO> implements IQueryVerify<FourFactorVerificationDTO> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FourVerificationMapper fourVerificationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected FourFactorVerificationDTO syncBeforeVerify(FourFactorVerificationDTO verificationDTO) {
|
||||||
|
StringJoiner stringJoiner = new StringJoiner("、");
|
||||||
|
if (!ValidateUtils.checkRealName(verificationDTO.getRealName())) {
|
||||||
|
stringJoiner.add("姓名格式有误");
|
||||||
|
}
|
||||||
|
if (!ValidateUtils.isIdCard(verificationDTO.getCardNo())) {
|
||||||
|
stringJoiner.add("证件号格式有误");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(verificationDTO.getBankAccountNo())) {
|
||||||
|
stringJoiner.add("银行卡号为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(verificationDTO.getPhone())) {
|
||||||
|
stringJoiner.add("手机号为空");
|
||||||
|
}
|
||||||
|
String failReason = stringJoiner.toString();
|
||||||
|
if (StringUtils.isNotBlank(failReason)) {
|
||||||
|
verificationDTO.setFailReason(failReason);
|
||||||
|
} else {
|
||||||
|
//校验成功调用
|
||||||
|
super.syncBeforeVerify(verificationDTO);
|
||||||
|
}
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
FourFactorVerificationDTO createAndGet(FourFactorVerificationDTO verificationDTO) {
|
||||||
|
BankCardFourVerification bankCardFourVerification = fourVerificationMapper.selectInfo(verificationDTO);
|
||||||
|
if (bankCardFourVerification == null) {
|
||||||
|
//认证库不存在,以默认状态入库——"未认证"
|
||||||
|
verificationDTO.setStatus(AuthStatusEnum.NOT_AUTH.getType());
|
||||||
|
bankCardFourVerification = FourVerificationMapMapper.INSTANCE.toEntity(verificationDTO);
|
||||||
|
fourVerificationMapper.saveEntity(bankCardFourVerification);
|
||||||
|
}
|
||||||
|
return FourVerificationMapMapper.INSTANCE.toDto(bankCardFourVerification);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
LockDTO getLock(FourFactorVerificationDTO verificationDTO) {
|
||||||
|
return LockDTO.builder().methodName("verify:four").tryLockWaitTime(0L)
|
||||||
|
.arg(verificationDTO.getRealName())
|
||||||
|
.arg(verificationDTO.getCardNo())
|
||||||
|
.arg(verificationDTO.getBankAccountNo())
|
||||||
|
.arg(verificationDTO.getPhone())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AutoUnLock
|
||||||
|
public void autoVerify(FourFactorVerificationDTO verificationDTO) {
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verificationDTO);
|
||||||
|
Assert.isTrue(RedissonUtils.tryLockAutomatically(lockDTO), "请勿重复校验四要素");
|
||||||
|
|
||||||
|
BankCardFourVerification verificationEntity = fourVerificationMapper.selectInfo(verificationDTO);
|
||||||
|
|
||||||
|
if (Objects.nonNull(verificationEntity)) {
|
||||||
|
if (AuthStatusEnum.AUTH_SUCCESS.getType().equals(verificationEntity.getStatus())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verificationEntity.setAuthenticationSource(FactorVerificationSourceTypeEnum.SYS.getType());
|
||||||
|
verificationEntity.setStatus(AuthStatusEnum.AUTH_SUCCESS.getType());
|
||||||
|
fourVerificationMapper.updateEntitySelective(verificationEntity,
|
||||||
|
UserContextHolder.getLoginUserId());
|
||||||
|
} else {
|
||||||
|
verificationEntity =
|
||||||
|
BankCardFourVerification.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.phone(verificationDTO.getPhone())
|
||||||
|
.bankAccountNo(verificationDTO.getBankAccountNo())
|
||||||
|
.authenticationSource(FactorVerificationSourceTypeEnum.SYS.getType())
|
||||||
|
.status(AuthStatusEnum.AUTH_SUCCESS.getType())
|
||||||
|
.build();
|
||||||
|
fourVerificationMapper.saveEntity(verificationEntity);
|
||||||
|
}
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(verificationDTO));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), verificationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FourFactorVerificationDTO> list(FactorVerificationQueryDTO queryDTO) {
|
||||||
|
return fourVerificationMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FourFactorVerificationDTO> queryListByData(List<FactorVerificationQueryDTO> queryDTOList) {
|
||||||
|
List<FourFactorVerificationDTO> resultList = Lists
|
||||||
|
.newArrayListWithCapacity(queryDTOList.size());
|
||||||
|
if (CollectionUtils.isEmpty(queryDTOList)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
List<FourFactorVerificationDTO> bankCardThreeVerifications = fourVerificationMapper
|
||||||
|
.findFinishStatusData();
|
||||||
|
Map<String, FourFactorVerificationDTO> threeVerificationMap = bankCardThreeVerifications
|
||||||
|
.stream().collect(
|
||||||
|
Collectors.toMap(k -> k.getRealName() + k.getCardNo() + k.getBankAccountNo() + k.getPhone(), v -> v, (v1, v2) -> v1));
|
||||||
|
|
||||||
|
for (FactorVerificationQueryDTO queryDTO : queryDTOList) {
|
||||||
|
FourFactorVerificationDTO FourFactorVerificationDTO = threeVerificationMap
|
||||||
|
.get(queryDTO.getRealName() + queryDTO.getCardNo() + queryDTO.getBankAccountNo() + queryDTO
|
||||||
|
.getPhone());
|
||||||
|
if (FourFactorVerificationDTO != null) {
|
||||||
|
resultList.add(FourFactorVerificationDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FourFactorVerificationDTO findById(Long id) {
|
||||||
|
FourFactorVerificationDTO fourFactorVerificationDTO = null;
|
||||||
|
BankCardFourVerification entity = fourVerificationMapper.getById(id);
|
||||||
|
if (entity != null) {
|
||||||
|
fourFactorVerificationDTO = FourVerificationMapMapper.INSTANCE.toDto(entity);
|
||||||
|
}
|
||||||
|
return fourFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
FourFactorVerificationDTO realVerification(FourFactorVerificationDTO verificationDTO) {
|
||||||
|
Integer authenticationSource = verificationDTO.getAuthenticationSource();
|
||||||
|
SOURCE_SERVICE_MAP.get(authenticationSource).fourVerify(verificationDTO);
|
||||||
|
//更新状态
|
||||||
|
BankCardFourVerification entity = FourVerificationMapMapper.INSTANCE
|
||||||
|
.toEntity(verificationDTO);
|
||||||
|
fourVerificationMapper.updateEntitySelective(entity, UserContextHolder.getLoginUserId());
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VerificationTypeEnum getType() {
|
||||||
|
return VerificationTypeEnum.FOUR;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要素查询顶层接口
|
||||||
|
*
|
||||||
|
* @author cheny
|
||||||
|
* @date 2022/08/11
|
||||||
|
*/
|
||||||
|
public interface IQueryVerify<T extends FactorVerificationDTO> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据参数查list
|
||||||
|
*
|
||||||
|
* @param queryDTO 查询DTO
|
||||||
|
* @return {@link List}<{@link T}>
|
||||||
|
*/
|
||||||
|
List<T> list(FactorVerificationQueryDTO queryDTO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据传来的数据,查出认证库中存在的数据
|
||||||
|
*
|
||||||
|
* @param queryDTOList 查询DTO集合
|
||||||
|
* @return {@link List}<{@link T}>
|
||||||
|
*/
|
||||||
|
List<T> queryListByData(List<FactorVerificationQueryDTO> queryDTOList);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取
|
||||||
|
*
|
||||||
|
* @param id id
|
||||||
|
* @return {@link T}
|
||||||
|
*/
|
||||||
|
T findById(Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要素校验顶层接口
|
||||||
|
*
|
||||||
|
* @author cheny
|
||||||
|
* @date 2022/08/11
|
||||||
|
*/
|
||||||
|
public interface IVerify<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步校验
|
||||||
|
*
|
||||||
|
* @param list 列表
|
||||||
|
* @return {@link List}<{@link T}>
|
||||||
|
*/
|
||||||
|
List<T> sync(List<T> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步校验
|
||||||
|
*
|
||||||
|
* @param list 列表
|
||||||
|
* @return {@link List}<{@link T}>
|
||||||
|
*/
|
||||||
|
List<T> async(List<T> list);
|
||||||
|
|
||||||
|
default T sync(T t) {
|
||||||
|
List<T> syncSingle = new ArrayList<>(1);
|
||||||
|
syncSingle.add(t);
|
||||||
|
return sync(syncSingle).get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
default T async(T t) {
|
||||||
|
List<T> asyncSingle = new ArrayList<>(1);
|
||||||
|
asyncSingle.add(t);
|
||||||
|
return async(asyncSingle).get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VerificationTypeEnum getType();
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.newyetai.alitaforward.common.mq.constant.ForwardMqConstants;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.phoneThree.dao.PhoneThreeVerificationMapper;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.phoneThree.entity.PhoneThreeVerification;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.phoneThree.mapstruct.PhoneThreeVerificationMapMapper;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.common.validation.util.ValidateUtils;
|
||||||
|
import com.newyetai.frame.redis.aop.annotation.AutoUnLock;
|
||||||
|
import com.newyetai.frame.redis.dto.LockDTO;
|
||||||
|
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||||
|
import com.newyetai.mq.util.MqSendUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class PhoneThreeVerify extends AbstractVerify<PhoneThreeFactorVerificationDTO> implements IQueryVerify<PhoneThreeFactorVerificationDTO> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PhoneThreeVerificationMapper phoneThreeVerificationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PhoneThreeFactorVerificationDTO syncBeforeVerify(PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
StringJoiner stringJoiner = new StringJoiner("、");
|
||||||
|
if (!ValidateUtils.checkRealName(verificationDTO.getRealName())) {
|
||||||
|
stringJoiner.add("姓名格式有误");
|
||||||
|
}
|
||||||
|
if (!ValidateUtils.isIdCard(verificationDTO.getCardNo())) {
|
||||||
|
stringJoiner.add("证件号格式有误");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(verificationDTO.getPhone())) {
|
||||||
|
stringJoiner.add("手机号为空");
|
||||||
|
}
|
||||||
|
String failReason = stringJoiner.toString();
|
||||||
|
if (StringUtils.isNotBlank(failReason)) {
|
||||||
|
verificationDTO.setFailReason(failReason);
|
||||||
|
} else {
|
||||||
|
//校验成功调用
|
||||||
|
super.syncBeforeVerify(verificationDTO);
|
||||||
|
}
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
PhoneThreeFactorVerificationDTO createAndGet(PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
PhoneThreeVerification entity = phoneThreeVerificationMapper.find(verificationDTO);
|
||||||
|
if (entity == null) {
|
||||||
|
//认证库不存在,以默认状态入库——"未认证"
|
||||||
|
verificationDTO.setStatus(AuthStatusEnum.NOT_AUTH.getType());
|
||||||
|
entity = PhoneThreeVerificationMapMapper.INSTANCE.exchange(verificationDTO);
|
||||||
|
phoneThreeVerificationMapper.saveEntity(entity);
|
||||||
|
}
|
||||||
|
return PhoneThreeVerificationMapMapper.INSTANCE.exchange(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
LockDTO getLock(PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
return LockDTO.builder()
|
||||||
|
.methodName("verify:three:phone")
|
||||||
|
.tryLockWaitTime(0L)
|
||||||
|
.arg(verificationDTO.getRealName())
|
||||||
|
.arg(verificationDTO.getCardNo())
|
||||||
|
.arg(verificationDTO.getPhone())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AutoUnLock
|
||||||
|
public void autoVerify(PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verificationDTO);
|
||||||
|
Assert.isTrue(RedissonUtils.tryLockAutomatically(lockDTO), "请勿重复校验手机三要素");
|
||||||
|
|
||||||
|
PhoneThreeVerification verificationEntity = phoneThreeVerificationMapper.find(verificationDTO);
|
||||||
|
|
||||||
|
if (Objects.nonNull(verificationEntity)) {
|
||||||
|
if (!AuthStatusEnum.NOT_AUTH.getType().equals(verificationEntity.getStatus())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verificationEntity.setAuthenticationSource(FactorVerificationSourceTypeEnum.SYS.getType());
|
||||||
|
verificationEntity.setStatus(verificationDTO.getStatus());
|
||||||
|
phoneThreeVerificationMapper.updateEntitySelective(verificationEntity,
|
||||||
|
UserContextHolder.getLoginUserId());
|
||||||
|
} else {
|
||||||
|
verificationEntity =
|
||||||
|
PhoneThreeVerification.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.phone(verificationDTO.getPhone())
|
||||||
|
.authenticationSource(FactorVerificationSourceTypeEnum.SYS.getType())
|
||||||
|
.status(verificationDTO.getStatus())
|
||||||
|
.build();
|
||||||
|
phoneThreeVerificationMapper.saveEntity(verificationEntity);
|
||||||
|
}
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(verificationDTO));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), verificationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PhoneThreeFactorVerificationDTO> list(FactorVerificationQueryDTO queryDTO) {
|
||||||
|
return phoneThreeVerificationMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PhoneThreeFactorVerificationDTO> queryListByData(List<FactorVerificationQueryDTO> queryDTOList) {
|
||||||
|
List<PhoneThreeFactorVerificationDTO> resultList = Lists
|
||||||
|
.newArrayListWithCapacity(queryDTOList.size());
|
||||||
|
if (CollectionUtils.isEmpty(queryDTOList)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
List<PhoneThreeFactorVerificationDTO> bankCardThreeVerifications = phoneThreeVerificationMapper
|
||||||
|
.findFinishStatusData();
|
||||||
|
Map<String, PhoneThreeFactorVerificationDTO> threeVerificationMap = bankCardThreeVerifications
|
||||||
|
.stream().collect(
|
||||||
|
Collectors.toMap(k -> k.getRealName() + k.getCardNo() + k.getPhone(), v -> v, (v1, v2) -> v1));
|
||||||
|
|
||||||
|
for (FactorVerificationQueryDTO queryDTO : queryDTOList) {
|
||||||
|
PhoneThreeFactorVerificationDTO PhoneThreeFactorVerificationDTO = threeVerificationMap
|
||||||
|
.get(queryDTO.getRealName() + queryDTO.getCardNo() + queryDTO.getPhone());
|
||||||
|
if (PhoneThreeFactorVerificationDTO != null) {
|
||||||
|
resultList.add(PhoneThreeFactorVerificationDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PhoneThreeFactorVerificationDTO findById(Long id) {
|
||||||
|
PhoneThreeFactorVerificationDTO threeFactorVerificationDTO = null;
|
||||||
|
PhoneThreeVerification entity = phoneThreeVerificationMapper.getById(id);
|
||||||
|
if (entity != null) {
|
||||||
|
threeFactorVerificationDTO = PhoneThreeVerificationMapMapper.INSTANCE.exchange(entity);
|
||||||
|
}
|
||||||
|
return threeFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
PhoneThreeFactorVerificationDTO realVerification(
|
||||||
|
PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
Integer authenticationSource = verificationDTO.getAuthenticationSource();
|
||||||
|
SOURCE_SERVICE_MAP.get(authenticationSource).phoneThreeVerify(verificationDTO);
|
||||||
|
//更新状态
|
||||||
|
PhoneThreeVerification entity = PhoneThreeVerificationMapMapper.INSTANCE.exchange(verificationDTO);
|
||||||
|
phoneThreeVerificationMapper.updateEntitySelective(entity, UserContextHolder.getLoginUserId());
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VerificationTypeEnum getType() {
|
||||||
|
return VerificationTypeEnum.PHONE_THREE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.convert.RealNameTwoVerificationConvert;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.dao.RealNameTwoVerificationMapper;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.entity.RealNameTwoVerification;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.common.validation.util.ValidateUtils;
|
||||||
|
import com.newyetai.frame.redis.aop.annotation.AutoUnLock;
|
||||||
|
import com.newyetai.frame.redis.dto.LockDTO;
|
||||||
|
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||||
|
import com.newyetai.mq.util.MqSendUtils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RealNameTwoVerify extends AbstractVerify<RealNameTwoFactorVerificationDTO> implements IQueryVerify<RealNameTwoFactorVerificationDTO> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RealNameTwoVerificationMapper realNameTwoVerificationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected RealNameTwoFactorVerificationDTO syncBeforeVerify(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
StringJoiner stringJoiner = new StringJoiner("、");
|
||||||
|
if (!ValidateUtils.checkRealName(verificationDTO.getRealName())) {
|
||||||
|
stringJoiner.add("姓名格式有误");
|
||||||
|
}
|
||||||
|
if (!ValidateUtils.isIdCard(verificationDTO.getCardNo())) {
|
||||||
|
stringJoiner.add("证件号格式有误");
|
||||||
|
}
|
||||||
|
String failReason = stringJoiner.toString();
|
||||||
|
if (StringUtils.isNotBlank(failReason)) {
|
||||||
|
verificationDTO.setFailReason(failReason);
|
||||||
|
} else {
|
||||||
|
//校验成功调用
|
||||||
|
super.syncBeforeVerify(verificationDTO);
|
||||||
|
}
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
RealNameTwoFactorVerificationDTO createAndGet(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
RealNameTwoVerification entity = realNameTwoVerificationMapper.selectInfo(verificationDTO);
|
||||||
|
if (entity == null) {
|
||||||
|
//认证库不存在,以默认状态入库——"未认证"
|
||||||
|
verificationDTO.setStatus(AuthStatusEnum.NOT_AUTH.getType());
|
||||||
|
entity = RealNameTwoVerificationConvert.INSTANCE.convert(verificationDTO);
|
||||||
|
realNameTwoVerificationMapper.saveEntity(entity);
|
||||||
|
}
|
||||||
|
return RealNameTwoVerificationConvert.INSTANCE.convertDTO(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
LockDTO getLock(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
return LockDTO.builder()
|
||||||
|
.methodName("verify:real_name:two")
|
||||||
|
.tryLockWaitTime(0L)
|
||||||
|
.arg(verificationDTO.getRealName())
|
||||||
|
.arg(verificationDTO.getCardNo())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AutoUnLock
|
||||||
|
public void autoVerify(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verificationDTO);
|
||||||
|
Assert.isTrue(RedissonUtils.tryLockAutomatically(lockDTO), "请勿重复校验二要素");
|
||||||
|
|
||||||
|
RealNameTwoVerification realNameTwoVerification = realNameTwoVerificationMapper.selectInfo(verificationDTO);
|
||||||
|
|
||||||
|
if (Objects.nonNull(realNameTwoVerification)) {
|
||||||
|
if (!AuthStatusEnum.NOT_AUTH.getType().equals(realNameTwoVerification.getStatus())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
realNameTwoVerification.setAuthenticationSource(FactorVerificationSourceTypeEnum.SYS.getType());
|
||||||
|
realNameTwoVerification.setStatus(verificationDTO.getStatus());
|
||||||
|
realNameTwoVerificationMapper.updateEntitySelective(realNameTwoVerification,
|
||||||
|
UserContextHolder.getLoginUserId());
|
||||||
|
} else {
|
||||||
|
realNameTwoVerification =
|
||||||
|
RealNameTwoVerification.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.authenticationSource(FactorVerificationSourceTypeEnum.SYS.getType())
|
||||||
|
.status(verificationDTO.getStatus())
|
||||||
|
.build();
|
||||||
|
realNameTwoVerificationMapper.saveEntity(realNameTwoVerification);
|
||||||
|
}
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(verificationDTO));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), verificationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RealNameTwoFactorVerificationDTO> list(FactorVerificationQueryDTO queryDTO) {
|
||||||
|
return realNameTwoVerificationMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RealNameTwoFactorVerificationDTO> queryListByData(List<FactorVerificationQueryDTO> queryDTOList) {
|
||||||
|
List<RealNameTwoFactorVerificationDTO> resultList = Lists
|
||||||
|
.newArrayListWithCapacity(queryDTOList.size());
|
||||||
|
if (CollectionUtils.isEmpty(queryDTOList)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
List<RealNameTwoFactorVerificationDTO> bankCardThreeVerifications = realNameTwoVerificationMapper
|
||||||
|
.findFinishStatusData();
|
||||||
|
Map<String, RealNameTwoFactorVerificationDTO> threeVerificationMap = bankCardThreeVerifications
|
||||||
|
.stream().collect(
|
||||||
|
Collectors.toMap(k -> k.getRealName() + k.getCardNo(), v -> v, (v1, v2) -> v1));
|
||||||
|
|
||||||
|
for (FactorVerificationQueryDTO queryDTO : queryDTOList) {
|
||||||
|
RealNameTwoFactorVerificationDTO RealNameTwoFactorVerificationDTO = threeVerificationMap
|
||||||
|
.get(queryDTO.getRealName() + queryDTO.getCardNo());
|
||||||
|
if (RealNameTwoFactorVerificationDTO != null) {
|
||||||
|
resultList.add(RealNameTwoFactorVerificationDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RealNameTwoFactorVerificationDTO findById(Long id) {
|
||||||
|
RealNameTwoFactorVerificationDTO threeFactorVerificationDTO = null;
|
||||||
|
RealNameTwoVerification entity = realNameTwoVerificationMapper.getById(id);
|
||||||
|
if (entity != null) {
|
||||||
|
threeFactorVerificationDTO = RealNameTwoVerificationConvert.INSTANCE.convertDTO(entity);
|
||||||
|
}
|
||||||
|
return threeFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
RealNameTwoFactorVerificationDTO realVerification(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
Integer authenticationSource = verificationDTO.getAuthenticationSource();
|
||||||
|
SOURCE_SERVICE_MAP.get(authenticationSource).twoVerify(verificationDTO);
|
||||||
|
RealNameTwoVerification entity = RealNameTwoVerificationConvert.INSTANCE.convert(verificationDTO);
|
||||||
|
realNameTwoVerificationMapper.updateEntitySelective(entity, UserContextHolder.getLoginUserId());
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VerificationTypeEnum getType() {
|
||||||
|
return VerificationTypeEnum.TWO;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.three.dao.ThreeVerificationMapper;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.three.entity.BankCardThreeVerification;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.three.mapstruct.ThreeVerificationMapMapper;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import com.newyetai.common.util.UserContextHolder;
|
||||||
|
import com.newyetai.common.validation.util.ValidateUtils;
|
||||||
|
import com.newyetai.frame.redis.aop.annotation.AutoUnLock;
|
||||||
|
import com.newyetai.frame.redis.dto.LockDTO;
|
||||||
|
import com.newyetai.frame.redis.redisson.RedissonUtils;
|
||||||
|
import com.newyetai.mq.util.MqSendUtils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ThreeVerify extends AbstractVerify<ThreeFactorVerificationDTO> implements IQueryVerify<ThreeFactorVerificationDTO> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ThreeVerificationMapper threeVerificationMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ThreeFactorVerificationDTO syncBeforeVerify(ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
StringJoiner stringJoiner = new StringJoiner("、");
|
||||||
|
if (!ValidateUtils.checkRealName(verificationDTO.getRealName())) {
|
||||||
|
stringJoiner.add("姓名格式有误");
|
||||||
|
}
|
||||||
|
if (!ValidateUtils.isIdCard(verificationDTO.getCardNo())) {
|
||||||
|
stringJoiner.add("证件号格式有误");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(verificationDTO.getBankAccountNo())) {
|
||||||
|
stringJoiner.add("银行卡号为空");
|
||||||
|
}
|
||||||
|
String failReason = stringJoiner.toString();
|
||||||
|
if (StringUtils.isNotBlank(failReason)) {
|
||||||
|
verificationDTO.setFailReason(failReason);
|
||||||
|
} else {
|
||||||
|
//校验成功调用
|
||||||
|
super.syncBeforeVerify(verificationDTO);
|
||||||
|
}
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ThreeFactorVerificationDTO createAndGet(ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
BankCardThreeVerification entity = threeVerificationMapper.find(verificationDTO);
|
||||||
|
if (entity == null) {
|
||||||
|
//认证库不存在,以默认状态入库——"未认证"
|
||||||
|
verificationDTO.setStatus(AuthStatusEnum.NOT_AUTH.getType());
|
||||||
|
entity = ThreeVerificationMapMapper.INSTANCE.toEntity(verificationDTO);
|
||||||
|
threeVerificationMapper.saveEntity(entity);
|
||||||
|
}
|
||||||
|
return ThreeVerificationMapMapper.INSTANCE.toDto(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AutoUnLock
|
||||||
|
public void autoVerify(ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
//拿锁
|
||||||
|
LockDTO lockDTO = getLock(verificationDTO);
|
||||||
|
Assert.isTrue(RedissonUtils.tryLockAutomatically(lockDTO), "请勿重复校验三要素");
|
||||||
|
|
||||||
|
BankCardThreeVerification verificationEntity = threeVerificationMapper.find(verificationDTO);
|
||||||
|
|
||||||
|
if (Objects.nonNull(verificationEntity)) {
|
||||||
|
if (!AuthStatusEnum.NOT_AUTH.getType().equals(verificationEntity.getStatus())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verificationEntity.setAuthenticationSource(FactorVerificationSourceTypeEnum.SYS.getType());
|
||||||
|
verificationEntity.setStatus(verificationDTO.getStatus());
|
||||||
|
threeVerificationMapper.updateEntitySelective(verificationEntity,
|
||||||
|
UserContextHolder.getLoginUserId());
|
||||||
|
} else {
|
||||||
|
verificationEntity =
|
||||||
|
BankCardThreeVerification.builder()
|
||||||
|
.realName(verificationDTO.getRealName())
|
||||||
|
.cardNo(verificationDTO.getCardNo())
|
||||||
|
.bankAccountNo(verificationDTO.getBankAccountNo())
|
||||||
|
.authenticationSource(FactorVerificationSourceTypeEnum.SYS.getType())
|
||||||
|
.status(verificationDTO.getStatus())
|
||||||
|
.build();
|
||||||
|
threeVerificationMapper.saveEntity(verificationEntity);
|
||||||
|
}
|
||||||
|
log.info("【MQ】通知认证状态变更,参数:{}", JSONUtil.toJsonStr(verificationDTO));
|
||||||
|
MqSendUtils.send(statusChangeRoutingKey(), verificationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
LockDTO getLock(ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
return LockDTO.builder()
|
||||||
|
.methodName("verify:three")
|
||||||
|
.tryLockWaitTime(0L)
|
||||||
|
.arg(verificationDTO.getRealName())
|
||||||
|
.arg(verificationDTO.getCardNo())
|
||||||
|
.arg(verificationDTO.getBankAccountNo())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ThreeFactorVerificationDTO> list(FactorVerificationQueryDTO queryDTO) {
|
||||||
|
return threeVerificationMapper.list(queryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ThreeFactorVerificationDTO> queryListByData(List<FactorVerificationQueryDTO> queryDTOList) {
|
||||||
|
List<ThreeFactorVerificationDTO> resultList = Lists
|
||||||
|
.newArrayListWithCapacity(queryDTOList.size());
|
||||||
|
if (CollectionUtils.isEmpty(queryDTOList)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
List<ThreeFactorVerificationDTO> bankCardThreeVerifications = threeVerificationMapper
|
||||||
|
.findFinishStatusData();
|
||||||
|
Map<String, ThreeFactorVerificationDTO> threeVerificationMap = bankCardThreeVerifications
|
||||||
|
.stream().collect(
|
||||||
|
Collectors.toMap(k -> k.getRealName() + k.getCardNo() + k.getBankAccountNo(), v -> v, (v1, v2) -> v1));
|
||||||
|
|
||||||
|
for (FactorVerificationQueryDTO queryDTO : queryDTOList) {
|
||||||
|
ThreeFactorVerificationDTO threeFactorVerificationDTO = threeVerificationMap
|
||||||
|
.get(queryDTO.getRealName() + queryDTO.getCardNo() + queryDTO.getBankAccountNo());
|
||||||
|
if (threeFactorVerificationDTO != null) {
|
||||||
|
resultList.add(threeFactorVerificationDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThreeFactorVerificationDTO findById(Long id) {
|
||||||
|
ThreeFactorVerificationDTO threeFactorVerificationDTO = null;
|
||||||
|
BankCardThreeVerification entity = threeVerificationMapper.getById(id);
|
||||||
|
if (entity != null) {
|
||||||
|
threeFactorVerificationDTO = ThreeVerificationMapMapper.INSTANCE.toDto(entity);
|
||||||
|
}
|
||||||
|
return threeFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
ThreeFactorVerificationDTO realVerification(ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
Integer authenticationSource = verificationDTO.getAuthenticationSource();
|
||||||
|
SOURCE_SERVICE_MAP.get(authenticationSource).threeVerify(verificationDTO);
|
||||||
|
//更新状态
|
||||||
|
BankCardThreeVerification entity = ThreeVerificationMapMapper.INSTANCE
|
||||||
|
.toEntity(verificationDTO);
|
||||||
|
threeVerificationMapper.updateEntitySelective(entity, UserContextHolder.getLoginUserId());
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VerificationTypeEnum getType() {
|
||||||
|
return VerificationTypeEnum.THREE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.source.FactorVerificationSourceService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class VerifyConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private void autowiredFactorVerificationSourceService(List<FactorVerificationSourceService> sourceServices) {
|
||||||
|
for (FactorVerificationSourceService sourceService : sourceServices) {
|
||||||
|
AbstractVerify.SOURCE_SERVICE_MAP.put(sourceService.getSourceType().getType(), sourceService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.four.dao;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.entity.BankCardFourVerification;
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
public interface FourVerificationMapper extends MyMapper<BankCardFourVerification> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据四要素查询数据
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
BankCardFourVerification selectInfo(@Param("params") FourFactorVerificationDTO params);
|
||||||
|
|
||||||
|
@Select("select * from bank_card_four_verification where deleted = false and status in (2,3)")
|
||||||
|
List<FourFactorVerificationDTO> findFinishStatusData();
|
||||||
|
|
||||||
|
List<FourFactorVerificationDTO> list(@Param("params") FactorVerificationQueryDTO factorVerificationQueryDTO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.four.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel("四要素认证库")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("bank_card_four_verification")
|
||||||
|
public class BankCardFourVerification extends BaseEntity {
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?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="com.newyetai.alitaforward.verification.factor.four.dao.FourVerificationMapper">
|
||||||
|
<select id="selectInfo" resultType="com.newyetai.alitaforward.verification.factor.four.entity.BankCardFourVerification">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
bank_card_four_verification
|
||||||
|
where
|
||||||
|
deleted = 0
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
and bank_account_no = #{params.bankAccountNo}
|
||||||
|
and phone = #{params.phone}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
bank_card_four_verification
|
||||||
|
<where>
|
||||||
|
AND deleted = 0
|
||||||
|
<if test="params.id != null">
|
||||||
|
and id = #{params.id}
|
||||||
|
</if>
|
||||||
|
<if test='params.realName != null and params.realName != ""'>
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
</if>
|
||||||
|
<if test='params.cardNo != null and params.cardNo != ""'>
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.bankAccountNo != null and params.bankAccountNo != ""'>
|
||||||
|
and bank_account_no = #{params.bankAccountNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.phone != null and params.phone != ""'>
|
||||||
|
and phone = #{params.phone}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.four.mapstruct;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.four.entity.BankCardFourVerification;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardFourRequestDTO;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardThreeRequestDTO;
|
||||||
|
import java.util.List;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FourVerificationMapMapper {
|
||||||
|
|
||||||
|
FourVerificationMapMapper INSTANCE = Mappers.getMapper(
|
||||||
|
FourVerificationMapMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto to entity
|
||||||
|
*
|
||||||
|
* @param fourVerificationDTO
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
BankCardFourVerification toEntity(
|
||||||
|
FourFactorVerificationDTO fourVerificationDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dtoList to entityList
|
||||||
|
*
|
||||||
|
* @param threeVerificationDTOList
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
List<BankCardFourVerification> toEntityList(
|
||||||
|
List<FourFactorVerificationDTO> threeVerificationDTOList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* entity to dto
|
||||||
|
*
|
||||||
|
* @param threeVerification
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
FourFactorVerificationDTO toDto(
|
||||||
|
BankCardFourVerification threeVerification);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* entityList to dtoList
|
||||||
|
*
|
||||||
|
* @param fourVerificationEntityList
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
List<FourFactorVerificationDTO> toDtoList(
|
||||||
|
List<BankCardFourVerification> fourVerificationEntityList);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.phoneThree.dao;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.phoneThree.entity.PhoneThreeVerification;
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
public interface PhoneThreeVerificationMapper extends MyMapper<PhoneThreeVerification> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据三要素查询数据
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PhoneThreeVerification find(@Param("params") PhoneThreeFactorVerificationDTO params);
|
||||||
|
|
||||||
|
@Select("select * from phone_three_verification where deleted = false")
|
||||||
|
List<PhoneThreeFactorVerificationDTO> findFinishStatusData();
|
||||||
|
|
||||||
|
List<PhoneThreeFactorVerificationDTO> list(@Param("params") FactorVerificationQueryDTO factorVerificationQueryDTO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.phoneThree.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel("手机号三要素认证库")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("phone_three_verification")
|
||||||
|
public class PhoneThreeVerification extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1033289792676234200L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?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="com.newyetai.alitaforward.verification.factor.phoneThree.dao.PhoneThreeVerificationMapper">
|
||||||
|
|
||||||
|
<select id="find" resultType="com.newyetai.alitaforward.verification.factor.phoneThree.entity.PhoneThreeVerification">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
phone_three_verification
|
||||||
|
where
|
||||||
|
deleted = 0
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
and phone = #{params.phone}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
phone_three_verification
|
||||||
|
<where>
|
||||||
|
AND deleted = 0
|
||||||
|
<if test="params.id != null">
|
||||||
|
and id = #{params.id}
|
||||||
|
</if>
|
||||||
|
<if test='params.realName != null and params.realName != ""'>
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
</if>
|
||||||
|
<if test='params.cardNo != null and params.cardNo != ""'>
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.phone != null and params.phone != ""'>
|
||||||
|
and phone = #{params.phone}
|
||||||
|
</if>
|
||||||
|
<if test='params.status != null and params.status != ""'>
|
||||||
|
and status = #{params.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.phoneThree.mapstruct;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.phoneThree.entity.PhoneThreeVerification;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PhoneThreeVerificationMapMapper {
|
||||||
|
|
||||||
|
PhoneThreeVerificationMapMapper INSTANCE = Mappers.getMapper(
|
||||||
|
PhoneThreeVerificationMapMapper.class);
|
||||||
|
|
||||||
|
PhoneThreeFactorVerificationDTO exchange(PhoneThreeVerification verification);
|
||||||
|
|
||||||
|
PhoneThreeVerification exchange(PhoneThreeFactorVerificationDTO verificationDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.three.dao;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.three.entity.BankCardThreeVerification;
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
public interface ThreeVerificationMapper extends MyMapper<BankCardThreeVerification> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据三要素查询数据
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
BankCardThreeVerification find(@Param("params") ThreeFactorVerificationDTO params);
|
||||||
|
|
||||||
|
@Select("select * from bank_card_three_verification where deleted = false")
|
||||||
|
List<ThreeFactorVerificationDTO> findFinishStatusData();
|
||||||
|
|
||||||
|
List<ThreeFactorVerificationDTO> list(@Param("params") FactorVerificationQueryDTO factorVerificationQueryDTO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.three.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ApiModel("三要素认证库")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("bank_card_three_verification")
|
||||||
|
public class BankCardThreeVerification extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1178897458908696195L;
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("银行卡号")
|
||||||
|
private String bankAccountNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证状态(1-未认证 2-认证中 3-认证成功 4-认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?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="com.newyetai.alitaforward.verification.factor.three.dao.ThreeVerificationMapper">
|
||||||
|
|
||||||
|
<select id="find" resultType="com.newyetai.alitaforward.verification.factor.three.entity.BankCardThreeVerification">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
bank_card_three_verification
|
||||||
|
where
|
||||||
|
deleted = 0
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
and bank_account_no = #{params.bankAccountNo}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
bank_card_three_verification
|
||||||
|
<where>
|
||||||
|
AND deleted = 0
|
||||||
|
<if test="params.id != null">
|
||||||
|
and id = #{params.id}
|
||||||
|
</if>
|
||||||
|
<if test="params.ids != null and params.ids.size() != 0">
|
||||||
|
and id IN
|
||||||
|
<foreach collection="params.ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test='params.realName != null and params.realName != ""'>
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
</if>
|
||||||
|
<if test='params.cardNo != null and params.cardNo != ""'>
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.bankAccountNo != null and params.bankAccountNo != ""'>
|
||||||
|
and bank_account_no = #{params.bankAccountNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.status != null and params.status != ""'>
|
||||||
|
and status = #{params.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.three.mapstruct;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.three.entity.BankCardThreeVerification;
|
||||||
|
import java.util.List;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-17
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ThreeVerificationMapMapper {
|
||||||
|
|
||||||
|
ThreeVerificationMapMapper INSTANCE = Mappers.getMapper(
|
||||||
|
ThreeVerificationMapMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto to entity
|
||||||
|
*
|
||||||
|
* @param threeVerificationDTO
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
BankCardThreeVerification toEntity(
|
||||||
|
ThreeFactorVerificationDTO threeVerificationDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dtoList to entityList
|
||||||
|
*
|
||||||
|
* @param threeVerificationDTOList
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
List<BankCardThreeVerification> toEntityList(
|
||||||
|
List<ThreeFactorVerificationDTO> threeVerificationDTOList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* entity to dto
|
||||||
|
*
|
||||||
|
* @param threeVerification
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
ThreeFactorVerificationDTO toDto(
|
||||||
|
BankCardThreeVerification threeVerification);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* entityList to dtoList
|
||||||
|
*
|
||||||
|
* @param threeVerificationEntityList
|
||||||
|
* @return
|
||||||
|
* @author czy on 2021-06-17
|
||||||
|
*/
|
||||||
|
List<ThreeFactorVerificationDTO> toDtoList(
|
||||||
|
List<BankCardThreeVerification> threeVerificationEntityList);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.convert;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.dto.RealNameTwoVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.dto.RealNameTwoVerificationOperatorDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.entity.RealNameTwoVerification;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RealNameTwoVerificationConvert {
|
||||||
|
RealNameTwoVerificationConvert INSTANCE = Mappers.getMapper(RealNameTwoVerificationConvert.class);
|
||||||
|
|
||||||
|
RealNameTwoVerification convert(RealNameTwoVerificationDTO dto);
|
||||||
|
|
||||||
|
RealNameTwoVerificationDTO convert(RealNameTwoVerification entity);
|
||||||
|
RealNameTwoFactorVerificationDTO convertDTO(RealNameTwoVerification entity);
|
||||||
|
|
||||||
|
RealNameTwoVerification convert(RealNameTwoVerificationOperatorDTO dto);
|
||||||
|
|
||||||
|
RealNameTwoVerification convert(RealNameTwoFactorVerificationDTO dto);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.dao;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.dto.RealNameTwoVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.dto.RealNameTwoVerificationPageQueryDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.factor.two.entity.RealNameTwoVerification;
|
||||||
|
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RealNameTwoVerificationMapper extends MyMapper<RealNameTwoVerification> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据二要素查询数据
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RealNameTwoVerification selectInfo(@Param("param") RealNameTwoFactorVerificationDTO params);
|
||||||
|
|
||||||
|
List<RealNameTwoVerificationDTO> page(
|
||||||
|
@Param("param") RealNameTwoVerificationPageQueryDTO queryDTO);
|
||||||
|
|
||||||
|
List<RealNameTwoFactorVerificationDTO> list(@Param("param") FactorVerificationQueryDTO queryDTO);
|
||||||
|
|
||||||
|
@Select("select * from real_name_two_verification where deleted = false")
|
||||||
|
List<RealNameTwoFactorVerificationDTO> findFinishStatusData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.dto;
|
||||||
|
|
||||||
|
import com.newyetai.common.dto.BaseDTO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@ApiModel("二要素认证表")
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RealNameTwoVerificationDTO extends BaseDTO {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1待认证 2认证中 3认证成功 4认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源(1放心签、2创蓝 3系统)")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@ApiModel("二要素认证表")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RealNameTwoVerificationOperatorDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名")
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1待认证 2认证中 3认证成功 4认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源(1放心签、2创蓝 3系统)")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.newyetai.common.dto.PageQueryDTO;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@ApiModel("二要素认证表")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RealNameTwoVerificationPageQueryDTO extends PageQueryDTO<RealNameTwoVerificationDTO> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名 (模糊匹配)")
|
||||||
|
private String realNameLike;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1待认证 2认证中 3认证成功 4认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源(1放心签、2创蓝 3系统)")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@ApiModel("二要素认证表")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RealNameTwoVerificationQueryDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("姓名 (模糊匹配)")
|
||||||
|
private String realNameLike;
|
||||||
|
|
||||||
|
@ApiModelProperty("证件号")
|
||||||
|
private String cardNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(1待认证 2认证中 3认证成功 4认证失败)")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty("认证来源(1放心签、2创蓝 3系统)")
|
||||||
|
private Integer authenticationSource;
|
||||||
|
|
||||||
|
@ApiModelProperty("调用数据")
|
||||||
|
private String invokeData;
|
||||||
|
|
||||||
|
@ApiModelProperty("失败原因")
|
||||||
|
private String failReason;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTimeEnd;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeStart;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTimeEnd;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.factor.two.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.newyetai.common.entity.BaseEntity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二要素认证表
|
||||||
|
*
|
||||||
|
* @author chenyun chenyun.home@outlook.com
|
||||||
|
* @since 1.0.0 2022-07-22
|
||||||
|
*/
|
||||||
|
@TableName("real_name_two_verification")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RealNameTwoVerification extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 姓名 */
|
||||||
|
private String realName;
|
||||||
|
/** 证件号 */
|
||||||
|
private String cardNo;
|
||||||
|
/** 状态(1待认证 2认证中 3认证成功 4认证失败) */
|
||||||
|
private Integer status;
|
||||||
|
/** 认证来源(1放心签、2创蓝 3系统) */
|
||||||
|
private Integer authenticationSource;
|
||||||
|
/** 调用数据 */
|
||||||
|
private String invokeData;
|
||||||
|
/** 失败原因 */
|
||||||
|
private String failReason;
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?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="com.newyetai.alitaforward.verification.factor.two.dao.RealNameTwoVerificationMapper">
|
||||||
|
|
||||||
|
<select id="list" resultType="com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO">
|
||||||
|
select
|
||||||
|
*
|
||||||
|
from
|
||||||
|
real_name_two_verification
|
||||||
|
<where>
|
||||||
|
AND deleted = 0
|
||||||
|
<if test="params.id != null">
|
||||||
|
and id = #{params.id}
|
||||||
|
</if>
|
||||||
|
<if test='params.realName != null and params.realName != ""'>
|
||||||
|
and real_name = #{params.realName}
|
||||||
|
</if>
|
||||||
|
<if test='params.cardNo != null and params.cardNo != ""'>
|
||||||
|
and card_no = #{params.cardNo}
|
||||||
|
</if>
|
||||||
|
<if test='params.status != null and params.status != ""'>
|
||||||
|
and status = #{params.status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="page" resultType="com.newyetai.alitaforward.verification.factor.two.dto.RealNameTwoVerificationDTO">
|
||||||
|
SELECT t.*
|
||||||
|
<include refid="queryFromSql"></include>
|
||||||
|
</select>
|
||||||
|
<select id="selectInfo"
|
||||||
|
resultType="com.newyetai.alitaforward.verification.factor.two.entity.RealNameTwoVerification">
|
||||||
|
SELECT t.*
|
||||||
|
FROM real_name_two_verification t
|
||||||
|
WHERE t.deleted = 0
|
||||||
|
AND t.real_name = #{param.realName}
|
||||||
|
AND t.card_no = #{param.cardNo}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="queryFromSql">
|
||||||
|
FROM
|
||||||
|
real_name_two_verification t
|
||||||
|
WHERE t.deleted = 0
|
||||||
|
<if test='param.id != null'>
|
||||||
|
AND t.id = #{param.id}
|
||||||
|
</if>
|
||||||
|
<if test='param.realNameLike != null and param.realNameLike.trim() != ""'>
|
||||||
|
<bind name="realNameLike" value="'%' + param.realNameLike + '%'"/>
|
||||||
|
AND t.real_name like #{realNameLike}
|
||||||
|
</if>
|
||||||
|
<if test='param.cardNo != null and param.cardNo.trim() != ""'>
|
||||||
|
AND t.card_no = #{param.cardNo}
|
||||||
|
</if>
|
||||||
|
<if test='param.status != null'>
|
||||||
|
AND t.status = #{param.status}
|
||||||
|
</if>
|
||||||
|
<if test='param.authenticationSource != null'>
|
||||||
|
AND t.authentication_source = #{param.authenticationSource}
|
||||||
|
</if>
|
||||||
|
<if test='param.invokeData != null and param.invokeData.trim() != ""'>
|
||||||
|
AND t.invoke_data = #{param.invokeData}
|
||||||
|
</if>
|
||||||
|
<if test='param.failReason != null and param.failReason.trim() != ""'>
|
||||||
|
AND t.fail_reason = #{param.failReason}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeStart != null'>
|
||||||
|
AND t.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.createTimeEnd != null'>
|
||||||
|
AND t.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeStart != null'>
|
||||||
|
AND t.update_time >= #{param.updateTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test='param.updateTimeEnd != null'>
|
||||||
|
AND t.update_time <= #{param.updateTimeEnd}
|
||||||
|
</if>
|
||||||
|
ORDER BY t.id DESC
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.BankCordVerificationResDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BankCardVerificationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白名单管理-->三、四要素查询合并为银行卡查询
|
||||||
|
* @param cardNo
|
||||||
|
*/
|
||||||
|
List<BankCordVerificationResDTO> list(String cardNo,Integer status);
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.mq.consumer.handler.ITopicMqHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-22
|
||||||
|
*/
|
||||||
|
public interface FourFactorVerificationProvider extends ITopicMqHandler<FourFactorVerificationDTO> {
|
||||||
|
|
||||||
|
default String getRoutingKey(){
|
||||||
|
return VerificationTypeEnum.FOUR.getStatusChangeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.mq.consumer.handler.ITopicMqHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-22
|
||||||
|
*/
|
||||||
|
public interface PhoneThreeFactorVerificationProvider extends ITopicMqHandler<PhoneThreeFactorVerificationDTO> {
|
||||||
|
|
||||||
|
default String getRoutingKey(){
|
||||||
|
return VerificationTypeEnum.PHONE_THREE.getStatusChangeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.mq.consumer.handler.ITopicMqHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-22
|
||||||
|
*/
|
||||||
|
public interface RealNameTwoFactorVerificationProvider extends ITopicMqHandler<RealNameTwoFactorVerificationDTO> {
|
||||||
|
|
||||||
|
default String getRoutingKey(){
|
||||||
|
return VerificationTypeEnum.TWO.getStatusChangeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.VerificationTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.mq.consumer.handler.ITopicMqHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-22
|
||||||
|
*/
|
||||||
|
public interface ThreeFactorVerificationProvider extends ITopicMqHandler<ThreeFactorVerificationDTO> {
|
||||||
|
|
||||||
|
default String getRoutingKey(){
|
||||||
|
return VerificationTypeEnum.THREE.getStatusChangeKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.service.impl;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dao.BankCardVerificationMapper;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.BankCordVerificationResDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.service.BankCardVerificationService;
|
||||||
|
import com.newyetai.common.exception.BusinessException;
|
||||||
|
import com.newyetai.common.exception.util.Assert;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BankCardVerificationServiceImpl implements BankCardVerificationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BankCardVerificationMapper bankCardVerificationMapper;
|
||||||
|
/**
|
||||||
|
* 白名单管理-->三、四要素查询合并为银行卡查询
|
||||||
|
* @param cardNo
|
||||||
|
*/
|
||||||
|
public List<BankCordVerificationResDTO> list(String cardNo,Integer status){
|
||||||
|
if(StringUtils.isBlank(cardNo)){
|
||||||
|
throw new BusinessException("身份证号不能为空");
|
||||||
|
}
|
||||||
|
List<BankCordVerificationResDTO> bankCordVerificationResDTOList = bankCardVerificationMapper.list(cardNo);
|
||||||
|
if(status != null){
|
||||||
|
return bankCordVerificationResDTOList.stream().
|
||||||
|
filter(f -> f.getStatus() != null && f.getStatus() == status).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return bankCordVerificationResDTOList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.source;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.common.exception.BusinessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要素认证源 - 顶层接口
|
||||||
|
*
|
||||||
|
* @author cheny
|
||||||
|
* @date 2022/08/11
|
||||||
|
*/
|
||||||
|
public interface FactorVerificationSourceService {
|
||||||
|
|
||||||
|
FactorVerificationSourceTypeEnum getSourceType();
|
||||||
|
|
||||||
|
default RealNameTwoFactorVerificationDTO twoVerify(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
throw new BusinessException("二要素不支持的该认证源:" + getSourceType());
|
||||||
|
}
|
||||||
|
default ThreeFactorVerificationDTO threeVerify(ThreeFactorVerificationDTO verificationDTO){
|
||||||
|
throw new BusinessException("银行卡三要素不支持的该认证源:" + getSourceType());
|
||||||
|
}
|
||||||
|
default PhoneThreeFactorVerificationDTO phoneThreeVerify(PhoneThreeFactorVerificationDTO verificationDTO){
|
||||||
|
throw new BusinessException("手机号三要素不支持的该认证源:" + getSourceType());
|
||||||
|
}
|
||||||
|
default FourFactorVerificationDTO fourVerify(FourFactorVerificationDTO verificationDTO){
|
||||||
|
throw new BusinessException("银行卡四要素不支持的该认证源:" + getSourceType());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.source.cl;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.source.FactorVerificationSourceService;
|
||||||
|
import com.newyetai.alitaforward.verification.source.cl.mapstruct.ClMapMapper;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.BankCardFourRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.BankCardThreeRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.ChuangLanResultDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.PhoneThreeRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.RealNameTwoBaseRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.service.ChuangLanService;
|
||||||
|
import com.newyetai.sdk.common.constant.SdkConstants;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创蓝认证源
|
||||||
|
*
|
||||||
|
* @author cheny
|
||||||
|
* @date 2022/08/11
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public class ClAuthenticateSourceServiceImpl implements FactorVerificationSourceService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RealNameTwoFactorVerificationDTO twoVerify(RealNameTwoFactorVerificationDTO verificationDTO) {
|
||||||
|
RealNameTwoBaseRequestDTO requestDTO = ClMapMapper.INSTANCE.toTwoRequestDTO(verificationDTO);
|
||||||
|
log.info("执行创蓝运营商二要素认证:{}", JSONUtil.toJsonStr(requestDTO));
|
||||||
|
AlitaResult<ChuangLanResultDTO> result = chuangLanService.checkRealNameTwoBase(requestDTO);
|
||||||
|
handlerResult(result, verificationDTO);
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PhoneThreeFactorVerificationDTO phoneThreeVerify(PhoneThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
PhoneThreeRequestDTO phoneThreeRequestDTO = ClMapMapper.INSTANCE
|
||||||
|
.toPhoneThreeRequestDTO(verificationDTO);
|
||||||
|
log.info("执行创蓝运营商三要素认证:{}", JSONUtil.toJsonStr(phoneThreeRequestDTO));
|
||||||
|
AlitaResult<ChuangLanResultDTO> result = chuangLanService.checkPhoneThree(phoneThreeRequestDTO);
|
||||||
|
handlerResult(result, verificationDTO);
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThreeFactorVerificationDTO threeVerify(
|
||||||
|
ThreeFactorVerificationDTO verificationDTO) {
|
||||||
|
BankCardThreeRequestDTO bankCardThreeRequestDTO = ClMapMapper.INSTANCE
|
||||||
|
.toThreeRequestDTO(verificationDTO);
|
||||||
|
log.info("执行创蓝三要素认证:{}", JSONUtil.toJsonStr(bankCardThreeRequestDTO));
|
||||||
|
AlitaResult<ChuangLanResultDTO> result = chuangLanService.checkBankCardThree(bankCardThreeRequestDTO);
|
||||||
|
handlerResult(result, verificationDTO);
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FourFactorVerificationDTO fourVerify(
|
||||||
|
FourFactorVerificationDTO verificationDTO) {
|
||||||
|
//调用放心签
|
||||||
|
BankCardFourRequestDTO bankCardFourRequestDTO = ClMapMapper.INSTANCE
|
||||||
|
.toFourRequestDTO(verificationDTO);
|
||||||
|
log.info("执行创蓝四要素认证:{}", JSONUtil.toJsonStr(bankCardFourRequestDTO));
|
||||||
|
AlitaResult<ChuangLanResultDTO> result = chuangLanService.checkBankCardFour(bankCardFourRequestDTO);
|
||||||
|
handlerResult(result, verificationDTO);
|
||||||
|
|
||||||
|
return verificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理结果
|
||||||
|
*
|
||||||
|
* @param result 结果
|
||||||
|
* @param verificationDTO 验证dto
|
||||||
|
*/
|
||||||
|
private void handlerResult(AlitaResult<ChuangLanResultDTO> result, FactorVerificationDTO verificationDTO) {
|
||||||
|
verificationDTO.setInvokeData(Optional.ofNullable(result.getData()).map(ChuangLanResultDTO::getJsonData).orElse(""));
|
||||||
|
AuthStatusEnum targetStatus = null;
|
||||||
|
if (SdkConstants.SDK_INVOKE_NOT_REACH_CODE.equals(result.getCode())) {
|
||||||
|
// 接口调起失败,未拿到返回结果,视为未调起
|
||||||
|
verificationDTO.setFailReason("调用异常,未调起第三方");
|
||||||
|
} else {
|
||||||
|
if (Boolean.TRUE.equals(result.getSuccess()) && Boolean.TRUE.equals(result.getData().getStatus())) {
|
||||||
|
targetStatus = AuthStatusEnum.AUTH_SUCCESS;
|
||||||
|
} else {
|
||||||
|
targetStatus = AuthStatusEnum.AUTH_FAIL;
|
||||||
|
verificationDTO.setFailReason(result.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(targetStatus)) {
|
||||||
|
verificationDTO.setStatus(targetStatus.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Resource(name = ChuangLanService.BEAN_ID)
|
||||||
|
private ChuangLanService chuangLanService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FactorVerificationSourceTypeEnum getSourceType() {
|
||||||
|
return FactorVerificationSourceTypeEnum.CL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.source.cl.mapstruct;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.PhoneThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.RealNameTwoFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.BankCardFourRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.BankCardThreeRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.PhoneThreeRequestDTO;
|
||||||
|
import com.newyetai.sdk.chuanglan.dto.RealNameTwoBaseRequestDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-23
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ClMapMapper {
|
||||||
|
|
||||||
|
ClMapMapper INSTANCE = Mappers.getMapper(ClMapMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转创蓝三要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto 验证dto
|
||||||
|
* @return {@link RealNameTwoBaseRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "idNum", source = "dto.cardNo")
|
||||||
|
})
|
||||||
|
RealNameTwoBaseRequestDTO toTwoRequestDTO(RealNameTwoFactorVerificationDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转创蓝三要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return {@link BankCardThreeRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "idNum", source = "dto.cardNo"),
|
||||||
|
@Mapping(target = "cardNo", source = "dto.bankAccountNo")
|
||||||
|
})
|
||||||
|
BankCardThreeRequestDTO toThreeRequestDTO(ThreeFactorVerificationDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转创蓝三要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto dto
|
||||||
|
* @return {@link PhoneThreeRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "idNum", source = "dto.cardNo"),
|
||||||
|
@Mapping(target = "mobile", source = "dto.phone")
|
||||||
|
})
|
||||||
|
PhoneThreeRequestDTO toPhoneThreeRequestDTO(PhoneThreeFactorVerificationDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转创蓝四要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return {@link BankCardFourRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "idNum", source = "dto.cardNo"),
|
||||||
|
@Mapping(target = "cardNo", source = "dto.bankAccountNo"),
|
||||||
|
@Mapping(target = "mobile", source = "dto.phone")
|
||||||
|
})
|
||||||
|
BankCardFourRequestDTO toFourRequestDTO(FourFactorVerificationDTO dto);
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.source.fxq;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.constants.FactorVerificationSourceTypeEnum;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.source.FactorVerificationSourceService;
|
||||||
|
import com.newyetai.alitaforward.verification.source.fxq.mapstruct.FxqMapMapper;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.constant.AuthStatusEnum;
|
||||||
|
import com.newyetai.sdk.common.constant.SdkConstants;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardFourRequestDTO;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardThreeRequestDTO;
|
||||||
|
import com.newyetai.sdk.fangxinqian.service.FangXinQianService;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-21
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class FxqAuthenticateSourceServiceImpl implements FactorVerificationSourceService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThreeFactorVerificationDTO threeVerify(
|
||||||
|
ThreeFactorVerificationDTO threeFactorVerificationDTO) {
|
||||||
|
BankCardThreeRequestDTO bankCardThreeRequestDto =
|
||||||
|
FxqMapMapper.INSTANCE.toThreeRequestDTO(threeFactorVerificationDTO);
|
||||||
|
log.info("执行放心签三要素认证:{}", JSONUtil.toJsonStr(bankCardThreeRequestDto));
|
||||||
|
AlitaResult<Boolean> result = fangXinQianService.checkBankCardThree(bankCardThreeRequestDto);
|
||||||
|
handlerResult(result, threeFactorVerificationDTO);
|
||||||
|
return threeFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FourFactorVerificationDTO fourVerify(
|
||||||
|
FourFactorVerificationDTO fourFactorVerificationDTO) {
|
||||||
|
//调用放心签
|
||||||
|
BankCardFourRequestDTO bankCardFourRequestDTO = FxqMapMapper.INSTANCE
|
||||||
|
.toFourRequestDTO(fourFactorVerificationDTO);
|
||||||
|
log.info("执行放心签四要素认证:{}", JSONUtil.toJsonStr(bankCardFourRequestDTO));
|
||||||
|
AlitaResult<Boolean> result = fangXinQianService.checkBankCardFour(bankCardFourRequestDTO);
|
||||||
|
handlerResult(result, fourFactorVerificationDTO);
|
||||||
|
|
||||||
|
return fourFactorVerificationDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理结果
|
||||||
|
*
|
||||||
|
* @param result 结果
|
||||||
|
* @param verificationDTO 验证dto
|
||||||
|
*/
|
||||||
|
private void handlerResult(AlitaResult<Boolean> result, FactorVerificationDTO verificationDTO) {
|
||||||
|
AuthStatusEnum targetStatus = null;
|
||||||
|
if (SdkConstants.SDK_INVOKE_NOT_REACH_CODE.equals(result.getCode())) {
|
||||||
|
// 接口调起失败,未拿到返回结果,视为未调起
|
||||||
|
verificationDTO.setFailReason("调用异常,未调起第三方");
|
||||||
|
} else {
|
||||||
|
if (Boolean.TRUE.equals(result.getSuccess()) && Boolean.TRUE.equals(result.getData())) {
|
||||||
|
targetStatus = AuthStatusEnum.AUTH_SUCCESS;
|
||||||
|
} else {
|
||||||
|
targetStatus = AuthStatusEnum.AUTH_FAIL;
|
||||||
|
verificationDTO.setFailReason(result.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(targetStatus)) {
|
||||||
|
verificationDTO.setStatus(targetStatus.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Resource(name = FangXinQianService.BEAN_ID)
|
||||||
|
private FangXinQianService fangXinQianService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FactorVerificationSourceTypeEnum getSourceType() {
|
||||||
|
return FactorVerificationSourceTypeEnum.FXQ;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.newyetai.alitaforward.verification.source.fxq.mapstruct;
|
||||||
|
|
||||||
|
import com.newyetai.alitaforward.verification.dto.FourFactorVerificationDTO;
|
||||||
|
import com.newyetai.alitaforward.verification.dto.ThreeFactorVerificationDTO;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardFourRequestDTO;
|
||||||
|
import com.newyetai.sdk.fangxinqian.dto.BankCardThreeRequestDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czy
|
||||||
|
* @date 2021-06-23
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FxqMapMapper {
|
||||||
|
|
||||||
|
FxqMapMapper INSTANCE = Mappers.getMapper(
|
||||||
|
FxqMapMapper.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转放心签三要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return {@link BankCardThreeRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "identityCode", source = "dto.cardNo"),
|
||||||
|
@Mapping(target = "bankcardNumber", source = "dto.bankAccountNo")
|
||||||
|
})
|
||||||
|
BankCardThreeRequestDTO toThreeRequestDTO(ThreeFactorVerificationDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dto转放心签四要素认证请求对象
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return {@link BankCardFourRequestDTO}
|
||||||
|
*/
|
||||||
|
@Mappings(value = {
|
||||||
|
@Mapping(target = "name", source = "dto.realName"),
|
||||||
|
@Mapping(target = "identityCode", source = "dto.cardNo"),
|
||||||
|
@Mapping(target = "bankcardNumber", source = "dto.bankAccountNo"),
|
||||||
|
@Mapping(target = "phoneNumber", source = "dto.phone")
|
||||||
|
})
|
||||||
|
BankCardFourRequestDTO toFourRequestDTO(FourFactorVerificationDTO dto);
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.newyetai.business.ability.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品类型
|
||||||
|
*
|
||||||
|
* @author sr on 2021-03-29
|
||||||
|
*/
|
||||||
|
public enum ProdTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新业态-灵活就业
|
||||||
|
**/
|
||||||
|
XYT(10, "新业态产品"),
|
||||||
|
/**
|
||||||
|
* 其他
|
||||||
|
**/
|
||||||
|
OTHER(11, "其他"),
|
||||||
|
/**
|
||||||
|
* 短信
|
||||||
|
**/
|
||||||
|
SMS_COUNT(12, "短信计次"),
|
||||||
|
/**
|
||||||
|
* 三要素
|
||||||
|
**/
|
||||||
|
BANK_CARD_THREE_COUNT(13, "三要素计次"),
|
||||||
|
/**
|
||||||
|
* 电子合同
|
||||||
|
**/
|
||||||
|
ELECTRONIC_CONTRACT_COUNT(14, "合同计次"),
|
||||||
|
/**
|
||||||
|
* 发票
|
||||||
|
**/
|
||||||
|
INVOICE(15, "开票余额"),
|
||||||
|
/**
|
||||||
|
* 工商信息
|
||||||
|
**/
|
||||||
|
COMPANY_INFO(16, "工商信息"),
|
||||||
|
/**
|
||||||
|
* 积分
|
||||||
|
**/
|
||||||
|
POINT(17, "积分"),
|
||||||
|
/**
|
||||||
|
* 通用支付
|
||||||
|
*/
|
||||||
|
OPEN_PAY(18, "通用支付"),
|
||||||
|
/**
|
||||||
|
* 无卡发薪
|
||||||
|
*/
|
||||||
|
UPAY(19, "无卡发薪"),
|
||||||
|
/**
|
||||||
|
* 平台认证
|
||||||
|
*/
|
||||||
|
PLATFORM_VERIFICATION(20, "平台认证");
|
||||||
|
|
||||||
|
ProdTypeEnum(Integer type, String desc) {
|
||||||
|
this.type = type;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer type;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
public Integer getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.newyetai.codegenerator.config;
|
||||||
|
|
||||||
|
import java.net.Inet6Address;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import com.newyetai.codegenerator.service.CodeService;
|
||||||
|
import com.newyetai.codegenerator.service.SnowflakeIdWorker;
|
||||||
|
import com.newyetai.codegenerator.service.generator.SnowFlakeCodeGenerator;
|
||||||
|
import com.newyetai.codegenerator.service.impl.CodeServiceImpl;
|
||||||
|
import com.newyetai.codegenerator.util.CodeUtils;
|
||||||
|
import com.newyetai.common.CommonConfiguration;
|
||||||
|
import com.newyetai.common.constant.CommonConstants;
|
||||||
|
import com.newyetai.common.util.EnvironmentUtils;
|
||||||
|
import com.newyetai.common.util.RequestUtils;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发号器配置类
|
||||||
|
* @author sr on 2021-03-23
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@AutoConfigureAfter(CommonConfiguration.class)
|
||||||
|
@Slf4j
|
||||||
|
public class CodeConfiguration {
|
||||||
|
|
||||||
|
public static final String PROP_WORID_PREFIX = "code.snowflake.workid";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认编号生成器
|
||||||
|
* @return
|
||||||
|
* @author sr on 2021-03-23
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public SnowFlakeCodeGenerator snowFlakeCodeGenerator() {
|
||||||
|
// 机器id
|
||||||
|
String hostIp = RequestUtils.getHostIp();
|
||||||
|
log.info("hostIp:" + hostIp);
|
||||||
|
String workIdStr = EnvironmentUtils.getProperty(
|
||||||
|
String.join(CommonConstants.POINT, PROP_WORID_PREFIX, hostIp));
|
||||||
|
Long workId = 99l;
|
||||||
|
try {
|
||||||
|
if (StringUtils.isNoneBlank(workIdStr)) {
|
||||||
|
workId = Long.valueOf(workIdStr);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(workId, 0);
|
||||||
|
return new SnowFlakeCodeGenerator(idWorker);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号service(根据类型分发不同的生成器)
|
||||||
|
* @return
|
||||||
|
* @author sr on 2021-03-23
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CodeService codeService() {
|
||||||
|
CodeService codeService = new CodeServiceImpl();
|
||||||
|
CodeUtils.setCodeService(codeService);
|
||||||
|
return codeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.newyetai.codegenerator.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号常量类
|
||||||
|
* @author sr on 2019-09-15
|
||||||
|
*/
|
||||||
|
public class CodeConstants {
|
||||||
|
|
||||||
|
/** 生成器类型:默认(不可用) **/
|
||||||
|
// public static final String GENERATOR_TYPE_DEFAULT = "DEFAULT";
|
||||||
|
public static final String GENERATOR_TYPE_SNOW_FLAKE = "SnowFlake";
|
||||||
|
|
||||||
|
/** id默认长度 **/
|
||||||
|
public static final int ID_DEFAULT_LENGTH = 5;
|
||||||
|
|
||||||
|
/** id默认补位字符 **/
|
||||||
|
public static final char ID_DEFAULT_PAD = '0';
|
||||||
|
/** id默认日期格式化 **/
|
||||||
|
public static final DateFormatterEnum ID_DEFAULT_FORMATTER = DateFormatterEnum.YEAR;
|
||||||
|
|
||||||
|
/** -----异常信息----- **/
|
||||||
|
public static final String CODE_GENERATE_ERROR = "编号生成失败";
|
||||||
|
/** -----异常信息----- **/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.newyetai.codegenerator.constant;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期formatter枚举
|
||||||
|
* @author sr on 2019-12-03
|
||||||
|
*/
|
||||||
|
public enum DateFormatterEnum {
|
||||||
|
|
||||||
|
/** 年:yyyy **/
|
||||||
|
YEAR(DateTimeFormatter.ofPattern("yyyy")),
|
||||||
|
/** 年月:yyyyMM **/
|
||||||
|
YM(DateTimeFormatter.ofPattern("yyyyMM")),
|
||||||
|
/** 年月:yyMM **/
|
||||||
|
YM2(DateTimeFormatter.ofPattern("yyMM")),
|
||||||
|
/** 年月日:yyyyMMdd **/
|
||||||
|
YMD(DateTimeFormatter.ofPattern("yyyyMMdd")),
|
||||||
|
/** 年月日:yyMMdd **/
|
||||||
|
YMD2(DateTimeFormatter.ofPattern("yyMMdd"));
|
||||||
|
|
||||||
|
private DateTimeFormatter formatter;
|
||||||
|
|
||||||
|
private DateFormatterEnum(DateTimeFormatter formatter){
|
||||||
|
this.formatter = formatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTimeFormatter getDateTimeFormatter() {
|
||||||
|
return this.formatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.newyetai.codegenerator.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号生成器异常
|
||||||
|
* @author sr on 2019-12-03
|
||||||
|
*/
|
||||||
|
public class CodeGeneratorException extends RuntimeException{
|
||||||
|
|
||||||
|
/** **/
|
||||||
|
private static final long serialVersionUID = 3558280270933232655L;
|
||||||
|
|
||||||
|
|
||||||
|
public CodeGeneratorException() {}
|
||||||
|
|
||||||
|
public CodeGeneratorException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeGeneratorException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeGeneratorException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/com/newyetai/codegenerator/pojo/CodeParam.java
Normal file
25
src/main/java/com/newyetai/codegenerator/pojo/CodeParam.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.newyetai.codegenerator.pojo;
|
||||||
|
|
||||||
|
import com.newyetai.codegenerator.constant.CodeConstants;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Builder.Default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编码生成参数对象
|
||||||
|
* @author sr on 2019-12-05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class CodeParam {
|
||||||
|
|
||||||
|
/** 生成器类型 **/
|
||||||
|
@Default
|
||||||
|
private String generatorType = CodeConstants.GENERATOR_TYPE_SNOW_FLAKE;
|
||||||
|
|
||||||
|
/** 编码类型 **/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.newyetai.codegenerator.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.newyetai.codegenerator.pojo.CodeParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号生成器 默认一套实现,如需重定义中间时间format和id长度,重写规则 重写规则,注意去发号器对应的数据库表(leaf_alloc)中添加对应type+时间(biz_tag)的记录
|
||||||
|
*
|
||||||
|
* @author sr on 2019-09-15
|
||||||
|
*/
|
||||||
|
public interface CodeGenerator<T extends CodeParam> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义特定业务类型,即前缀
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @author sr on 2019-09-19
|
||||||
|
*/
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据生成规则获取编号
|
||||||
|
*
|
||||||
|
* @param codeParam
|
||||||
|
* @return
|
||||||
|
* @author sr on 2020-07-13
|
||||||
|
*/
|
||||||
|
String getCode(T codeParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量根据生成规则获取编号
|
||||||
|
*
|
||||||
|
* @param codeParam
|
||||||
|
* @return
|
||||||
|
* @author sr on 2020-07-13
|
||||||
|
*/
|
||||||
|
List<String> batchCode(T codeParam, Integer batchNum);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.newyetai.codegenerator.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.newyetai.codegenerator.pojo.CodeParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号service(根据类型分发不同的生成器)
|
||||||
|
*
|
||||||
|
* @author sr on 2019-09-15
|
||||||
|
*/
|
||||||
|
public interface CodeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据生成规则获取编号
|
||||||
|
*
|
||||||
|
* @param codeParam
|
||||||
|
* @return
|
||||||
|
* @author sr on 2020-07-13
|
||||||
|
*/
|
||||||
|
String getCode(CodeParam codeParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量根据生成规则获取编号
|
||||||
|
*
|
||||||
|
* @param codeParam
|
||||||
|
* @param batchNum 批次数(1-1000)
|
||||||
|
* @return
|
||||||
|
* @author sr on 2020-07-13
|
||||||
|
*/
|
||||||
|
List<String> batchCode(CodeParam codeParam, Integer batchNum);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package com.newyetai.codegenerator.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Twitter_Snowflake<br>
|
||||||
|
* SnowFlake的结构如下(每部分用-分开):<br>
|
||||||
|
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
|
||||||
|
* 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
|
||||||
|
* 41位时间戳(毫秒级),注意,41位时间戳不是存储当前时间的时间戳,而是存储时间戳的差值(当前时间戳 - 开始时间戳) 得到的值),这里的的开始时间戳,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间戳,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
|
||||||
|
* 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
|
||||||
|
* 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间戳)产生4096个ID序号<br>
|
||||||
|
* 加起来刚好64位,为一个Long型。<br>
|
||||||
|
* SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
|
||||||
|
*/
|
||||||
|
public class SnowflakeIdWorker {
|
||||||
|
|
||||||
|
// ==============================Fields===========================================
|
||||||
|
/** 开始时间戳 (2015-01-01) */
|
||||||
|
private final long twepoch = 1420041600000L;
|
||||||
|
|
||||||
|
/** 能容忍的系统时钟回拨时间(2秒) */
|
||||||
|
private final long timeOffset = 2000L;
|
||||||
|
|
||||||
|
/** 机器id所占的位数 */
|
||||||
|
private final long workerIdBits = 5L;
|
||||||
|
|
||||||
|
/** 数据标识id所占的位数 */
|
||||||
|
private final long datacenterIdBits = 5L;
|
||||||
|
|
||||||
|
/** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
|
||||||
|
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||||
|
|
||||||
|
/** 支持的最大数据标识id,结果是31 */
|
||||||
|
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||||
|
|
||||||
|
/** 序列在id中占的位数 */
|
||||||
|
private final long sequenceBits = 12L;
|
||||||
|
|
||||||
|
/** 机器ID向左移12位 */
|
||||||
|
private final long workerIdShift = sequenceBits;
|
||||||
|
|
||||||
|
/** 数据标识id向左移17位(12+5) */
|
||||||
|
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
||||||
|
|
||||||
|
/** 时间戳向左移22位(5+5+12) */
|
||||||
|
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||||
|
|
||||||
|
/** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
|
||||||
|
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||||
|
|
||||||
|
/** 工作机器ID(0~31) */
|
||||||
|
private long workerId;
|
||||||
|
|
||||||
|
/** 数据中心ID(0~31) */
|
||||||
|
private long datacenterId;
|
||||||
|
|
||||||
|
/** 毫秒内序列(0~4095) */
|
||||||
|
private long sequence = 0L;
|
||||||
|
|
||||||
|
/** 上次生成ID的时间戳 */
|
||||||
|
private long lastTimestamp = -1L;
|
||||||
|
|
||||||
|
// ==============================Constructors=====================================
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
* @param workerId 工作ID (0~31)
|
||||||
|
* @param datacenterId 数据中心ID (0~31)
|
||||||
|
*/
|
||||||
|
public SnowflakeIdWorker(long workerId, long datacenterId) {
|
||||||
|
if (workerId > maxWorkerId || workerId < 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||||
|
}
|
||||||
|
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||||
|
}
|
||||||
|
this.workerId = workerId;
|
||||||
|
this.datacenterId = datacenterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================Methods==========================================
|
||||||
|
/**
|
||||||
|
* 获得下一个ID (该方法是线程安全的)
|
||||||
|
* @return SnowflakeId
|
||||||
|
*/
|
||||||
|
public synchronized long nextId() {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
|
||||||
|
// 当前时间戳小于上一次ID生成的时间戳
|
||||||
|
if (timestamp < lastTimestamp) {
|
||||||
|
long offset = lastTimestamp - timestamp;
|
||||||
|
// 系统时钟回退在容忍范围内,例如出现过闰秒
|
||||||
|
if (offset < timeOffset) {
|
||||||
|
timestamp = lastTimestamp;
|
||||||
|
}
|
||||||
|
// 系统时钟回退超出容忍范围,抛出异常
|
||||||
|
else {
|
||||||
|
throw new RuntimeException(String
|
||||||
|
.format("Clock moved backwards. Refusing to generate id for %d milliseconds", offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是同一时间生成的,则进行毫秒内序列
|
||||||
|
if (lastTimestamp == timestamp) {
|
||||||
|
sequence = (sequence + 1) & sequenceMask;
|
||||||
|
// 毫秒内序列溢出
|
||||||
|
if (sequence == 0) {
|
||||||
|
// 阻塞到下一个毫秒,获得新的时间戳
|
||||||
|
timestamp = tilNextMillis(lastTimestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 时间戳改变,毫秒内序列重置
|
||||||
|
else {
|
||||||
|
sequence = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上次生成ID的时间戳
|
||||||
|
lastTimestamp = timestamp;
|
||||||
|
|
||||||
|
// 移位并通过或运算拼到一起组成64位的ID
|
||||||
|
return ((timestamp - twepoch) << timestampLeftShift) //
|
||||||
|
| (datacenterId << datacenterIdShift) //
|
||||||
|
| (workerId << workerIdShift) //
|
||||||
|
| sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阻塞到下一个毫秒,直到获得新的时间戳
|
||||||
|
* @param lastTimestamp 上次生成ID的时间戳
|
||||||
|
* @return 当前时间戳
|
||||||
|
*/
|
||||||
|
protected long tilNextMillis(long lastTimestamp) {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
while (timestamp <= lastTimestamp) {
|
||||||
|
timestamp = timeGen();
|
||||||
|
}
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回以毫秒为单位的当前时间
|
||||||
|
* @return 当前时间(毫秒)
|
||||||
|
*/
|
||||||
|
protected long timeGen() {
|
||||||
|
return System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==============================Test=============================================
|
||||||
|
/** 测试 */
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.out.println("1000011111010000000111110011100110011110000000000000000001100".length());
|
||||||
|
// SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
|
||||||
|
// for (int i = 0; i < 1000; i++) {
|
||||||
|
// long id = idWorker.nextId();
|
||||||
|
// System.out.println(Long.toBinaryString(id));
|
||||||
|
// System.out.println(id);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.newyetai.codegenerator.service.generator;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.newyetai.codegenerator.constant.CodeConstants;
|
||||||
|
import com.newyetai.codegenerator.pojo.CodeParam;
|
||||||
|
import com.newyetai.codegenerator.service.CodeGenerator;
|
||||||
|
import com.newyetai.codegenerator.service.SnowflakeIdWorker;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认编号生成器
|
||||||
|
*
|
||||||
|
* @author sr on 2019-09-15
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SnowFlakeCodeGenerator implements CodeGenerator<CodeParam> {
|
||||||
|
|
||||||
|
private SnowflakeIdWorker snowflakeIdWorker;
|
||||||
|
|
||||||
|
public SnowFlakeCodeGenerator(SnowflakeIdWorker snowflakeIdWorker) {
|
||||||
|
this.snowflakeIdWorker = snowflakeIdWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return CodeConstants.GENERATOR_TYPE_SNOW_FLAKE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCode(CodeParam codeParam) {
|
||||||
|
return codeParam.getType() + snowflakeIdWorker.nextId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> batchCode(CodeParam codeParam, Integer batchNum) {
|
||||||
|
List<String> ids = Lists.newArrayListWithCapacity(batchNum);
|
||||||
|
for (int i = 0; i < batchNum; i++) {
|
||||||
|
ids.add(this.getCode(codeParam));
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user