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
ef595f7e
Commit
ef595f7e
authored
May 03, 2017
by
minminyan
Browse files
Options
Browse Files
Download
Plain Diff
合并代码
parents
8f6896b9
4c3b3444
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
840 additions
and
695 deletions
+840
-695
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+6
-0
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+29
-3
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+416
-413
IUserRepository.java
...n/java/cn/quantgroup/xyqb/repository/IUserRepository.java
+2
-1
ISessionService.java
...a/cn/quantgroup/xyqb/service/session/ISessionService.java
+11
-8
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+121
-111
IUserDetailService.java
...a/cn/quantgroup/xyqb/service/user/IUserDetailService.java
+6
-5
UserDetailServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
+75
-41
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+115
-113
UserDetailVO.java
...java/cn/quantgroup/xyqb/service/user/vo/UserDetailVO.java
+59
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
ef595f7e
...
@@ -86,6 +86,9 @@ public class AppController implements IBaseController {
...
@@ -86,6 +86,9 @@ public class AppController implements IBaseController {
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
if
(
merchant
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
...
@@ -126,6 +129,9 @@ public class AppController implements IBaseController {
...
@@ -126,6 +129,9 @@ public class AppController implements IBaseController {
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
if
(
merchant
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
ef595f7e
...
@@ -4,15 +4,17 @@ import cn.quantgroup.xyqb.entity.*;
...
@@ -4,15 +4,17 @@ import cn.quantgroup.xyqb.entity.*;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
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.*
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -47,7 +49,8 @@ public class InnerController {
...
@@ -47,7 +49,8 @@ public class InnerController {
private
IWechatService
wechatService
;
private
IWechatService
wechatService
;
@Autowired
@Autowired
private
IUserSpouseService
userSpouseService
;
private
IUserSpouseService
userSpouseService
;
@Autowired
private
ISessionService
sessionService
;
@RequestMapping
(
"/user/search/phoneNo"
)
@RequestMapping
(
"/user/search/phoneNo"
)
public
JsonResult
findByPhoneNo
(
String
phoneNo
)
{
public
JsonResult
findByPhoneNo
(
String
phoneNo
)
{
...
@@ -102,6 +105,7 @@ public class InnerController {
...
@@ -102,6 +105,7 @@ public class InnerController {
user
.
setUpdatedAt
(
new
Timestamp
(
updatedAt
));
user
.
setUpdatedAt
(
new
Timestamp
(
updatedAt
));
user
.
setEnable
(
true
);
user
.
setEnable
(
true
);
user
.
setRegisteredFrom
(
registeredFrom
);
user
.
setRegisteredFrom
(
registeredFrom
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
password
);
user
.
setPassword
(
password
);
user
=
userService
.
saveUser
(
user
);
user
=
userService
.
saveUser
(
user
);
UserRet
userRet
=
null
;
UserRet
userRet
=
null
;
...
@@ -333,7 +337,10 @@ public class InnerController {
...
@@ -333,7 +337,10 @@ public class InnerController {
@RequestMapping
(
"/user_detail/search_list"
)
@RequestMapping
(
"/user_detail/search_list"
)
public
JsonResult
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
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
);
return
JsonResult
.
buildSuccessResult
(
"success"
,
userDetails
);
}
}
...
@@ -373,6 +380,25 @@ public class InnerController {
...
@@ -373,6 +380,25 @@ public class InnerController {
return
JsonResult
.
buildSuccessResult
(
null
,
null
==
wechatUserInfo
?
null
:
wechatUserInfo
.
getOpenId
());
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"
)
@RequestMapping
(
"/user/spouse/save"
)
public
JsonResult
saveSpouse
(
Long
userId
,
MaritalStatus
status
,
String
spousePhone
,
String
spouseName
)
{
public
JsonResult
saveSpouse
(
Long
userId
,
MaritalStatus
status
,
String
spousePhone
,
String
spouseName
)
{
if
(
userId
==
null
||
userId
==
0
)
{
if
(
userId
==
null
||
userId
==
0
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
ef595f7e
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/repository/IUserRepository.java
View file @
ef595f7e
...
@@ -2,11 +2,12 @@ package cn.quantgroup.xyqb.repository;
...
@@ -2,11 +2,12 @@ package cn.quantgroup.xyqb.repository;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
/**
* Created by Miraculous on 15/7/4.
* 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
);
User
findByPhoneNo
(
String
phoneNo
);
...
...
src/main/java/cn/quantgroup/xyqb/service/session/ISessionService.java
View file @
ef595f7e
...
@@ -2,7 +2,6 @@ package cn.quantgroup.xyqb.service.session;
...
@@ -2,7 +2,6 @@ package cn.quantgroup.xyqb.service.session;
import
cn.quantgroup.xyqb.entity.Merchant
;
import
cn.quantgroup.xyqb.entity.Merchant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.function.OneArgFunction
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.LoginProperties
;
import
cn.quantgroup.xyqb.model.LoginProperties
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
...
@@ -14,15 +13,19 @@ import cn.quantgroup.xyqb.model.session.SessionValue;
...
@@ -14,15 +13,19 @@ import cn.quantgroup.xyqb.model.session.SessionValue;
public
interface
ISessionService
{
public
interface
ISessionService
{
AuthBean
createSession
(
Long
channelId
,
Long
createdFrom
,
String
appChannel
,
User
user
,
Merchant
merchant
);
AuthBean
createSession
(
Long
channelId
,
Long
createdFrom
,
String
appChannel
,
User
user
,
Merchant
merchant
);
SessionStruct
createSessionAndPersist
(
User
user
,
LoginProperties
loginProperties
);
SessionStruct
createSessionAndPersist
(
User
user
,
LoginProperties
loginProperties
);
String
findSessionIdByUserIdLoginProperties
(
Long
userId
,
LoginProperties
properties
);
String
findSessionIdByUserIdLoginProperties
(
Long
userId
,
LoginProperties
properties
);
String
findSessionValueBySessionId
(
String
sessionId
);
String
findSessionValueBySessionId
(
String
sessionId
);
SessionStruct
newSession
(
User
user
,
LoginProperties
properties
);
void
persistSession
(
String
token
,
SessionValue
sessionValue
);
SessionStruct
findSessionBySessionId
(
String
sessionId
);
SessionStruct
newSession
(
User
user
,
LoginProperties
properties
);
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 @
ef595f7e
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/service/user/IUserDetailService.java
View file @
ef595f7e
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
java.util.List
;
import
java.util.List
;
...
@@ -9,13 +10,13 @@ import java.util.List;
...
@@ -9,13 +10,13 @@ import java.util.List;
* Created by 11 on 2016/12/29.
* Created by 11 on 2016/12/29.
*/
*/
public
interface
IUserDetailService
{
public
interface
IUserDetailService
{
UserDetail
findByUserId
(
Long
userId
);
UserDetail
findByUserId
(
Long
userId
);
UserDetail
saveUserDetail
(
UserDetail
userDetail
)
throws
DataIntegrityViolationException
;
UserDetail
saveUserDetail
(
UserDetail
userDetail
)
throws
DataIntegrityViolationException
;
UserDetail
findByPhoneNo
(
String
phoneNo
);
UserDetail
findByPhoneNo
(
String
phoneNo
);
void
updateUserQQ
(
Long
userId
,
String
qq
);
void
updateUserQQ
(
Long
userId
,
String
qq
);
List
<
UserDetail
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
);
List
<
UserDetailVO
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
View file @
ef595f7e
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
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.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
com.google.common.collect.Maps
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.persistence.criteria.*
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* Created by 11 on 2016/12/29.
* Created by 11 on 2016/12/29.
...
@@ -19,52 +29,76 @@ import java.util.List;
...
@@ -19,52 +29,76 @@ import java.util.List;
@Service
@Service
public
class
UserDetailServiceImpl
implements
IUserDetailService
{
public
class
UserDetailServiceImpl
implements
IUserDetailService
{
@Autowired
@Autowired
private
IUserDetailRepository
userDetailRepository
;
private
IUserDetailRepository
userDetailRepository
;
@Autowired
private
IUserRepository
userRepository
;
@Override
@Override
public
UserDetail
findByUserId
(
Long
userId
)
{
public
UserDetail
findByUserId
(
Long
userId
)
{
return
userDetailRepository
.
findByUserId
(
userId
);
return
userDetailRepository
.
findByUserId
(
userId
);
}
}
@Override
@Override
public
UserDetail
saveUserDetail
(
UserDetail
userDetail
)
throws
DataIntegrityViolationException
{
public
UserDetail
saveUserDetail
(
UserDetail
userDetail
)
throws
DataIntegrityViolationException
{
return
userDetailRepository
.
save
(
userDetail
);
return
userDetailRepository
.
save
(
userDetail
);
}
}
@Override
@Override
public
UserDetail
findByPhoneNo
(
String
phoneNo
)
{
public
UserDetail
findByPhoneNo
(
String
phoneNo
)
{
return
userDetailRepository
.
findByPhoneNo
(
phoneNo
);
return
userDetailRepository
.
findByPhoneNo
(
phoneNo
);
}
}
@Override
@Override
public
void
updateUserQQ
(
Long
userId
,
String
qq
)
{
public
void
updateUserQQ
(
Long
userId
,
String
qq
)
{
userDetailRepository
.
updateUserQQ
(
qq
,
userId
);
userDetailRepository
.
updateUserQQ
(
qq
,
userId
);
}
}
@Override
@Override
public
List
<
UserDetail
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
public
List
<
UserDetailVO
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
)
{
return
userDetailRepository
.
findAll
(
getSpecification
(
name
,
phoneNo
,
idNo
));
// return
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
)
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
Specification
<
UserDetail
>
specification
=
new
Specification
<
UserDetail
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
UserDetail
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
criteriaBuilder
)
{
if
(!
StringUtils
.
isEmpty
(
name
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"name"
).
as
(
String
.
class
),
name
));
}
if
(!
StringUtils
.
isEmpty
(
phoneNo
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"phoneNo"
).
as
(
String
.
class
),
phoneNo
));
}
if
(!
StringUtils
.
isEmpty
(
idNo
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"idNo"
).
as
(
String
.
class
),
idNo
));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
return
criteriaBuilder
.
and
(
list
.
toArray
(
p
));
}
};
return
specification
;
}
private
Specification
<
UserDetail
>
getSpecification
(
String
name
,
String
phoneNo
,
String
idNo
)
{
private
UserDetailVO
fromUserDetailAndUserMap
(
UserDetail
userDetail
,
Map
<
Long
,
User
>
userMap
)
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
UserDetailVO
userDetailVO
=
UserDetailVO
.
fromUserDetail
(
userDetail
);
Specification
<
UserDetail
>
specification
=
new
Specification
<
UserDetail
>()
{
User
user
=
userMap
.
get
(
userDetail
.
getUserId
());
@Override
if
(
user
!=
null
)
{
public
Predicate
toPredicate
(
Root
<
UserDetail
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
criteriaBuilder
)
{
userDetailVO
.
setEnable
(
user
.
getEnable
());
if
(!
StringUtils
.
isEmpty
(
name
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"name"
).
as
(
String
.
class
),
name
));
}
if
(!
StringUtils
.
isEmpty
(
phoneNo
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"phoneNo"
).
as
(
String
.
class
),
phoneNo
));
}
if
(!
StringUtils
.
isEmpty
(
idNo
))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"idNo"
).
as
(
String
.
class
),
idNo
));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
return
criteriaBuilder
.
and
(
list
.
toArray
(
p
));
}
};
return
specification
;
}
}
return
userDetailVO
;
}
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
ef595f7e
...
@@ -24,120 +24,122 @@ import java.util.concurrent.TimeUnit;
...
@@ -24,120 +24,122 @@ import java.util.concurrent.TimeUnit;
@Service
@Service
public
class
UserServiceImpl
implements
IUserService
{
public
class
UserServiceImpl
implements
IUserService
{
@Autowired
@Autowired
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Autowired
@Autowired
private
ILkbUserService
lkbUserService
;
private
ILkbUserService
lkbUserService
;
@Autowired
@Autowired
private
IUserRepository
userRepository
;
private
IUserRepository
userRepository
;
@Autowired
@Autowired
private
ISmsService
smsService
;
private
ISmsService
smsService
;
@Override
@Override
public
User
findByPhoneInDb
(
String
phone
)
{
public
User
findByPhoneInDb
(
String
phone
)
{
return
userRepository
.
findByPhoneNo
(
phone
);
return
userRepository
.
findByPhoneNo
(
phone
);
}
@Override
public
User
findByUuidInDb
(
String
uuid
)
{
return
userRepository
.
findByUuid
(
uuid
);
}
@Override
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #user.phoneNo"
,
cacheManager
=
"cacheManager"
)
public
User
saveUser
(
User
user
)
{
return
userRepository
.
save
(
user
);
}
@Override
public
User
findById
(
Long
userId
)
{
return
userRepository
.
findById
(
userId
);
}
@Override
public
User
registerAndReturn
(
String
phoneNo
,
String
password
,
Long
registerFrom
)
{
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
password
);
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
User
user
=
new
User
();
user
.
setEnable
(
true
);
user
.
setPhoneNo
(
phoneNo
);
user
.
setUpdatedAt
(
currentTime
);
user
.
setCreatedAt
(
currentTime
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
user
.
setRegisteredFrom
(
registerFrom
);
return
userRepository
.
save
(
user
);
}
@Override
@Cacheable
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #phone"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
User
findByPhoneWithCache
(
String
phone
)
{
return
userRepository
.
findByPhoneNo
(
phone
);
}
@Override
@Cacheable
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #uuid"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
User
findByUuidWithCache
(
String
uuid
)
{
return
userRepository
.
findByUuid
(
uuid
);
}
@Override
@Transactional
(
value
=
Transactional
.
TxType
.
REQUIRED
)
public
boolean
register
(
String
phoneNo
,
String
password
,
Long
registerFrom
,
String
userIp
,
Long
channelId
)
{
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
password
);
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
User
user
=
new
User
();
user
.
setEnable
(
true
);
user
.
setPhoneNo
(
phoneNo
);
user
.
setUpdatedAt
(
currentTime
);
user
.
setCreatedAt
(
currentTime
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
//解决线上白条registerFrom为1的问题
if
(
channelId
==
222L
)
{
user
.
setRegisteredFrom
(
channelId
);
}
else
{
user
.
setRegisteredFrom
(
registerFrom
);
}
}
//user.setRegisteredFrom(registerFrom);
@Override
public
User
findByUuidInDb
(
String
uuid
)
{
user
=
userRepository
.
save
(
user
);
return
userRepository
.
findByUuid
(
uuid
);
smsService
.
sendAfterRegister
(
phoneNo
);
}
return
user
!=
null
;
}
@Override
public
User
saveUser
(
User
user
)
{
@Override
return
userRepository
.
save
(
user
);
public
boolean
exist
(
String
phoneNo
)
{
return
userRepository
.
findByPhoneNo
(
phoneNo
)
!=
null
;
}
/**
* 修改用户密码
*
* @param phoneNo
* @param password
* @return
* @date 2017-02-15 修改用户修改密码时,更新updatedAt时间
*/
@Override
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #phone"
,
cacheManager
=
"cacheManager"
)
public
boolean
resetPassword
(
String
phoneNo
,
String
password
)
{
User
user
=
userRepository
.
findByPhoneNo
(
phoneNo
);
if
(
user
==
null
)
{
throw
new
RuntimeException
(
"用户["
+
phoneNo
+
"]不存在"
);
}
}
user
.
setUpdatedAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
user
=
userRepository
.
save
(
user
);
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
return
StringUtils
.
equals
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
),
user
.
getPassword
());
@Override
}
public
User
findById
(
Long
userId
)
{
return
userRepository
.
findById
(
userId
);
}
@Override
public
User
registerAndReturn
(
String
phoneNo
,
String
password
,
Long
registerFrom
)
{
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
password
);
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
User
user
=
new
User
();
user
.
setEnable
(
true
);
user
.
setPhoneNo
(
phoneNo
);
user
.
setUpdatedAt
(
currentTime
);
user
.
setCreatedAt
(
currentTime
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
user
.
setRegisteredFrom
(
registerFrom
);
return
userRepository
.
save
(
user
);
}
@Override
@Cacheable
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #phone"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
User
findByPhoneWithCache
(
String
phone
)
{
return
userRepository
.
findByPhoneNo
(
phone
);
}
@Override
@Cacheable
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #uuid"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
User
findByUuidWithCache
(
String
uuid
)
{
return
userRepository
.
findByUuid
(
uuid
);
}
@Override
@Transactional
(
value
=
Transactional
.
TxType
.
REQUIRED
)
public
boolean
register
(
String
phoneNo
,
String
password
,
Long
registerFrom
,
String
userIp
,
Long
channelId
)
{
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
password
);
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
User
user
=
new
User
();
user
.
setEnable
(
true
);
user
.
setPhoneNo
(
phoneNo
);
user
.
setUpdatedAt
(
currentTime
);
user
.
setCreatedAt
(
currentTime
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
//解决线上白条registerFrom为1的问题
if
(
channelId
==
222L
)
{
user
.
setRegisteredFrom
(
channelId
);
}
else
{
user
.
setRegisteredFrom
(
registerFrom
);
}
//user.setRegisteredFrom(registerFrom);
user
=
userRepository
.
save
(
user
);
smsService
.
sendAfterRegister
(
phoneNo
);
return
user
!=
null
;
}
@Override
public
boolean
exist
(
String
phoneNo
)
{
return
userRepository
.
findByPhoneNo
(
phoneNo
)
!=
null
;
}
/**
* 修改用户密码
* @date 2017-02-15 修改用户修改密码时,更新updatedAt时间
* @param phoneNo
* @param password
* @return
*/
@Override
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #phone"
,
cacheManager
=
"cacheManager"
)
public
boolean
resetPassword
(
String
phoneNo
,
String
password
)
{
User
user
=
userRepository
.
findByPhoneNo
(
phoneNo
);
if
(
user
==
null
)
{
throw
new
RuntimeException
(
"用户["
+
phoneNo
+
"]不存在"
);
}
user
.
setUpdatedAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
user
.
setPassword
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
user
=
userRepository
.
save
(
user
);
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
return
StringUtils
.
equals
(
PasswordUtil
.
MD5
(
password
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
),
user
.
getPassword
());
}
}
}
src/main/java/cn/quantgroup/xyqb/service/user/vo/UserDetailVO.java
0 → 100644
View file @
ef595f7e
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
vo
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.IdType
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@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
;
}
}
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