Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chuanshan_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
chuanshan_gov_platform
Commits
f67fdb14
Commit
f67fdb14
authored
Mar 07, 2024
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
d04ef8dc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
310 additions
and
1 deletion
+310
-1
single-matter/src/main/java/com/mortals/xhx/common/utils/AESUtil.java
...r/src/main/java/com/mortals/xhx/common/utils/AESUtil.java
+241
-0
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
+42
-1
single-matter/src/main/java/com/mortals/xhx/module/apply/model/vo/MatterApplyVo.java
.../com/mortals/xhx/module/apply/model/vo/MatterApplyVo.java
+2
-0
single-matter/src/main/java/com/mortals/xhx/module/apply/web/MatterApplyController.java
...m/mortals/xhx/module/apply/web/MatterApplyController.java
+25
-0
No files found.
single-matter/src/main/java/com/mortals/xhx/common/utils/AESUtil.java
0 → 100644
View file @
f67fdb14
package
com.mortals.xhx.common.utils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.Base64Utils
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
/**
* AES加密工具类
*
*/
public
class
AESUtil
{
/**
* 日志相关
*/
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
AESUtil
.
class
);
/**
* 编码
*/
private
static
final
String
ENCODING
=
"UTF-8"
;
/**
* 算法定义
*/
private
static
final
String
AES_ALGORITHM
=
"AES"
;
/**
* 指定填充方式
*/
private
static
final
String
CIPHER_PADDING
=
"AES/ECB/PKCS5Padding"
;
private
static
final
String
CIPHER_CBC_PADDING
=
"AES/CBC/PKCS5Padding"
;
/**
* 偏移量(CBC中使用,增强加密算法强度)
*/
private
static
final
String
IV_SEED
=
"tdrdadq59tbss5n7"
;
/**
* AES加密
* @param content 待加密内容
* @param aesKey 密码
* @return
*/
public
static
String
encrypt
(
String
content
,
String
aesKey
){
if
(
StringUtils
.
isBlank
(
content
)){
LOGGER
.
info
(
"AES encrypt: the content is null!"
);
return
null
;
}
//判断秘钥是否为16位
if
(
StringUtils
.
isNotBlank
(
aesKey
)
&&
aesKey
.
length
()
==
16
){
try
{
//对密码进行编码
byte
[]
bytes
=
aesKey
.
getBytes
(
ENCODING
);
//设置加密算法,生成秘钥
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
bytes
,
AES_ALGORITHM
);
// "算法/模式/补码方式"
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_PADDING
);
//选择加密
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
);
//根据待加密内容生成字节数组
byte
[]
encrypted
=
cipher
.
doFinal
(
content
.
getBytes
(
ENCODING
));
//返回base64字符串
return
Base64Utils
.
encodeToString
(
encrypted
);
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"AES encrypt exception:"
+
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
}
else
{
LOGGER
.
info
(
"AES encrypt: the aesKey is null or error!"
);
return
null
;
}
}
/**
* 解密
*
* @param content 待解密内容
* @param aesKey 密码
* @return
*/
public
static
String
decrypt
(
String
content
,
String
aesKey
){
if
(
StringUtils
.
isBlank
(
content
)){
LOGGER
.
info
(
"AES decrypt: the content is null!"
);
return
null
;
}
//判断秘钥是否为16位
if
(
StringUtils
.
isNotBlank
(
aesKey
)
&&
aesKey
.
length
()
==
16
){
try
{
//对密码进行编码
byte
[]
bytes
=
aesKey
.
getBytes
(
ENCODING
);
//设置解密算法,生成秘钥
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
bytes
,
AES_ALGORITHM
);
// "算法/模式/补码方式"
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_PADDING
);
//选择解密
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
skeySpec
);
//先进行Base64解码
byte
[]
decodeBase64
=
Base64Utils
.
decodeFromString
(
content
);
//根据待解密内容进行解密
byte
[]
decrypted
=
cipher
.
doFinal
(
decodeBase64
);
//将字节数组转成字符串
return
new
String
(
decrypted
,
ENCODING
);
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"AES decrypt exception:"
+
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
}
else
{
LOGGER
.
info
(
"AES decrypt: the aesKey is null or error!"
);
return
null
;
}
}
/**
* AES_CBC加密
*
* @param content 待加密内容
* @param aesKey 密码
* @return
*/
public
static
String
encryptCBC
(
String
content
,
String
aesKey
){
if
(
StringUtils
.
isBlank
(
content
)){
LOGGER
.
info
(
"AES_CBC encrypt: the content is null!"
);
return
null
;
}
//判断秘钥是否为16位
if
(
StringUtils
.
isNotBlank
(
aesKey
)
&&
aesKey
.
length
()
==
16
){
try
{
//对密码进行编码
byte
[]
bytes
=
aesKey
.
getBytes
(
ENCODING
);
//设置加密算法,生成秘钥
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
bytes
,
AES_ALGORITHM
);
// "算法/模式/补码方式"
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_CBC_PADDING
);
//偏移
IvParameterSpec
iv
=
new
IvParameterSpec
(
IV_SEED
.
getBytes
(
ENCODING
));
//选择加密
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
,
iv
);
//根据待加密内容生成字节数组
byte
[]
encrypted
=
cipher
.
doFinal
(
content
.
getBytes
(
ENCODING
));
//返回base64字符串
return
Base64Utils
.
encodeToString
(
encrypted
);
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"AES_CBC encrypt exception:"
+
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
}
else
{
LOGGER
.
info
(
"AES_CBC encrypt: the aesKey is null or error!"
);
return
null
;
}
}
/**
* AES_CBC解密
*
* @param content 待解密内容
* @param aesKey 密码
* @return
*/
public
static
String
decryptCBC
(
String
content
,
String
aesKey
){
if
(
StringUtils
.
isBlank
(
content
)){
LOGGER
.
info
(
"AES_CBC decrypt: the content is null!"
);
return
null
;
}
//判断秘钥是否为16位
if
(
StringUtils
.
isNotBlank
(
aesKey
)
&&
aesKey
.
length
()
==
16
){
try
{
//对密码进行编码
byte
[]
bytes
=
aesKey
.
getBytes
(
ENCODING
);
//设置解密算法,生成秘钥
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
bytes
,
AES_ALGORITHM
);
//偏移
IvParameterSpec
iv
=
new
IvParameterSpec
(
IV_SEED
.
getBytes
(
ENCODING
));
// "算法/模式/补码方式"
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_CBC_PADDING
);
//选择解密
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
skeySpec
,
iv
);
//先进行Base64解码
byte
[]
decodeBase64
=
Base64Utils
.
decodeFromString
(
content
);
//根据待解密内容进行解密
byte
[]
decrypted
=
cipher
.
doFinal
(
decodeBase64
);
//将字节数组转成字符串
return
new
String
(
decrypted
,
ENCODING
);
}
catch
(
Exception
e
)
{
LOGGER
.
info
(
"AES_CBC decrypt exception:"
+
e
.
getMessage
());
throw
new
RuntimeException
(
e
);
}
}
else
{
LOGGER
.
info
(
"AES_CBC decrypt: the aesKey is null or error!"
);
return
null
;
}
}
public
static
void
main
(
String
[]
args
)
{
// AES支持三种长度的密钥:128位、192位、256位。
// 代码中这种就是128位的加密密钥,16字节 * 8位/字节 = 128位。
String
random
=
"0000000671595991"
;
// System.out.println("随机key:" + random);
// System.out.println();
//
// System.out.println("---------加密---------");
// String aesResult = encrypt("511181198903042414", random);
// System.out.println("aes加密结果:" + aesResult);
// System.out.println();
//
// System.out.println("---------解密---------");
// String decrypt = decrypt(aesResult, random);
// System.out.println("aes解密结果:" + decrypt);
// System.out.println();
//
//
// System.out.println("--------AES_CBC加密解密---------");
// String cbcResult = encryptCBC("511181198903042414", random);
// System.out.println("aes_cbc加密结果:" + cbcResult);
// System.out.println();
System
.
out
.
println
(
"---------解密CBC---------"
);
String
cbcDecrypt
=
decryptCBC
(
"SWYgzz2KjYx+6TopctMpJQ=="
,
random
);
System
.
out
.
println
(
"aes解密结果:"
+
cbcDecrypt
);
System
.
out
.
println
();
System
.
out
.
println
(
"---------解密CBC---------"
);
String
cbcDecrypt1
=
decryptCBC
(
"DXgGKRNryrPM/eeUQiN4wlfpYNUZ0XIwumXNHRFQGZM="
,
random
);
System
.
out
.
println
(
"aes解密结果:"
+
cbcDecrypt1
);
System
.
out
.
println
();
System
.
out
.
println
(
"---------解密CBC---------"
);
String
cbcDecrypt2
=
decryptCBC
(
"6yPbSSjvMeFuJ2ONqNmSyA=="
,
random
);
System
.
out
.
println
(
"aes解密结果:"
+
cbcDecrypt2
);
System
.
out
.
println
();
}
}
single-matter/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
View file @
f67fdb14
...
@@ -4,6 +4,7 @@ import com.mortals.framework.common.Rest;
...
@@ -4,6 +4,7 @@ import com.mortals.framework.common.Rest;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
...
@@ -11,6 +12,9 @@ import com.mortals.xhx.common.code.YesNoEnum;
...
@@ -11,6 +12,9 @@ import com.mortals.xhx.common.code.YesNoEnum;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.apply.model.ApproverEntity
;
import
com.mortals.xhx.module.apply.model.ApproverQuery
;
import
com.mortals.xhx.module.apply.service.ApproverService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -34,6 +38,8 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
...
@@ -34,6 +38,8 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@Autowired
private
ApproverService
approverService
;
@Override
@Override
...
@@ -70,7 +76,6 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
...
@@ -70,7 +76,6 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
//门户用户map
//门户用户map
// Map<String, UserEntity> newUserMap = newUserList.stream().collect(Collectors.toMap(x -> x.getLoginName(), y -> y, (o, n) -> n));
// Map<String, UserEntity> newUserMap = newUserList.stream().collect(Collectors.toMap(x -> x.getLoginName(), y -> y, (o, n) -> n));
List
<
UserEntity
>
saveUserList
=
newUserList
.
stream
().
map
(
item
->
{
List
<
UserEntity
>
saveUserList
=
newUserList
.
stream
().
map
(
item
->
{
if
(!
oldUserMap
.
containsKey
(
item
.
getLoginName
()))
{
if
(!
oldUserMap
.
containsKey
(
item
.
getLoginName
()))
{
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserId
(
1L
);
...
@@ -89,6 +94,42 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
...
@@ -89,6 +94,42 @@ public class SyncPortalUserTaskImpl implements ITaskExcuteService {
});
});
}
}
List
<
ApproverEntity
>
newApproverList
=
userPduList
.
stream
().
map
(
newUser
->
{
ApproverEntity
approverEntity
=
new
ApproverEntity
();
approverEntity
.
initAttrValue
();
approverEntity
.
setFullName
(
newUser
.
getRealName
());
if
(
StringUtils
.
isNotEmpty
(
newUser
.
getPhone
()))
{
approverEntity
.
setPhoneNumber
(
newUser
.
getMobile
());
}
else
{
approverEntity
.
setPhoneNumber
(
"13888888888"
);
}
approverEntity
.
setLoginName
(
newUser
.
getLoginName
());
approverEntity
.
setLoginPwd
(
newUser
.
getLoginPwd
());
return
approverEntity
;
}).
collect
(
Collectors
.
toList
());
List
<
ApproverEntity
>
oldApproverList
=
approverService
.
find
(
new
ApproverQuery
());
log
.
info
(
" oldApproverList size:{}"
,
oldApproverList
.
size
());
//当前单事项审批人员
Map
<
String
,
ApproverEntity
>
oldApproverMap
=
oldApproverList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
List
<
ApproverEntity
>
saveApproverList
=
newApproverList
.
stream
().
map
(
item
->
{
if
(!
oldApproverMap
.
containsKey
(
item
.
getLoginName
()))
{
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
saveApproverList
))
{
log
.
info
(
"单事项审批人员新增,size:{}"
,
saveApproverList
.
size
());
saveApproverList
.
stream
().
forEach
(
item
->
{
approverService
.
getDao
().
insert
(
item
);
});
}
}
}
//查找新增 与更新
//查找新增 与更新
...
...
single-matter/src/main/java/com/mortals/xhx/module/apply/model/vo/MatterApplyVo.java
View file @
f67fdb14
...
@@ -31,4 +31,6 @@ public class MatterApplyVo extends BaseEntityLong {
...
@@ -31,4 +31,6 @@ public class MatterApplyVo extends BaseEntityLong {
private
String
applyTypeName
;
private
String
applyTypeName
;
private
List
<
MatterApplyDatumGroupVO
>
datumGroupList
;
private
List
<
MatterApplyDatumGroupVO
>
datumGroupList
;
/** 数据来源 1:小程序,0其他*/
private
Integer
source
;
}
}
\ No newline at end of file
single-matter/src/main/java/com/mortals/xhx/module/apply/web/MatterApplyController.java
View file @
f67fdb14
...
@@ -11,6 +11,7 @@ import com.mortals.framework.utils.BeanUtil;
...
@@ -11,6 +11,7 @@ import com.mortals.framework.utils.BeanUtil;
import
com.mortals.framework.utils.ReflectUtils
;
import
com.mortals.framework.utils.ReflectUtils
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.common.utils.AESUtil
;
import
com.mortals.xhx.module.apply.model.MatterApplyDatumEntity
;
import
com.mortals.xhx.module.apply.model.MatterApplyDatumEntity
;
import
com.mortals.xhx.module.apply.model.MatterApplyDatumQuery
;
import
com.mortals.xhx.module.apply.model.MatterApplyDatumQuery
;
import
com.mortals.xhx.module.apply.service.MatterApplyDatumService
;
import
com.mortals.xhx.module.apply.service.MatterApplyDatumService
;
...
@@ -85,6 +86,12 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
...
@@ -85,6 +86,12 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
int
code
;
int
code
;
try
{
try
{
this
.
saveBefore
(
entity
,
model
,
context
);
this
.
saveBefore
(
entity
,
model
,
context
);
if
(
entity
.
getSource
()!=
null
&&
entity
.
getSource
()==
1
)
{
String
random
=
"0000000671595991"
;
entity
.
setApplyPerson
(
AESUtil
.
decryptCBC
(
entity
.
getApplyPerson
(),
random
));
entity
.
setIdCard
(
AESUtil
.
decryptCBC
(
entity
.
getIdCard
(),
random
));
entity
.
setPhoneNum
(
AESUtil
.
decryptCBC
(
entity
.
getPhoneNum
(),
random
));
}
if
(
entity
.
newEntity
())
{
if
(
entity
.
newEntity
())
{
Class
<
MatterApplyEntity
>
tClass
=
ReflectUtils
.
getClassGenricType
(
this
.
getClass
(),
1
);
Class
<
MatterApplyEntity
>
tClass
=
ReflectUtils
.
getClassGenricType
(
this
.
getClass
(),
1
);
MatterApplyEntity
initEntity
=
(
MatterApplyEntity
)
tClass
.
newInstance
();
MatterApplyEntity
initEntity
=
(
MatterApplyEntity
)
tClass
.
newInstance
();
...
@@ -193,6 +200,12 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
...
@@ -193,6 +200,12 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
int
code
;
int
code
;
try
{
try
{
if
(
entity
.
getSource
()!=
null
&&
entity
.
getSource
()==
1
)
{
String
random
=
"0000000671595991"
;
entity
.
setApplyPerson
(
AESUtil
.
decryptCBC
(
entity
.
getApplyPerson
(),
random
));
entity
.
setIdCard
(
AESUtil
.
decryptCBC
(
entity
.
getIdCard
(),
random
));
entity
.
setPhoneNum
(
AESUtil
.
decryptCBC
(
entity
.
getPhoneNum
(),
random
));
}
this
.
service
.
reApply
(
entity
,
context
);
this
.
service
.
reApply
(
entity
,
context
);
model
.
put
(
"id"
,
entity
.
getId
());
model
.
put
(
"id"
,
entity
.
getId
());
code
=
this
.
saveAfter
(
entity
,
model
,
context
);
code
=
this
.
saveAfter
(
entity
,
model
,
context
);
...
@@ -257,6 +270,18 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
...
@@ -257,6 +270,18 @@ public class MatterApplyController extends BaseCRUDJsonBodyMappingController<Mat
int
code
;
int
code
;
try
{
try
{
this
.
doListBefore
(
query
,
model
,
context
);
this
.
doListBefore
(
query
,
model
,
context
);
if
(
query
.
getSource
()!=
null
&&
query
.
getSource
()==
1
)
{
String
random
=
"0000000671595991"
;
if
(
StringUtils
.
isNotEmpty
(
query
.
getApplyPerson
()))
{
query
.
setApplyPerson
(
AESUtil
.
decryptCBC
(
query
.
getApplyPerson
(),
random
));
}
if
(
StringUtils
.
isNotEmpty
(
query
.
getIdCard
()))
{
query
.
setIdCard
(
AESUtil
.
decryptCBC
(
query
.
getIdCard
(),
random
));
}
if
(
StringUtils
.
isNotEmpty
(
query
.
getPhoneNum
()))
{
query
.
setPhoneNum
(
AESUtil
.
decryptCBC
(
query
.
getPhoneNum
(),
random
));
}
}
PageInfo
pageInfo
=
this
.
buildPageInfo
(
query
);
PageInfo
pageInfo
=
this
.
buildPageInfo
(
query
);
Result
<
MatterApplyEntity
>
result
=
this
.
getService
().
find
(
query
,
pageInfo
,
context
);
Result
<
MatterApplyEntity
>
result
=
this
.
getService
().
find
(
query
,
pageInfo
,
context
);
this
.
doListAfter
(
query
,
result
.
getList
(),
context
);
this
.
doListAfter
(
query
,
result
.
getList
(),
context
);
...
...
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