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
dcdb7bc5
Commit
dcdb7bc5
authored
May 08, 2021
by
于桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主从库分离时,不能在同一线程内切换,写操作出错
parent
a935c82e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
IUserService.java
...in/java/cn/quantgroup/xyqb/service/user/IUserService.java
+2
-0
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+7
-1
No files found.
src/main/java/cn/quantgroup/xyqb/service/user/IUserService.java
View file @
dcdb7bc5
...
...
@@ -25,6 +25,8 @@ public interface IUserService {
User
findByPhoneInDb
(
String
phone
);
User
findSlaveByPhoneInDb
(
String
phone
);
User
findByUuidInDb
(
String
uuid
);
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
dcdb7bc5
...
...
@@ -96,12 +96,18 @@ public class UserServiceImpl implements IUserService, IBaseController {
private
ILockIpv4Service
lockIpv4Service
;
@Override
@TargetDataSource
(
type
=
DSType
.
SLAVE
)
//查询从库
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public
User
findByPhoneInDb
(
String
phone
)
{
return
userRepository
.
findByPhoneNo
(
phone
);
}
@Override
@TargetDataSource
(
type
=
DSType
.
SLAVE
)
//查询从库
// @Cacheable(value = "usercache", key = "'xyqbuser' + #phone", unless = "#result == null", cacheManager = "cacheManager")
public
User
findSlaveByPhoneInDb
(
String
phone
)
{
return
userRepository
.
findByPhoneNo
(
phone
);
}
@Override
@TargetDataSource
(
type
=
DSType
.
SLAVE
)
//查询从库
public
Map
<
Long
,
String
>
findPhoneByIdsInDb
(
List
<
Long
>
userIds
)
{
...
...
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