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
d3956a85
Commit
d3956a85
authored
Apr 24, 2017
by
minminyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
禁用用户的同时删除相应的缓存
parent
8aa4d2be
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
975 additions
and
947 deletions
+975
-947
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+312
-302
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+416
-413
ISessionService.java
...a/cn/quantgroup/xyqb/service/session/ISessionService.java
+11
-8
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+121
-111
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+115
-113
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
d3956a85
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
d3956a85
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/service/session/ISessionService.java
View file @
d3956a85
...
@@ -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 @
d3956a85
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
d3956a85
...
@@ -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
());
}
}
}
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