Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
entrance_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
王琮
entrance_api
Commits
3c7e4391
Commit
3c7e4391
authored
Dec 26, 2022
by
zhangyanduan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复捷顺接口中新增用户的头像数据转换为base64字符串上传
parent
3e887912
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
JieLinkServiceImpl.java
.../integration/jieLink/service/impl/JieLinkServiceImpl.java
+29
-1
No files found.
src/main/java/org/rcisoft/integration/jieLink/service/impl/JieLinkServiceImpl.java
View file @
3c7e4391
...
...
@@ -32,7 +32,10 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.client.RestTemplate
;
import
java.io.IOException
;
import
java.math.BigInteger
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.*
;
/**
...
...
@@ -288,7 +291,14 @@ public class JieLinkServiceImpl implements IJieLinkService {
pushData
.
setPersonNo
(
userData
.
getUsername
());
//人员编号
pushData
.
setPersonName
(
userData
.
getName
());
//姓名 必填
pushData
.
setPersonGender
(
StringUtils
.
equals
(
"0"
,
userData
.
getSex
())?
1
:
StringUtils
.
equals
(
"1"
,
userData
.
getSex
())?
0
:
null
);
//性别
pushData
.
setPersonPhoto
(
userData
.
getFaceAddress
());
//此处需要将头像信息转换成BASE64数据存储
if
(
StringUtils
.
isNotBlank
(
userData
.
getFaceAddress
())){
//读取文件将文件转换为base64字符串
String
picBase64Str
=
encryptToBase64
(
userData
.
getFaceAddress
());
if
(
StringUtils
.
isNotBlank
(
picBase64Str
)){
pushData
.
setPersonPhoto
(
picBase64Str
);
}
}
//身份证处理
if
(
StringUtils
.
isNotBlank
(
userData
.
getIdNumber
())){
if
(
userData
.
getIdNumber
().
trim
().
length
()==
15
){
...
...
@@ -764,5 +774,23 @@ public class JieLinkServiceImpl implements IJieLinkService {
}
}
/**
* 将文件转换为base64字符串
* @param filePath
* @return
*/
public
String
encryptToBase64
(
String
filePath
)
{
if
(
filePath
==
null
)
{
return
null
;
}
try
{
byte
[]
b
=
Files
.
readAllBytes
(
Paths
.
get
(
filePath
));
return
Base64
.
getEncoder
().
encodeToString
(
b
);
}
catch
(
IOException
e
)
{
log
.
error
(
"读取用户头像文件失败:"
+
e
.
getMessage
(),
e
);
}
return
null
;
}
}
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