Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lei
fzm-joying
Commits
19cc14a8
Commit
19cc14a8
authored
Sep 13, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实名认证接口
parent
c9e2d04c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
25 deletions
+63
-25
UserController.java
...rc/main/java/com/fzm/admin/controller/UserController.java
+11
-4
AuthPerson.java
...ommon/src/main/java/com/fzm/common/entity/AuthPerson.java
+14
-7
UserListVo.java
...on/src/main/java/com/fzm/common/entity/vo/UserListVo.java
+3
-0
UserService.java
...mon/src/main/java/com/fzm/common/service/UserService.java
+3
-0
UserServiceImpl.java
...ain/java/com/fzm/common/service/impl/UserServiceImpl.java
+31
-13
UserMapper.xml
joying-common/src/main/resources/mapper/UserMapper.xml
+1
-0
UserController.java
...c/main/java/com/fzm/portal/controller/UserController.java
+0
-1
No files found.
joying-admin/src/main/java/com/fzm/admin/controller/UserController.java
View file @
19cc14a8
package
com
.
fzm
.
admin
.
controller
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.entity.AuthPerson
;
import
com.fzm.common.entity.vo.UserListVo
;
import
com.fzm.common.entity.vo.UserStatisticVo
;
import
com.fzm.common.model.ResponseModel
;
...
...
@@ -10,10 +11,7 @@ import com.github.pagehelper.PageInfo;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -51,4 +49,13 @@ public class UserController {
List
<
UserListVo
>
list
=
userService
.
list
(
telephone
,
nickname
,
authType
,
start
,
end
);
return
ResponseModel
.
success
(
new
PageInfo
<>(
list
));
}
@GetMapping
(
"auth/detail"
)
@ApiOperation
(
value
=
"获取用户的实名信息"
)
public
ResponseModel
<
AuthPerson
>
getAuthDetail
(
@RequestParam
Integer
userId
)
{
AuthPerson
authPerson
=
userService
.
getAuthDetail
(
userId
);
return
ResponseModel
.
success
(
authPerson
);
}
}
joying-common/src/main/java/com/fzm/common/entity/AuthPerson.java
View file @
19cc14a8
...
...
@@ -3,6 +3,7 @@ package com.fzm.common.entity;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -10,6 +11,7 @@ import lombok.experimental.Accessors;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.Pattern
;
import
java.util.Date
;
/**
* @author tangtuo
...
...
@@ -19,28 +21,33 @@ import javax.validation.constraints.Pattern;
@Accessors
(
chain
=
true
)
@ApiModel
(
"个人认证信息"
)
@TableName
(
"tb_auth_person"
)
public
class
AuthPerson
extends
BaseEntity
{
public
class
AuthPerson
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
@ApiModelProperty
(
"用户id"
)
private
Integer
userId
;
@ApiModelProperty
(
"姓名"
)
@NotBlank
(
message
=
"姓名不能为空"
)
private
String
name
;
@ApiModelProperty
(
"身份证号码"
)
@NotBlank
(
message
=
"身份证号码不能为空"
)
@Pattern
(
regexp
=
"^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$"
,
message
=
"身份证号码格式有误"
)
private
String
idCard
;
@ApiModelProperty
(
"身份证正面照片(人脸面)"
)
@
NotBlank
(
message
=
"身份证正面照片不能为空"
)
@
JsonProperty
(
access
=
JsonProperty
.
Access
.
WRITE_ONLY
)
private
String
cardPictureFront
;
@ApiModelProperty
(
"身份证反面照片(国徽面)"
)
@
NotBlank
(
message
=
"身份证反面照片不能为空"
)
@
JsonProperty
(
access
=
JsonProperty
.
Access
.
WRITE_ONLY
)
private
String
cardPictureBack
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createDate
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateDate
;
}
joying-common/src/main/java/com/fzm/common/entity/vo/UserListVo.java
View file @
19cc14a8
...
...
@@ -26,6 +26,9 @@ public class UserListVo {
@ApiModelProperty
(
"认证类型 0-个人认证 1-企业认证"
)
private
Integer
authType
;
@ApiModelProperty
(
"实名认证状态 0-未认证 1-认证成功 2-认证失败"
)
private
Integer
authStatus
;
@ApiModelProperty
(
"已发行nft数"
)
private
Integer
publishCount
;
...
...
joying-common/src/main/java/com/fzm/common/service/UserService.java
View file @
19cc14a8
package
com
.
fzm
.
common
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.fzm.common.entity.AuthPerson
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.vo.UserListVo
;
import
com.fzm.common.entity.vo.UserStatisticVo
;
...
...
@@ -74,4 +75,6 @@ public interface UserService extends IService<User> {
User
getUserByWallet
(
String
publishAddress
);
IdCardOCRVerificationResponse
personAuth
(
MultipartFile
cardPictureFront
,
MultipartFile
cardPictureBack
)
throws
IOException
;
AuthPerson
getAuthDetail
(
Integer
userId
);
}
joying-common/src/main/java/com/fzm/common/service/impl/UserServiceImpl.java
View file @
19cc14a8
...
...
@@ -215,28 +215,31 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public
IdCardOCRVerificationResponse
personAuth
(
MultipartFile
cardPictureFront
,
MultipartFile
cardPictureBack
)
throws
IOException
{
String
token
=
request
.
getHeader
(
"Authorization"
);
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
token
);
User
user
=
getUserByToken
();
if
(
AuthStatusEnum
.
SUCCESS
.
getStatus
().
equals
(
user
.
getAuthStatus
()))
{
throw
GlobalException
.
newException
(
ResultCode
.
ID_CARD_VERIFICATION_ERROR
,
"您已认证成功,无法再次认证"
);
}
Integer
userId
=
user
.
getId
();
BASE64Encoder
base64Encoder
=
new
BASE64Encoder
();
String
encode
=
"data:image/jpg;base64,"
+
base64Encoder
.
encode
(
cardPictureFront
.
getBytes
());
IdCardOCRVerificationResponse
response
=
TencentApi
.
idCardOCRVerification
(
encode
);
// 验证成功上传身份证证件
String
frontUrl
=
ossUtil
.
putSimpleObject
(
cardPictureFront
);
String
backUrl
=
ossUtil
.
putSimpleObject
(
cardPictureBack
);
AuthPerson
authPerson
=
new
AuthPerson
()
.
setUserId
(
userId
)
.
setIdCard
(
response
.
getIdCard
())
.
setName
(
response
.
getName
())
.
setCardPictureBack
(
backUrl
)
.
setCardPictureFront
(
frontUrl
);
authPersonService
.
save
(
authPerson
);
UpdateWrapper
<
User
>
userUpdateWrapper
=
new
UpdateWrapper
<>();
Integer
status
;
if
(
IdCardVerificationResponse
.
SUCCESS
.
getCode
().
equals
(
response
.
getResult
()))
{
// 验证成功上传身份证证件
String
frontUrl
=
ossUtil
.
putSimpleObject
(
cardPictureFront
);
String
backUrl
=
ossUtil
.
putSimpleObject
(
cardPictureBack
);
AuthPerson
authPerson
=
new
AuthPerson
()
.
setUserId
(
userId
)
.
setIdCard
(
response
.
getIdCard
())
.
setName
(
response
.
getName
())
.
setCardPictureBack
(
backUrl
)
.
setCardPictureFront
(
frontUrl
);
authPersonService
.
save
(
authPerson
);
status
=
AuthStatusEnum
.
SUCCESS
.
getStatus
();
}
else
{
status
=
AuthStatusEnum
.
FAIL
.
getStatus
();
}
UpdateWrapper
<
User
>
userUpdateWrapper
=
new
UpdateWrapper
<>();
userUpdateWrapper
.
set
(
"auth_type"
,
AuthTypeEnum
.
PERSON
.
getType
())
.
set
(
"auth_status"
,
status
)
.
eq
(
"id"
,
userId
);
...
...
@@ -245,6 +248,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
}
@Override
public
AuthPerson
getAuthDetail
(
Integer
userId
)
{
User
user
=
getById
(
userId
);
if
(!
AuthStatusEnum
.
SUCCESS
.
getStatus
().
equals
(
user
.
getAuthStatus
()))
{
throw
GlobalException
.
newException
(
ResultCode
.
DATA_ERROR
,
"此用户实名认证未成功,无法查看其具体实名信息"
);
}
// 个人认证
if
(
AuthTypeEnum
.
PERSON
.
getType
().
equals
(
user
.
getAuthType
()))
{
QueryWrapper
<
AuthPerson
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"user_id"
,
userId
);
return
authPersonService
.
getOne
(
queryWrapper
);
}
return
null
;
}
@Override
public
List
<
UserListVo
>
list
(
String
telephone
,
String
nickname
,
Integer
authType
,
String
start
,
String
end
)
{
DateTime
startDate
=
null
;
DateTime
endDate
=
null
;
...
...
joying-common/src/main/resources/mapper/UserMapper.xml
View file @
19cc14a8
...
...
@@ -7,6 +7,7 @@
u.telephone,
u.nickname,
u.auth_type,
u.auth_status,
u.create_date AS registerDate,
(select count(0) from tb_nft n where u.wallet = n.publish_address and n.nft_hash != '') as publishCount
FROM tb_user u
...
...
joying-portal/src/main/java/com/fzm/portal/controller/UserController.java
View file @
19cc14a8
...
...
@@ -129,7 +129,6 @@ public class UserController {
@ApiOperation
(
value
=
"个人认证"
)
public
ResponseModel
<
IdCardOCRVerificationResponse
>
personAuth
(
@ApiParam
(
"身份证正面照"
)
@RequestParam
MultipartFile
front
,
@ApiParam
(
"身份证反面照"
)
@RequestParam
MultipartFile
back
)
throws
IOException
{
return
ResponseModel
.
success
(
userService
.
personAuth
(
front
,
back
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment