Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
d26b7248
Commit
d26b7248
authored
Jan 04, 2022
by
killer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
phone数据加密
parent
738586df
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62041 additions
and
16 deletions
+62041
-16
pom.xml
pom.xml
+7
-0
SecurityConfig.java
src/main/java/cn/quantgroup/xyqb/config/SecurityConfig.java
+27
-0
TestController.java
...in/java/cn/quantgroup/xyqb/controller/TestController.java
+33
-0
Contact.java
src/main/java/cn/quantgroup/xyqb/entity/Contact.java
+3
-0
ModifyPhoneNo.java
src/main/java/cn/quantgroup/xyqb/entity/ModifyPhoneNo.java
+4
-0
User.java
src/main/java/cn/quantgroup/xyqb/entity/User.java
+25
-12
UserDetail.java
src/main/java/cn/quantgroup/xyqb/entity/UserDetail.java
+3
-4
UserSpouse.java
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
+2
-0
UuidPhoneMapping.java
...main/java/cn/quantgroup/xyqb/entity/UuidPhoneMapping.java
+2
-0
WechatUserInfo.java
src/main/java/cn/quantgroup/xyqb/entity/WechatUserInfo.java
+2
-0
EncryptConverter.java
...cn/quantgroup/xyqb/entity/converter/EncryptConverter.java
+38
-0
xyqb-user2.log
xyqb-user2.log
+61895
-0
No files found.
pom.xml
View file @
d26b7248
...
...
@@ -412,6 +412,13 @@
</exclusions>
</dependency>
<!-- 统一加解密包 -->
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
security
</artifactId>
<version>
0.1.2
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/cn/quantgroup/xyqb/config/SecurityConfig.java
0 → 100644
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
config
;
import
cn.quantgroup.security.AESEncryption
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* 统一加解密配置
*
* @author killer
* @date 2022年01月04日
**/
@Configuration
public
class
SecurityConfig
{
@Value
(
"${keystone.security.key}"
)
private
String
key
;
@Value
(
"${keystone.security.iv}"
)
private
String
iv
;
@Bean
public
AESEncryption
encryption
()
{
return
new
AESEncryption
(
key
,
iv
,
true
);
}
}
src/main/java/cn/quantgroup/xyqb/controller/TestController.java
0 → 100644
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
controller
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
/**
* 测试类
*
* @author killer
* @date 2022年01月04日
**/
@RestController
@RequestMapping
(
"/v1/test"
)
@RequiredArgsConstructor
public
class
TestController
{
private
final
IUserRepository
userRepository
;
@PostMapping
(
value
=
"/save/user"
)
public
JsonResult
<?>
saveUser
(
@RequestBody
User
user
)
{
User
result
=
userRepository
.
save
(
user
);
return
JsonResult
.
buildSuccessResult
(
"保存成功"
,
result
);
}
@GetMapping
(
value
=
"/query/user/{id}"
)
public
JsonResult
<?>
saveUser
(
@PathVariable
(
"id"
)
Long
id
)
{
User
result
=
userRepository
.
findById
(
id
);
return
JsonResult
.
buildSuccessResult
(
"查询成功"
,
result
);
}
}
src/main/java/cn/quantgroup/xyqb/entity/Contact.java
View file @
d26b7248
...
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.entity;
import
cn.quantgroup.user.enums.BizType
;
import
cn.quantgroup.user.enums.Relation
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
cn.quantgroup.xyqb.model.Tuple
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.AllArgsConstructor
;
...
...
@@ -10,6 +11,7 @@ import lombok.Data;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Column
;
import
javax.persistence.Convert
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
...
...
@@ -31,6 +33,7 @@ public class Contact extends BaseEntity implements Serializable {
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
phoneNo
;
@Column
(
name
=
"biz_type"
)
private
BizType
bizType
=
BizType
.
CASH
;
...
...
src/main/java/cn/quantgroup/xyqb/entity/ModifyPhoneNo.java
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Convert
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
...
...
@@ -43,12 +45,14 @@ public class ModifyPhoneNo extends BaseEntity implements Serializable {
* 原手机号码
*/
@Column
(
name
=
"prev_phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
prevPhoneNo
;
/**
* 新手机号码
*/
@Column
(
name
=
"cur_phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
curPhoneNo
;
/**
...
...
src/main/java/cn/quantgroup/xyqb/entity/User.java
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.UniqueConstraint
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Objects
;
/**
* Created by Miraculous on 15/7/4.
* 用户表
*
* @author Miraculous
* @date 2015年07月04日
*/
@Getter
@Setter
@ToString
@Entity
@Table
(
name
=
"user"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
=
"phone_no"
))
@Table
(
name
=
"user"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
=
"phone_no"
))
public
class
User
extends
BaseEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
//手机号
/**
* 手机号
*/
@Column
(
name
=
"phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
phoneNo
;
//uuid
/**
* password
*/
@Column
(
name
=
"password"
)
private
String
password
;
//第一次用户来源 channel_id
/**
* 第一次用户来源 channel_id
*/
@Column
(
name
=
"registered_from"
)
private
Long
registeredFrom
;
//uuid
/**
* uuid
*/
@Column
(
name
=
"uuid"
)
private
String
uuid
;
/**
* 是否禁用
*/
@Column
(
name
=
"enable"
)
private
Boolean
enable
;
/**
* 是否有密码
*
* @return
* @return
true/false
*/
public
boolean
getHasPassword
()
{
return
Objects
.
nonNull
(
password
)
&&
!
Objects
.
equals
(
""
,
password
);
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserDetail.java
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.motan.retbean.XUserDetail
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.IdType
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.UniqueConstraint
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Optional
;
...
...
@@ -32,6 +30,7 @@ public class UserDetail extends BaseEntity implements Serializable {
private
Long
userId
;
@Column
(
name
=
"phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
phoneNo
;
@Column
(
name
=
"name"
)
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
View file @
d26b7248
...
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.entity;
import
cn.quantgroup.user.enums.MaritalStatus
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.*
;
...
...
@@ -24,6 +25,7 @@ public class UserSpouse extends BaseEntity implements Serializable {
private
Long
userId
;
@Column
(
name
=
"spouse_phone"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
spousePhone
;
@Column
(
name
=
"spouse_name"
)
...
...
src/main/java/cn/quantgroup/xyqb/entity/UuidPhoneMapping.java
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
...
...
@@ -28,6 +29,7 @@ public class UuidPhoneMapping implements Serializable {
private
String
uuid
;
@Column
(
name
=
"phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
phoneNo
;
...
...
src/main/java/cn/quantgroup/xyqb/entity/WechatUserInfo.java
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.entity.converter.EncryptConverter
;
import
cn.quantgroup.xyqb.util.EmojiUtil
;
import
lombok.Data
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -23,6 +24,7 @@ public class WechatUserInfo extends BaseEntity implements Serializable {
@Column
(
name
=
"open_id"
)
private
String
openId
;
@Column
(
name
=
"phone_no"
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
phoneNo
=
""
;
@Column
(
name
=
"app_name"
)
private
String
appName
=
"xyqb"
;
...
...
src/main/java/cn/quantgroup/xyqb/entity/converter/EncryptConverter.java
0 → 100644
View file @
d26b7248
package
cn
.
quantgroup
.
xyqb
.
entity
.
converter
;
import
cn.quantgroup.security.AESEncryption
;
import
cn.quantgroup.xyqb.util.ApplicationContextHolder
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.AttributeConverter
;
import
javax.persistence.Converter
;
/**
* 字段加解密转换器
*
* @author killer
* @date 2022年01月04日
**/
@Converter
public
class
EncryptConverter
implements
AttributeConverter
<
String
,
String
>
{
@Override
public
String
convertToDatabaseColumn
(
String
entityAttribute
)
{
/* 加密 */
if
(
StringUtils
.
isBlank
(
entityAttribute
))
{
return
entityAttribute
;
}
AESEncryption
aesEncryption
=
ApplicationContextHolder
.
getBean
(
AESEncryption
.
class
);
return
aesEncryption
.
encryptBase64
(
entityAttribute
);
}
@Override
public
String
convertToEntityAttribute
(
String
databaseColumn
)
{
/* 解密 */
if
(
StringUtils
.
isBlank
(
databaseColumn
))
{
return
databaseColumn
;
}
AESEncryption
aesEncryption
=
ApplicationContextHolder
.
getBean
(
AESEncryption
.
class
);
return
aesEncryption
.
decryptBase64
(
databaseColumn
);
}
}
xyqb-user2.log
View file @
d26b7248
This diff is collapsed.
Click to expand it.
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