Commit dcdb7bc5 authored by 于桐's avatar 于桐

主从库分离时,不能在同一线程内切换,写操作出错

parent a935c82e
......@@ -25,6 +25,8 @@ public interface IUserService {
User findByPhoneInDb(String phone);
User findSlaveByPhoneInDb(String phone);
User findByUuidInDb(String uuid);
/**
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment