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
38797b99
Commit
38797b99
authored
May 05, 2017
by
minminyan
Browse files
Options
Browse Files
Download
Plain Diff
合并master
parents
babf69ae
1c3750ed
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
209 additions
and
21 deletions
+209
-21
MotanUserServiceImpl.java
.../xyqb/controller/external/motan/MotanUserServiceImpl.java
+7
-3
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+6
-0
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+29
-2
WeChatController.java
...group/xyqb/controller/external/user/WeChatController.java
+6
-5
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+15
-5
RequestFilter.java
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
+2
-1
IUserRepository.java
...n/java/cn/quantgroup/xyqb/repository/IUserRepository.java
+2
-1
ISessionService.java
...a/cn/quantgroup/xyqb/service/session/ISessionService.java
+2
-0
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+14
-1
IUserDetailService.java
...a/cn/quantgroup/xyqb/service/user/IUserDetailService.java
+2
-1
LkbUserviceImpl.java
...cn/quantgroup/xyqb/service/user/impl/LkbUserviceImpl.java
+1
-0
UserDetailServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
+32
-2
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+1
-0
UserDetailVO.java
...java/cn/quantgroup/xyqb/service/user/vo/UserDetailVO.java
+90
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/motan/MotanUserServiceImpl.java
View file @
38797b99
...
...
@@ -19,6 +19,7 @@ import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
...
...
@@ -27,7 +28,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.weibo.api.motan.config.springsupport.annotation.MotanService
;
import
java.util.concurrent.ThreadLocalRandom
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -140,6 +140,10 @@ public class MotanUserServiceImpl implements UserMotanService {
return
userDetail
==
null
?
null
:
userDetail
.
toXUserDetail
();
}
private
XUserDetail
fromUserDetailVO
(
UserDetailVO
userDetail
)
{
return
userDetail
==
null
?
null
:
userDetail
.
toXUserDetail
();
}
private
XUser
fromUser
(
User
user
)
{
return
user
==
null
?
null
:
user
.
toXUser
();
}
...
...
@@ -501,11 +505,11 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
public
UserSysResult
<
List
<
XUserDetail
>>
queryUserDetailBySpecification
(
String
name
,
String
phoneNo
,
String
idNo
)
{
List
<
UserDetail
>
userDetails
=
userDetailService
.
searchUserDetailList
(
name
,
phoneNo
,
idNo
);
List
<
UserDetail
VO
>
userDetails
=
userDetailService
.
searchUserDetailList
(
name
,
phoneNo
,
idNo
);
if
(
CollectionUtils
.
isEmpty
(
userDetails
))
{
return
null
;
}
List
<
XUserDetail
>
xUserDetails
=
userDetails
.
stream
().
map
(
user
->
fromUserDetail
(
user
)).
collect
(
Collectors
.
toList
());
List
<
XUserDetail
>
xUserDetails
=
userDetails
.
stream
().
map
(
user
->
fromUserDetail
VO
(
user
)).
collect
(
Collectors
.
toList
());
return
returnSuccessValue
(
xUserDetails
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
38797b99
...
...
@@ -83,6 +83,9 @@ public class AppController implements IBaseController {
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
...
...
@@ -123,6 +126,9 @@ public class AppController implements IBaseController {
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
38797b99
...
...
@@ -4,15 +4,17 @@ import cn.quantgroup.xyqb.entity.*;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -47,6 +49,8 @@ public class InnerController {
private
IWechatService
wechatService
;
@Autowired
private
IUserSpouseService
userSpouseService
;
@Autowired
private
ISessionService
sessionService
;
@RequestMapping
(
"/user/search/phoneNo"
)
public
JsonResult
findByPhoneNo
(
String
phoneNo
)
{
...
...
@@ -101,6 +105,7 @@ public class InnerController {
user
.
setUpdatedAt
(
new
Timestamp
(
updatedAt
));
user
.
setEnable
(
true
);
user
.
setRegisteredFrom
(
registeredFrom
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
password
);
user
=
userService
.
saveUser
(
user
);
UserRet
userRet
=
null
;
...
...
@@ -336,7 +341,10 @@ public class InnerController {
@RequestMapping
(
"/user_detail/search_list"
)
public
JsonResult
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
List
<
UserDetail
>
userDetails
=
userDetailService
.
searchUserDetailList
(
name
,
phoneNo
,
idNo
);
if
(
StringUtils
.
isBlank
(
name
)
&&
StringUtils
.
isBlank
(
phoneNo
)
&&
StringUtils
.
isBlank
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"至少必须满足一个条件不为空"
,
null
);
}
List
<
UserDetailVO
>
userDetails
=
userDetailService
.
searchUserDetailList
(
name
,
phoneNo
,
idNo
);
return
JsonResult
.
buildSuccessResult
(
"success"
,
userDetails
);
}
...
...
@@ -376,6 +384,25 @@ public class InnerController {
return
JsonResult
.
buildSuccessResult
(
null
,
null
==
wechatUserInfo
?
null
:
wechatUserInfo
.
getOpenId
());
}
@RequestMapping
(
"/user/disable"
)
public
JsonResult
disableUser
(
Long
userId
)
{
if
(
null
==
userId
||
0L
==
userId
)
{
return
JsonResult
.
buildErrorStateResult
(
"userId不能为空"
,
null
);
}
User
user
=
userService
.
findById
(
userId
);
if
(
null
==
user
)
{
return
JsonResult
.
buildErrorStateResult
(
"未查询到该用户,用户id:"
+
userId
,
null
);
}
user
.
setEnable
(
false
);
user
.
setUpdatedAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
LOGGER
.
info
(
"注销用户的信息,userId={}"
,
userId
);
user
=
userService
.
saveUser
(
user
);
if
(!
user
.
getEnable
())
{
sessionService
.
deleteByUserId
(
userId
);
}
return
JsonResult
.
buildSuccessResult
(
"用户已禁用."
,
user
.
getEnable
()
==
false
);
}
@RequestMapping
(
"/user/spouse/save"
)
public
JsonResult
saveSpouse
(
Long
userId
,
MaritalStatus
status
,
String
spousePhone
,
String
spouseName
)
{
if
(
userId
==
null
||
userId
==
0
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/WeChatController.java
View file @
38797b99
...
...
@@ -319,11 +319,8 @@ public class WeChatController implements IBaseController {
LOGGER
.
error
(
"发生异常"
,
ex
);
throw
ex
;
}
}
/**
* 通过redirect_url获取code
*
...
...
@@ -382,7 +379,7 @@ public class WeChatController implements IBaseController {
private
String
createUserSession
(
User
user
,
Merchant
merchant
,
String
redirect
,
String
schema
,
Long
registerFrom
)
{
//TODO 临时紧急上线修改的.下次上线的时候修复一下,不能这样写.
String
url
=
"http://passport.xyqb.com"
;
if
(
"https"
.
equals
(
schema
))
{
if
(
"https
:
"
.
equals
(
schema
))
{
url
=
"https://passport.xyqb.com"
;
}
if
(
StringUtils
.
isEmpty
(
redirect
)
||
"redirect"
.
equals
(
redirect
))
{
...
...
@@ -399,11 +396,15 @@ public class WeChatController implements IBaseController {
LOGGER
.
info
(
"微信登录:redirect不为null,创建session跳到指定前端页面."
);
AuthBean
authBean
=
sessionService
.
createSession
(
Constants
.
Channel
.
WECHAT
,
Constants
.
Channel
.
WECHAT
,
""
,
user
,
merchant
);
LOGGER
.
info
(
"微信登录:跳转地址{}"
,
url
+
"/weixin/callback?phoneNo="
+
user
.
getPhoneNo
()
+
"&token="
+
authBean
.
getToken
());
return
url
+
"/weixin/callback?phoneNo="
+
user
.
getPhoneNo
()
+
"&token="
+
authBean
.
getToken
();
Long
channelId
=
"baitiao"
.
equals
(
merchant
.
getName
())
?
222L
:
1L
;
String
target
=
"baitiao"
.
equals
(
merchant
.
getName
())
?
"cashTarget5"
:
"cashTarget4"
;
return
url
+
"/landing?token="
+
authBean
.
getToken
()
+
"®isterFrom="
+
registerFrom
+
"&channelId="
+
channelId
+
"&key="
+
merchant
.
getName
()
+
"&target="
+
target
+
"&isWechat=true"
;
}
return
null
;
}
private
String
loginInWechatWithSessionCreated
(
User
user
,
Merchant
merchant
,
String
target
,
Long
channelId
,
String
url
,
Long
registerFrom
)
{
AuthBean
authBean
=
sessionService
.
createSession
(
channelId
,
registerFrom
,
""
,
user
,
merchant
);
return
url
+
"/landing?token="
+
authBean
.
getToken
()
+
"®isterFrom="
+
registerFrom
+
"&channelId="
+
channelId
+
"&key="
+
merchant
.
getName
()
+
"&target="
+
target
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
38797b99
...
...
@@ -43,19 +43,22 @@ public class UserController implements IBaseController {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UserController
.
class
);
private
static
final
char
[]
PWD_BASE
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
};
private
final
String
pwdSalt
=
"_lkb"
;
@Autowired
private
IUserService
userService
;
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Autowired
private
ISmsService
smsService
;
@Autowired
private
ISessionService
sessionService
;
@Autowired
private
IUserDetailService
userDetailService
;
@Autowired
...
...
@@ -63,6 +66,10 @@ public class UserController implements IBaseController {
@Autowired
private
IWechatService
wechatService
;
private
static
final
char
[]
PWD_BASE
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
};
@RequestMapping
(
"/login"
)
public
JsonResult
login
(
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
String
appChannel
,
...
...
@@ -99,6 +106,9 @@ public class UserController implements IBaseController {
JsonResult
successResult
=
validMap
.
get
(
"success"
);
String
phoneNo
=
successResult
.
getData
().
toString
();
User
user
=
userService
.
findByPhoneWithCache
(
phoneNo
);
if
(
user
!=
null
&&
!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
if
(
user
==
null
)
{
user
=
registerFastWhenLogin
(
phoneNo
,
channelId
,
createdFrom
,
appChannel
);
if
(
user
==
null
)
{
...
...
@@ -396,7 +406,7 @@ public class UserController implements IBaseController {
String
userName
=
credentialArr
[
0
];
String
pass
=
credentialArr
[
1
];
User
user
=
userService
.
findByPhoneWithCache
(
userName
);
if
(
user
==
null
)
{
if
(
user
==
null
||
!
user
.
getEnable
()
)
{
return
null
;
}
//验证密码
...
...
@@ -414,7 +424,7 @@ public class UserController implements IBaseController {
//查询用户,存在则保存用户session信息,userId为uuid
User
user
=
userService
.
findByUuidInDb
(
userId
);
//用户信息存在,更新session中的最后访问时间,重新写入缓存.
if
(
null
!=
user
)
{
if
(
null
!=
user
||
!
user
.
getEnable
()
)
{
return
new
JsonResult
(
sessionService
.
createSession
(
channelId
,
createdFrom
,
appChannel
,
user
,
merchant
));
}
else
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
View file @
38797b99
...
...
@@ -29,7 +29,8 @@ public class RequestFilter implements Filter {
"/innerapi/**"
,
"/user/exist"
,
"/motan/**"
,
"/user/register"
,
"/user/login"
,
"/user/register/fast"
,
"/user/login/fast"
,
"/user/reset_password"
,
"/user/exist_check"
,
"/jr58/**"
,
"/app/login"
,
"/app/login_super"
,
"/wechat/**"
,
"/config/**"
,
"/api/**"
,
"/user/exists_token"
,
"/platform/api/page/return_url"
,
"/MP_verify_AWiagUn4kZiwmTt0.txt"
"/platform/api/page/return_url"
,
"/MP_"
+
"verify_AWiagUn4kZiwmTt0.txt"
};
private
static
final
String
UNAUTH_RESULT
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
));
@Autowired
...
...
src/main/java/cn/quantgroup/xyqb/repository/IUserRepository.java
View file @
38797b99
...
...
@@ -2,11 +2,12 @@ package cn.quantgroup.xyqb.repository;
import
cn.quantgroup.xyqb.entity.User
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
* Created by Miraculous on 15/7/4.
*/
public
interface
IUserRepository
extends
JpaRepository
<
User
,
Long
>
{
public
interface
IUserRepository
extends
JpaRepository
<
User
,
Long
>
,
JpaSpecificationExecutor
<
User
>
{
User
findByPhoneNo
(
String
phoneNo
);
...
...
src/main/java/cn/quantgroup/xyqb/service/session/ISessionService.java
View file @
38797b99
...
...
@@ -26,4 +26,6 @@ public interface ISessionService {
void
persistSession
(
String
token
,
SessionValue
sessionValue
);
SessionStruct
findSessionBySessionId
(
String
sessionId
);
void
deleteByUserId
(
long
userId
);
}
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
38797b99
...
...
@@ -9,16 +9,19 @@ import cn.quantgroup.xyqb.model.session.SessionStruct;
import
cn.quantgroup.xyqb.model.session.SessionValue
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.base.Joiner
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.sql.Timestamp
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -149,5 +152,15 @@ public class SessionServiceImpl implements ISessionService {
}
@Override
public
void
deleteByUserId
(
long
userId
)
{
String
pattern
=
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":*"
;
Set
<
String
>
keys
=
stringRedisTemplate
.
keys
(
pattern
);
if
(!
CollectionUtils
.
isEmpty
(
keys
))
{
log
.
info
(
"删除用户userId={}的缓存信息,个数:{},keys={}"
,
userId
,
keys
.
size
(),
Joiner
.
on
(
","
).
join
(
keys
));
}
stringRedisTemplate
.
delete
(
keys
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserDetailService.java
View file @
38797b99
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
java.util.List
;
...
...
@@ -17,5 +18,5 @@ public interface IUserDetailService {
void
updateUserQQ
(
Long
userId
,
String
qq
);
List
<
UserDetail
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
);
List
<
UserDetail
VO
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/LkbUserviceImpl.java
View file @
38797b99
...
...
@@ -65,6 +65,7 @@ public class LkbUserviceImpl implements ILkbUserService {
LOGGER
.
warn
(
"向LKB注册用户失败, phoneNo:{}, password:{}"
,
phoneNo
,
password
);
return
""
;
}
//String uid = java.util.UUID.randomUUID().toString().replace("-","");
return
result
.
get
(
"uid"
);
}
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
View file @
38797b99
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
com.google.common.collect.Maps
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
...
...
@@ -15,6 +20,8 @@ import javax.persistence.criteria.Predicate;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by 11 on 2016/12/29.
...
...
@@ -24,6 +31,8 @@ public class UserDetailServiceImpl implements IUserDetailService {
@Autowired
private
IUserDetailRepository
userDetailRepository
;
@Autowired
private
IUserRepository
userRepository
;
@Override
public
UserDetail
findByUserId
(
Long
userId
)
{
...
...
@@ -46,8 +55,20 @@ public class UserDetailServiceImpl implements IUserDetailService {
}
@Override
public
List
<
UserDetail
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
return
userDetailRepository
.
findAll
(
getSpecification
(
name
,
phoneNo
,
idNo
));
public
List
<
UserDetailVO
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
List
<
UserDetail
>
details
=
userDetailRepository
.
findAll
(
getSpecification
(
name
,
phoneNo
,
idNo
));
Map
<
Long
,
User
>
userMap
=
Maps
.
newHashMap
();
if
(!
CollectionUtils
.
isEmpty
(
details
))
{
List
<
Long
>
userIds
=
details
.
stream
().
map
(
d
->
d
.
getUserId
()).
collect
(
Collectors
.
toList
());
List
<
User
>
users
=
userRepository
.
findAll
((
root
,
query
,
cb
)
->
{
query
.
where
(
root
.
get
(
"id"
).
in
(
userIds
));
return
query
.
getRestriction
();
});
userMap
=
users
.
stream
().
collect
(
Collectors
.
toMap
(
User:
:
getId
,
o
->
o
));
}
Map
<
Long
,
User
>
finalUserMap
=
userMap
;
List
<
UserDetailVO
>
userDetailVOS
=
details
.
stream
().
map
(
o
->
fromUserDetailAndUserMap
(
o
,
finalUserMap
)).
collect
(
Collectors
.
toList
());
return
userDetailVOS
;
}
private
Specification
<
UserDetail
>
getSpecification
(
String
name
,
String
phoneNo
,
String
idNo
)
{
...
...
@@ -70,4 +91,13 @@ public class UserDetailServiceImpl implements IUserDetailService {
};
return
specification
;
}
private
UserDetailVO
fromUserDetailAndUserMap
(
UserDetail
userDetail
,
Map
<
Long
,
User
>
userMap
)
{
UserDetailVO
userDetailVO
=
UserDetailVO
.
fromUserDetail
(
userDetail
);
User
user
=
userMap
.
get
(
userDetail
.
getUserId
());
if
(
user
!=
null
)
{
userDetailVO
.
setEnable
(
user
.
getEnable
());
}
return
userDetailVO
;
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
38797b99
...
...
@@ -47,6 +47,7 @@ public class UserServiceImpl implements IUserService {
}
@Override
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #user.phoneNo"
,
cacheManager
=
"cacheManager"
)
public
User
saveUser
(
User
user
)
{
return
userRepository
.
save
(
user
);
}
...
...
src/main/java/cn/quantgroup/xyqb/service/user/vo/UserDetailVO.java
0 → 100644
View file @
38797b99
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
vo
;
import
cn.quantgroup.motan.retbean.XUserDetail
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.IdType
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.sql.Timestamp
;
@Data
@NoArgsConstructor
public
class
UserDetailVO
{
private
Long
id
;
private
Long
userId
;
private
String
phoneNo
;
private
String
name
;
private
String
idNo
;
private
IdType
idType
;
private
Boolean
isAuthenticated
=
false
;
private
Gender
gender
;
private
String
email
;
private
String
qq
;
private
Boolean
enable
;
private
Long
createdAt
;
private
Long
updatedAt
;
public
static
UserDetailVO
fromUserDetail
(
UserDetail
userDetail
)
{
UserDetailVO
userDetailVO
=
new
UserDetailVO
();
userDetailVO
.
id
=
userDetail
.
getId
();
userDetailVO
.
userId
=
userDetail
.
getUserId
();
userDetailVO
.
phoneNo
=
userDetail
.
getPhoneNo
();
userDetailVO
.
name
=
userDetail
.
getName
();
userDetailVO
.
idNo
=
userDetail
.
getIdNo
();
userDetailVO
.
idType
=
userDetail
.
getIdType
();
userDetailVO
.
isAuthenticated
=
userDetail
.
getIsAuthenticated
();
userDetailVO
.
gender
=
userDetail
.
getGender
();
userDetailVO
.
email
=
userDetail
.
getEmail
();
userDetailVO
.
qq
=
userDetail
.
getQq
();
if
(
userDetail
.
getCreatedAt
()
!=
null
)
{
userDetailVO
.
createdAt
=
userDetail
.
getCreatedAt
().
getTime
();
}
if
(
userDetail
.
getUpdatedAt
()
!=
null
)
{
userDetailVO
.
updatedAt
=
userDetail
.
getUpdatedAt
().
getTime
();
}
return
userDetailVO
;
}
public
XUserDetail
toXUserDetail
()
{
XUserDetail
xUserDetail
=
new
XUserDetail
();
xUserDetail
.
setId
(
this
.
getId
());
xUserDetail
.
setUserId
(
this
.
getUserId
());
xUserDetail
.
setPhoneNo
(
this
.
getPhoneNo
());
xUserDetail
.
setName
(
this
.
getName
());
xUserDetail
.
setIdNo
(
this
.
getIdNo
());
if
(
this
.
getIdType
()
!=
null
)
{
xUserDetail
.
setIdType
(
cn
.
quantgroup
.
motan
.
enums
.
IdType
.
valueOf
(
this
.
getIdType
().
name
()));
}
if
(
this
.
getGender
()
!=
null
)
{
xUserDetail
.
setGender
(
cn
.
quantgroup
.
motan
.
enums
.
Gender
.
valueOf
(
this
.
getGender
().
name
()));
}
xUserDetail
.
setEmail
(
this
.
getEmail
());
xUserDetail
.
setQq
(
this
.
getQq
());
xUserDetail
.
setId
(
this
.
getId
());
if
(
this
.
getCreatedAt
()
!=
null
)
{
xUserDetail
.
setCreatedAt
(
new
Timestamp
(
this
.
getCreatedAt
()));
}
if
(
this
.
getUpdatedAt
()
!=
null
)
{
xUserDetail
.
setUpdatedAt
(
new
Timestamp
(
this
.
getUpdatedAt
()));
}
xUserDetail
.
setIsAuthenticated
(
this
.
getIsAuthenticated
());
xUserDetail
.
setEnable
(
this
.
getEnable
());
return
xUserDetail
;
}
}
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