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
3072205a
Commit
3072205a
authored
Dec 17, 2019
by
杨锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用统一md5;
批量导入数据ignore;
parent
29679ff1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
UserHashPhoneNoIdNoMappingController.java
...ler/phonenoidno/UserHashPhoneNoIdNoMappingController.java
+3
-3
UserHashPhoneNoIdNoMapping.java
...cn/quantgroup/xyqb/entity/UserHashPhoneNoIdNoMapping.java
+12
-0
PhoneHashEventListener.java
...java/cn/quantgroup/xyqb/event/PhoneHashEventListener.java
+1
-2
UserDetailHashEventListener.java
...cn/quantgroup/xyqb/event/UserDetailHashEventListener.java
+1
-2
No files found.
src/main/java/cn/quantgroup/xyqb/controller/phonenoidno/UserHashPhoneNoIdNoMappingController.java
View file @
3072205a
package
cn
.
quantgroup
.
xyqb
.
controller
.
phonenoidno
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
phonenoidno
;
import
cn.quantgroup.xyqb.entity.UserHashPhoneNoIdNoMapping
;
import
cn.quantgroup.xyqb.entity.UserHashPhoneNoIdNoMapping
;
import
cn.quantgroup.xyqb.util.encrypt.Md5Util
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -8,7 +9,6 @@ import org.springframework.data.redis.core.StringRedisTemplate;
...
@@ -8,7 +9,6 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import
org.springframework.jdbc.core.BatchPreparedStatementSetter
;
import
org.springframework.jdbc.core.BatchPreparedStatementSetter
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.RowCallbackHandler
;
import
org.springframework.jdbc.core.RowCallbackHandler
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -72,13 +72,13 @@ public class UserHashPhoneNoIdNoMappingController {
...
@@ -72,13 +72,13 @@ public class UserHashPhoneNoIdNoMappingController {
/* 暂存 */
/* 暂存 */
userHashPhoneNoIdNoMapping
.
setId
(
rs
.
getLong
(
"id"
));
userHashPhoneNoIdNoMapping
.
setId
(
rs
.
getLong
(
"id"
));
userHashPhoneNoIdNoMapping
.
setUserId
(
rs
.
getLong
(
"user_id"
));
userHashPhoneNoIdNoMapping
.
setUserId
(
rs
.
getLong
(
"user_id"
));
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
DigestUtils
.
md5DigestAsHex
((
rs
.
getString
(
"phone_no"
)
+
rs
.
getString
(
"id_no"
)).
toLowerCase
().
getBytes
()));
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
Md5Util
.
build
((
rs
.
getString
(
"phone_no"
)
+
rs
.
getString
(
"id_no"
)).
toLowerCase
()));
userHashPhoneNoIdNoMappings
.
add
(
userHashPhoneNoIdNoMapping
);
userHashPhoneNoIdNoMappings
.
add
(
userHashPhoneNoIdNoMapping
);
}
}
});
});
// TODO: 2019/12/13 rewriteBatchedStatements=true
// TODO: 2019/12/13 rewriteBatchedStatements=true
if
(
CollectionUtils
.
isNotEmpty
(
userHashPhoneNoIdNoMappings
))
{
if
(
CollectionUtils
.
isNotEmpty
(
userHashPhoneNoIdNoMappings
))
{
jdbcTemplate
.
batchUpdate
(
"insert into user_hash_phone_no_id_no_mapping (user_id, phone_no_id_no_md5) values (?,?)"
,
new
BatchPreparedStatementSetter
()
{
jdbcTemplate
.
batchUpdate
(
"insert i
gnore i
nto user_hash_phone_no_id_no_mapping (user_id, phone_no_id_no_md5) values (?,?)"
,
new
BatchPreparedStatementSetter
()
{
@Override
@Override
public
void
setValues
(
PreparedStatement
ps
,
int
i
)
throws
SQLException
{
public
void
setValues
(
PreparedStatement
ps
,
int
i
)
throws
SQLException
{
UserHashPhoneNoIdNoMapping
userHashPhoneNoIdNoMapping
=
userHashPhoneNoIdNoMappings
.
get
(
i
);
UserHashPhoneNoIdNoMapping
userHashPhoneNoIdNoMapping
=
userHashPhoneNoIdNoMappings
.
get
(
i
);
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserHashPhoneNoIdNoMapping.java
View file @
3072205a
...
@@ -28,4 +28,16 @@ public class UserHashPhoneNoIdNoMapping {
...
@@ -28,4 +28,16 @@ public class UserHashPhoneNoIdNoMapping {
public
UserHashPhoneNoIdNoMapping
(
Long
userId
)
{
public
UserHashPhoneNoIdNoMapping
(
Long
userId
)
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
@PrePersist
public
void
prePersist
()
{
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
createdAt
=
timestamp
;
updatedAt
=
timestamp
;
}
@PreUpdate
public
void
preUpdate
()
{
updatedAt
=
new
Timestamp
(
System
.
currentTimeMillis
());
}
}
}
src/main/java/cn/quantgroup/xyqb/event/PhoneHashEventListener.java
View file @
3072205a
...
@@ -11,7 +11,6 @@ import org.apache.commons.lang.StringUtils;
...
@@ -11,7 +11,6 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.DigestUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.persistence.PersistenceException
;
import
javax.persistence.PersistenceException
;
...
@@ -42,7 +41,7 @@ public class PhoneHashEventListener implements ApplicationListener<RegisterEvent
...
@@ -42,7 +41,7 @@ public class PhoneHashEventListener implements ApplicationListener<RegisterEvent
if
(
StringUtils
.
isNotEmpty
(
idNo
))
{
if
(
StringUtils
.
isNotEmpty
(
idNo
))
{
phoneNoIdNoMd5
.
append
(
idNo
);
phoneNoIdNoMd5
.
append
(
idNo
);
}
}
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
DigestUtils
.
md5DigestAsHex
(
phoneNoIdNoMd5
.
toString
().
toLowerCase
().
getBytes
()));
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
Md5Util
.
build
(
phoneNoIdNoMd5
.
toString
().
toLowerCase
()));
try
{
try
{
userHashPhoneNoIdNoMappingRepository
.
saveAndFlush
(
userHashPhoneNoIdNoMapping
);
userHashPhoneNoIdNoMappingRepository
.
saveAndFlush
(
userHashPhoneNoIdNoMapping
);
}
catch
(
PersistenceException
e
)
{
}
catch
(
PersistenceException
e
)
{
...
...
src/main/java/cn/quantgroup/xyqb/event/UserDetailHashEventListener.java
View file @
3072205a
...
@@ -10,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -10,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.DigestUtils
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.persistence.PersistenceException
;
import
javax.persistence.PersistenceException
;
...
@@ -61,7 +60,7 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
...
@@ -61,7 +60,7 @@ public class UserDetailHashEventListener implements ApplicationListener<UserDeta
}
}
//可能存在手机号、身份证号修改. 搞一下.
//可能存在手机号、身份证号修改. 搞一下.
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
DigestUtils
.
md5DigestAsHex
((
userDetail
.
getPhoneNo
()
+
userDetail
.
getIdNo
()).
toLowerCase
().
getBytes
()));
userHashPhoneNoIdNoMapping
.
setPhoneNoIdNoMd5
(
Md5Util
.
build
((
userDetail
.
getPhoneNo
()
+
userDetail
.
getIdNo
()).
toLowerCase
()));
try
{
try
{
userHashPhoneNoIdNoMappingRepository
.
save
(
userHashPhoneNoIdNoMapping
);
userHashPhoneNoIdNoMappingRepository
.
save
(
userHashPhoneNoIdNoMapping
);
...
...
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