|
@@ -1,5 +1,7 @@
|
|
|
package com.ruoyi.zzb.controller;
|
|
|
|
|
|
+import com.ruoyi.common.annotation.DataSource;
|
|
|
+import com.ruoyi.common.enums.DataSourceType;
|
|
|
import com.ruoyi.zzb.domain.User;
|
|
|
import com.ruoyi.zzb.mapper.UserMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -15,8 +17,15 @@ public class UserController {
|
|
|
private UserMapper userMapper;
|
|
|
|
|
|
@GetMapping( "/getUserById")
|
|
|
+ @DataSource(value = DataSourceType.MASTER)
|
|
|
public User getUserById(int id){
|
|
|
return userMapper.selectById(id);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping( "/getUserById2")
|
|
|
+ @DataSource(value = DataSourceType.SLAVE)
|
|
|
+ public User getUserById2(int id){
|
|
|
+ return userMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
}
|