mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
sso service api
This commit is contained in:
parent
d2bc1d5193
commit
dc2b493748
@ -6,8 +6,6 @@ import org.dromara.system.api.domain.bo.RemoteUserBo;
|
|||||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||||
import org.dromara.system.api.model.LoginUser;
|
import org.dromara.system.api.model.LoginUser;
|
||||||
import org.dromara.system.api.model.XcxLoginUser;
|
import org.dromara.system.api.model.XcxLoginUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -16,7 +14,6 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@FeignClient(name = "user-service", url = "http://localhost:8081")
|
|
||||||
public interface RemoteUserService {
|
public interface RemoteUserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,8 +23,7 @@ public interface RemoteUserService {
|
|||||||
* @param tenantId 租户id
|
* @param tenantId 租户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getUserInfoByUsernameTenantId")
|
LoginUser getUserInfo(String username, String tenantId) throws UserException;
|
||||||
LoginUser getUserInfoByUsernameTenantId(@RequestParam("username") String username, @RequestParam("tenantId") String tenantId) throws UserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户id查询用户信息
|
* 通过用户id查询用户信息
|
||||||
@ -36,8 +32,7 @@ public interface RemoteUserService {
|
|||||||
* @param tenantId 租户id
|
* @param tenantId 租户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getUserInfo")
|
LoginUser getUserInfo(Long userId, String tenantId) throws UserException;
|
||||||
LoginUser getUserInfo(@RequestParam("userId") Long userId, @RequestParam("tenantId") String tenantId) throws UserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过手机号查询用户信息
|
* 通过手机号查询用户信息
|
||||||
@ -46,8 +41,7 @@ public interface RemoteUserService {
|
|||||||
* @param tenantId 租户id
|
* @param tenantId 租户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getUserInfoByPhonenumber")
|
LoginUser getUserInfoByPhonenumber(String phonenumber, String tenantId) throws UserException;
|
||||||
LoginUser getUserInfoByPhonenumber(@RequestParam("phonenumber") String phonenumber, @RequestParam("tenantId") String tenantId) throws UserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过邮箱查询用户信息
|
* 通过邮箱查询用户信息
|
||||||
@ -56,8 +50,7 @@ public interface RemoteUserService {
|
|||||||
* @param tenantId 租户id
|
* @param tenantId 租户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getUserInfoByEmail")
|
LoginUser getUserInfoByEmail(String email, String tenantId) throws UserException;
|
||||||
LoginUser getUserInfoByEmail(@RequestParam("email") String email, @RequestParam("tenantId") String tenantId) throws UserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过openid查询用户信息
|
* 通过openid查询用户信息
|
||||||
@ -65,8 +58,7 @@ public interface RemoteUserService {
|
|||||||
* @param openid openid
|
* @param openid openid
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/getUserInfoByOpenid")
|
XcxLoginUser getUserInfoByOpenid(String openid) throws UserException;
|
||||||
XcxLoginUser getUserInfoByOpenid(@RequestParam("openid") String openid) throws UserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
@ -74,8 +66,7 @@ public interface RemoteUserService {
|
|||||||
* @param remoteUserBo 用户信息
|
* @param remoteUserBo 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/registerUserInfo")
|
Boolean registerUserInfo(RemoteUserBo remoteUserBo) throws UserException, ServiceException;
|
||||||
Boolean registerUserInfo(@RequestBody RemoteUserBo remoteUserBo) throws UserException, ServiceException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过userId查询用户账户
|
* 通过userId查询用户账户
|
||||||
@ -83,8 +74,7 @@ public interface RemoteUserService {
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectUserNameById")
|
String selectUserNameById(Long userId);
|
||||||
String selectUserNameById(@RequestParam("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户昵称
|
* 通过用户ID查询用户昵称
|
||||||
@ -92,8 +82,7 @@ public interface RemoteUserService {
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectNicknameById")
|
String selectNicknameById(Long userId);
|
||||||
String selectNicknameById(@RequestParam("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户账户
|
* 通过用户ID查询用户账户
|
||||||
@ -101,8 +90,7 @@ public interface RemoteUserService {
|
|||||||
* @param userIds 用户ID 多个用逗号隔开
|
* @param userIds 用户ID 多个用逗号隔开
|
||||||
* @return 用户名称
|
* @return 用户名称
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectNicknameByIds")
|
String selectNicknameByIds(String userIds);
|
||||||
String selectNicknameByIds(@RequestParam("userIds") String userIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户手机号
|
* 通过用户ID查询用户手机号
|
||||||
@ -110,8 +98,7 @@ public interface RemoteUserService {
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @return 用户手机号
|
* @return 用户手机号
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectPhonenumberById")
|
String selectPhonenumberById(Long userId);
|
||||||
String selectPhonenumberById(@RequestParam("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户邮箱
|
* 通过用户ID查询用户邮箱
|
||||||
@ -119,8 +106,7 @@ public interface RemoteUserService {
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @return 用户邮箱
|
* @return 用户邮箱
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectEmailById")
|
String selectEmailById(Long userId);
|
||||||
String selectEmailById(@RequestParam("userId") Long userId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
@ -128,8 +114,7 @@ public interface RemoteUserService {
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param ip IP地址
|
* @param ip IP地址
|
||||||
*/
|
*/
|
||||||
@PostMapping("/recordLoginInfo")
|
void recordLoginInfo(Long userId, String ip);
|
||||||
void recordLoginInfo(@RequestParam("userId") Long userId, @RequestParam("ip") String ip);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户列表
|
* 通过用户ID查询用户列表
|
||||||
@ -137,8 +122,7 @@ public interface RemoteUserService {
|
|||||||
* @param userIds 用户ids
|
* @param userIds 用户ids
|
||||||
* @return 用户列表
|
* @return 用户列表
|
||||||
*/
|
*/
|
||||||
@PostMapping("/selectListByIds")
|
List<RemoteUserVo> selectListByIds(List<Long> userIds);
|
||||||
List<RemoteUserVo> selectListByIds(@RequestBody List<Long> userIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色ID查询用户ID
|
* 通过角色ID查询用户ID
|
||||||
@ -146,6 +130,5 @@ public interface RemoteUserService {
|
|||||||
* @param roleIds 角色ids
|
* @param roleIds 角色ids
|
||||||
* @return 用户ids
|
* @return 用户ids
|
||||||
*/
|
*/
|
||||||
@PostMapping("/selectUserIdsByRoleIds")
|
List<Long> selectUserIdsByRoleIds(List<Long> roleIds);
|
||||||
List<Long> selectUserIdsByRoleIds(@RequestBody List<Long> roleIds);
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ClientInfoUtil {
|
|
||||||
|
|
||||||
public String getCurrentSystemIp() {
|
|
||||||
try {
|
|
||||||
return InetAddress.getLocalHost().getHostAddress();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClientType(HttpServletRequest request) {
|
|
||||||
return request.getHeader("Client-Type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import feign.RequestInterceptor;
|
|
||||||
import feign.RequestTemplate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class FeignConfig {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ClientInfoUtil clientInfoUtil;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RequestInterceptor requestInterceptor() {
|
|
||||||
return new RequestInterceptor() {
|
|
||||||
@Override
|
|
||||||
public void apply(RequestTemplate template) {
|
|
||||||
// 获取客户端类型
|
|
||||||
String clientType = clientInfoUtil.getClientType(request);
|
|
||||||
|
|
||||||
// 获取当前系统的IP
|
|
||||||
String currentSystemIp = clientInfoUtil.getCurrentSystemIp();
|
|
||||||
|
|
||||||
// 将客户端信息添加到请求头
|
|
||||||
template.header("X-Client-IP", currentSystemIp);
|
|
||||||
template.header("X-Client-Type", clientType);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user