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
d4e08770
Commit
d4e08770
authored
Jul 17, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持身份证号和手机号前码模糊查询UserDetail列表
parent
65a95fb2
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
102 additions
and
34 deletions
+102
-34
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+2
-0
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+18
-0
UserApiController.java
...roup/xyqb/controller/external/user/UserApiController.java
+17
-14
IUserDetailRepository.java
.../cn/quantgroup/xyqb/repository/IUserDetailRepository.java
+22
-2
IUserRepository.java
...n/java/cn/quantgroup/xyqb/repository/IUserRepository.java
+3
-2
IUserDetailService.java
...a/cn/quantgroup/xyqb/service/user/IUserDetailService.java
+12
-3
IUserService.java
...in/java/cn/quantgroup/xyqb/service/user/IUserService.java
+3
-3
UserDetailServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
+25
-10
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
d4e08770
...
@@ -110,6 +110,8 @@ public interface Constants {
...
@@ -110,6 +110,8 @@ public interface Constants {
* 默认随机密码长度
* 默认随机密码长度
*/
*/
int
RANDOM_PWD_LEN
=
15
;
int
RANDOM_PWD_LEN
=
15
;
/** 标准大陆身份证号长度 */
int
IDNO_LENGTH
=
18
;
interface
Channel
{
interface
Channel
{
long
BAITIAO
=
222L
;
long
BAITIAO
=
222L
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
d4e08770
...
@@ -586,6 +586,24 @@ public class InnerController implements IBaseController {
...
@@ -586,6 +586,24 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildSuccessResult
(
"success"
,
userDetails
);
return
JsonResult
.
buildSuccessResult
(
"success"
,
userDetails
);
}
}
/**
* 按照身份证号和手机号 - 模糊查询
* @param phoneNo - 手机号
* @param idNo - 身份证号
* @return JsonResult<List<UserDetail>>
*/
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"按照身份证号和手机号,模糊查询用户详情"
)
@RequestMapping
(
"/user_detail/fuzzyQuery"
)
public
JsonResult
<
List
<
UserDetail
>>
fuzzyQueryUserDetailList
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
name
=
"phoneNo"
)
String
phoneNo
,
@ApiParam
(
value
=
"身份证号"
,
required
=
true
)
@RequestParam
(
name
=
"idNo"
)
String
idNo
)
{
log
.
info
(
"fuzzyQueryUserDetailList, phone:{},idNo:{},ip:{}"
,
phoneNo
,
idNo
,
getIp
());
if
(
StringUtils
.
isBlank
(
phoneNo
)
&&
StringUtils
.
isBlank
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"至少必须满足一个条件不为空"
,
null
);
}
List
<
UserDetail
>
userDetailList
=
userDetailService
.
fuzzyQueryByPhoneNoAndIdNo
(
phoneNo
,
idNo
);
return
JsonResult
.
buildSuccessResult
(
"success"
,
userDetailList
);
}
@RequestMapping
(
"/user_ext_info/search/user_id"
)
@RequestMapping
(
"/user_ext_info/search/user_id"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"查询用户扩展信息"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"查询用户扩展信息"
)
public
JsonResult
searchUserExtInfoByUserId
(
Long
userId
)
{
public
JsonResult
searchUserExtInfoByUserId
(
Long
userId
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/UserApiController.java
View file @
d4e08770
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
;
import
java.util.Objects
;
import
javax.annotation.Resource
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.service.api.IUserApiService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.session.XyqbSessionContextHolder
;
import
cn.quantgroup.xyqb.session.XyqbSessionContextHolder
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.Objects
;
/**
/**
* Created by FrankChow on 15/12/16.
* Created by FrankChow on 15/12/16.
...
...
src/main/java/cn/quantgroup/xyqb/repository/IUserDetailRepository.java
View file @
d4e08770
package
cn
.
quantgroup
.
xyqb
.
repository
;
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
java.util.List
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
...
@@ -8,7 +9,8 @@ import org.springframework.data.jpa.repository.Modifying;
...
@@ -8,7 +9,8 @@ import org.springframework.data.jpa.repository.Modifying;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.model.UserInfo
;
/**
/**
* @author mengfan.feng
* @author mengfan.feng
...
@@ -56,4 +58,22 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,
...
@@ -56,4 +58,22 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,
@Query
(
value
=
"update user_detail set name=?1 where phone_no=?2"
,
nativeQuery
=
true
)
@Query
(
value
=
"update user_detail set name=?1 where phone_no=?2"
,
nativeQuery
=
true
)
int
updateNameByPhoneNo
(
String
name
,
String
phoneNo
);
int
updateNameByPhoneNo
(
String
name
,
String
phoneNo
);
/**
* 按照身份证号和手机号 - 模糊查询
* @param phoneNo - 手机号
* @param idNo - 身份证号
* @return List<UserDetail>
*/
@Query
(
value
=
"select * from user_detail where phone_no like ?1 and id_no like ?2"
,
nativeQuery
=
true
)
List
<
UserDetail
>
fuzzyQueryByPhoneNoAndIdNo
(
String
phoneNo
,
String
idNo
);
/**
* 按照身份证号和手机号 - 模糊查询
* @param phoneNo - 手机号
* @param idNo - 身份证号
* @return List<UserInfo>
*/
@Query
(
value
=
"select * from user u left join user_detail ud on u.id=ud.user_id where u.phone_no like ?1 and ud.id_no like ?2"
,
nativeQuery
=
true
)
List
<
UserInfo
>
fuzzyQuery
(
String
phoneNo
,
String
idNo
);
}
}
src/main/java/cn/quantgroup/xyqb/repository/IUserRepository.java
View file @
d4e08770
package
cn
.
quantgroup
.
xyqb
.
repository
;
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.User
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
cn.quantgroup.xyqb.entity.User
;
/**
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IUserDetailService.java
View file @
d4e08770
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
java.util.List
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
/**
/**
* Created by 11 on 2016/12/29.
* Created by 11 on 2016/12/29.
...
@@ -44,4 +45,12 @@ public interface IUserDetailService {
...
@@ -44,4 +45,12 @@ public interface IUserDetailService {
int
updateIdCard
(
String
name
,
String
idNo
,
String
phoneNo
);
int
updateIdCard
(
String
name
,
String
idNo
,
String
phoneNo
);
List
<
UserDetail
>
findByPhones
(
List
<
String
>
phoneNos
);
List
<
UserDetail
>
findByPhones
(
List
<
String
>
phoneNos
);
/**
* 按照身份证号和手机号 - 模糊查询
* @param phoneNo - 手机号
* @param idNo - 身份证号
* @return List<UserDetail>
*/
List
<
UserDetail
>
fuzzyQueryByPhoneNoAndIdNo
(
String
phoneNo
,
String
idNo
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserService.java
View file @
d4e08770
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.UserInfo
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.UserInfo
;
/**
/**
* Created by Miraculous on 15/7/5.
* Created by Miraculous on 15/7/5.
*/
*/
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
View file @
d4e08770
...
@@ -19,8 +19,7 @@ import org.springframework.stereotype.Service;
...
@@ -19,8 +19,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
org.slf4j.Logger
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.LoggerFactory
;
import
cn.quantgroup.acolyte.buddhistscriptures.pojo.UserRealInfo
;
import
cn.quantgroup.acolyte.buddhistscriptures.pojo.UserRealInfo
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
...
@@ -29,6 +28,7 @@ import cn.quantgroup.xyqb.entity.UserDetail;
...
@@ -29,6 +28,7 @@ import cn.quantgroup.xyqb.entity.UserDetail;
import
cn.quantgroup.xyqb.event.StatisticsEvent
;
import
cn.quantgroup.xyqb.event.StatisticsEvent
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.IdCardInfo
;
import
cn.quantgroup.xyqb.model.IdCardInfo
;
import
cn.quantgroup.xyqb.model.UserInfo
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
...
@@ -39,9 +39,9 @@ import cn.quantgroup.xyqb.util.ValidationUtil;
...
@@ -39,9 +39,9 @@ import cn.quantgroup.xyqb.util.ValidationUtil;
/**
/**
* Created by 11 on 2016/12/29.
* Created by 11 on 2016/12/29.
*/
*/
@Slf4j
@Service
@Service
public
class
UserDetailServiceImpl
implements
IUserDetailService
{
public
class
UserDetailServiceImpl
implements
IUserDetailService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UserDetailServiceImpl
.
class
);
@Autowired
@Autowired
private
IUserDetailRepository
userDetailRepository
;
private
IUserDetailRepository
userDetailRepository
;
@Autowired
@Autowired
...
@@ -128,14 +128,20 @@ public class UserDetailServiceImpl implements IUserDetailService {
...
@@ -128,14 +128,20 @@ public class UserDetailServiceImpl implements IUserDetailService {
private
Specification
<
UserDetail
>
getSpecification
(
String
name
,
String
phoneNo
,
String
idNo
)
{
private
Specification
<
UserDetail
>
getSpecification
(
String
name
,
String
phoneNo
,
String
idNo
)
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
List
<
Predicate
>
list
=
new
ArrayList
<>();
Specification
<
UserDetail
>
specification
=
(
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
Specification
<
UserDetail
>
specification
=
(
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
if
(!
StringUtils
.
isEmpty
(
name
))
{
if
(
ValidationUtil
.
validatePhoneNo
(
phoneNo
)){
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"name"
).
as
(
String
.
class
),
name
));
}
if
(!
StringUtils
.
isEmpty
(
phoneNo
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
Constants
.
PHONE_NO
).
as
(
String
.
class
),
phoneNo
));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
Constants
.
PHONE_NO
).
as
(
String
.
class
),
phoneNo
));
}
else
if
(
StringUtils
.
isNotBlank
(
phoneNo
))
{
list
.
add
(
criteriaBuilder
.
like
(
root
.
get
(
Constants
.
PHONE_NO
).
as
(
String
.
class
),
phoneNo
.
concat
(
"%"
)));
}
}
if
(!
StringUtils
.
isEmpty
(
idNo
))
{
if
(
StringUtils
.
isNotBlank
(
idNo
))
{
if
(
Objects
.
equals
(
Constants
.
IDNO_LENGTH
,
idNo
.
length
())){
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"idNo"
).
as
(
String
.
class
),
idNo
));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"idNo"
).
as
(
String
.
class
),
idNo
));
}
else
{
list
.
add
(
criteriaBuilder
.
like
(
root
.
get
(
"idNo"
).
as
(
String
.
class
),
idNo
.
concat
(
"%"
)));
}
}
if
(
StringUtils
.
isNotBlank
(
name
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"name"
).
as
(
String
.
class
),
name
));
}
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
return
criteriaBuilder
.
and
(
list
.
toArray
(
p
));
return
criteriaBuilder
.
and
(
list
.
toArray
(
p
));
...
@@ -197,7 +203,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
...
@@ -197,7 +203,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
if
(
StringUtils
.
isNotBlank
(
idNo
))
{
if
(
StringUtils
.
isNotBlank
(
idNo
))
{
IdCardInfo
idCardInfo
=
idCardService
.
getIdCardInfo
(
idNo
);
IdCardInfo
idCardInfo
=
idCardService
.
getIdCardInfo
(
idNo
);
if
(
idCardInfo
==
null
||
!
idCardInfo
.
isValid
())
{
if
(
idCardInfo
==
null
||
!
idCardInfo
.
isValid
())
{
LOGGER
.
error
(
"用户的身份证错误,phoneNo:{},idNo:{}"
,
phoneNo
,
idNo
);
log
.
error
(
"用户的身份证错误,phoneNo:{},idNo:{}"
,
phoneNo
,
idNo
);
return
0
;
return
0
;
}
}
return
userDetailRepository
.
updateIdNoByPhoneNo
(
idCardInfo
.
getIdNo
(),
Optional
.
ofNullable
(
idCardInfo
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
ordinal
(),
phoneNo
);
return
userDetailRepository
.
updateIdNoByPhoneNo
(
idCardInfo
.
getIdNo
(),
Optional
.
ofNullable
(
idCardInfo
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
ordinal
(),
phoneNo
);
...
@@ -217,4 +223,13 @@ public class UserDetailServiceImpl implements IUserDetailService {
...
@@ -217,4 +223,13 @@ public class UserDetailServiceImpl implements IUserDetailService {
});
});
return
userDetails
;
return
userDetails
;
}
}
@Override
public
List
<
UserDetail
>
fuzzyQueryByPhoneNoAndIdNo
(
String
phoneNo
,
String
idNo
){
List
<
UserDetail
>
userDetailList
=
userDetailRepository
.
fuzzyQueryByPhoneNoAndIdNo
(
phoneNo
,
idNo
);
log
.
info
(
"List<UserDetail>:{}"
,
userDetailList
);
List
<
UserInfo
>
userInfoList
=
userDetailRepository
.
fuzzyQuery
(
phoneNo
,
idNo
);
log
.
info
(
"List<UserInfo>:{}"
,
userInfoList
);
return
userDetailList
;
}
}
}
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