mirror of
https://github.com/mfish-qf/mfish-nocode.git
synced 2026-09-21 05:42:57 +08:00
feat: 增加账号获取用户的feign接口
This commit is contained in:
+5
@@ -70,6 +70,11 @@ public class RemoteUserFallback implements FallbackFactory<RemoteUserService> {
|
||||
public Result<List<String>> getUserIdsByAccounts(String origin, String accounts) {
|
||||
return Result.fail("错误:获取用户ID失败" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<UserInfo>> getUsersByAccount(String origin, String accounts) {
|
||||
return Result.fail("错误:获取用户信息失败" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+42
-28
@@ -29,27 +29,29 @@ public interface RemoteUserService {
|
||||
/**
|
||||
* 根据token获取用户信息
|
||||
*
|
||||
* @param token
|
||||
* @param origin
|
||||
* @return
|
||||
* @param token token
|
||||
* @param origin 来源
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/user/info")
|
||||
Result<UserInfoVo> getUserInfo(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestHeader(Constants.AUTHENTICATION) String token);
|
||||
|
||||
/**
|
||||
* 根据id获取用户信息(不包括密码)
|
||||
* @param origin
|
||||
* @param id
|
||||
* @return
|
||||
*
|
||||
* @param origin 来源
|
||||
* @param id 用户id
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/user/{id}")
|
||||
Result<UserInfo> getUserById(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("id") String id);
|
||||
|
||||
/**
|
||||
* 根据账号获取用户信息(不包括密码)
|
||||
* @param origin
|
||||
* @param account
|
||||
* @return
|
||||
*
|
||||
* @param origin 来源
|
||||
* @param account 账号
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/user/info/{account}")
|
||||
Result<UserInfo> getUserByAccount(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("account") String account);
|
||||
@@ -57,10 +59,10 @@ public interface RemoteUserService {
|
||||
/**
|
||||
* 获取用户角色
|
||||
*
|
||||
* @param origin
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @return
|
||||
* @param origin 来源
|
||||
* @param userId 用户id
|
||||
* @param tenantId 租户id
|
||||
* @return 用户角色列表
|
||||
*/
|
||||
@GetMapping("/user/roles")
|
||||
Result<List<UserRole>> getRoles(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam("userId") String userId, @RequestParam("tenantId") String tenantId);
|
||||
@@ -68,10 +70,10 @@ public interface RemoteUserService {
|
||||
/**
|
||||
* 获取用户权限
|
||||
*
|
||||
* @param origin
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @return
|
||||
* @param origin 来源
|
||||
* @param userId 用户id
|
||||
* @param tenantId 租户id
|
||||
* @return 返回权限集合
|
||||
*/
|
||||
@GetMapping("/user/permissions")
|
||||
Result<Set<String>> getPermissions(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam("userId") String userId, @RequestParam("tenantId") String tenantId);
|
||||
@@ -79,9 +81,9 @@ public interface RemoteUserService {
|
||||
/**
|
||||
* 获取当前租户列表
|
||||
*
|
||||
* @param origin
|
||||
* @param userId
|
||||
* @return
|
||||
* @param origin 来源
|
||||
* @param userId 用户id
|
||||
* @return 租户列表
|
||||
*/
|
||||
@GetMapping("/user/tenants")
|
||||
Result<List<TenantVo>> getTenants(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @RequestParam("userId") String userId);
|
||||
@@ -89,9 +91,10 @@ public interface RemoteUserService {
|
||||
/**
|
||||
* 获取用户组织
|
||||
*
|
||||
* @param userId
|
||||
* @param direction
|
||||
* @return
|
||||
* @param origin 来源
|
||||
* @param userId 用户id
|
||||
* @param direction 查询方向
|
||||
* @return 用户组织列表
|
||||
*/
|
||||
@GetMapping("/user/orgs/{userId}")
|
||||
Result<List<SsoOrg>> getOrgs(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("userId") String userId, @RequestParam("direction") String direction);
|
||||
@@ -103,17 +106,28 @@ public interface RemoteUserService {
|
||||
* @param userId 用户id
|
||||
* @param tenantId 租户id
|
||||
* @param direction 查询方向
|
||||
* @return
|
||||
* @return 组织id列表
|
||||
*/
|
||||
@GetMapping("/user/orgIds/{userId}")
|
||||
Result<List<String>> getOrgIds(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("userId") String userId, @RequestParam("tenantId") String tenantId, @RequestParam("direction") String direction);
|
||||
|
||||
/**
|
||||
* 根据账号获取用户id
|
||||
* @param origin 来源
|
||||
*
|
||||
* @param origin 来源
|
||||
* @param accounts 账号 多个逗号分割
|
||||
* @return
|
||||
* @return 返回用户id列表
|
||||
*/
|
||||
@GetMapping("/user/userId/{account}")
|
||||
Result<List<String>> getUserIdsByAccounts(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable String accounts);
|
||||
@GetMapping("/user/userId/{accounts}")
|
||||
Result<List<String>> getUserIdsByAccounts(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("accounts") String accounts);
|
||||
|
||||
/**
|
||||
* 根据账号获取用户信息
|
||||
*
|
||||
* @param origin 来源
|
||||
* @param accounts 账号 多个逗号分割
|
||||
* @return 返回用户信息列表
|
||||
*/
|
||||
@GetMapping("/user/users/{accounts}")
|
||||
Result<List<UserInfo>> getUsersByAccount(@RequestHeader(RPCConstants.REQ_ORIGIN) String origin, @PathVariable("accounts") String accounts);
|
||||
}
|
||||
@@ -80,4 +80,9 @@ public class BootUserService implements RemoteUserService {
|
||||
public Result<List<String>> getUserIdsByAccounts(String origin, String accounts) {
|
||||
return Result.ok(ssoUserService.getUserIdsByAccounts(List.of(accounts.split(","))), "获取用户id成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<UserInfo>> getUsersByAccount(String origin, String accounts) {
|
||||
return Result.ok(ssoUserService.getUsersByAccounts(List.of(accounts.split(","))), "获取用户信息成功");
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -42,6 +42,8 @@ public interface SsoUserService extends IService<SsoUser> {
|
||||
|
||||
List<String> getUserIdsByAccounts(List<String> accounts);
|
||||
|
||||
List<UserInfo> getUsersByAccounts(List<String> accounts);
|
||||
|
||||
SsoUser getUserById(String userId);
|
||||
|
||||
UserInfo getUserByIdNoPwd(String userId);
|
||||
|
||||
+2
-1
@@ -2,12 +2,13 @@ package cn.com.mfish.common.redis.temp;
|
||||
|
||||
import cn.com.mfish.common.redis.common.RedisPrefix;
|
||||
import cn.com.mfish.common.redis.config.CacheProperties;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -308,4 +308,11 @@ public class SsoUserController {
|
||||
public Result<List<String>> getUserIdByAccount(@Parameter(name = "accounts", description = "帐号名称") @PathVariable String accounts) {
|
||||
return Result.ok(ssoUserService.getUserIdsByAccounts(List.of(accounts.split(","))), "获取用户id成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "根据账号获取简单用户信息(内部接口)")
|
||||
@GetMapping("/users/{accounts}")
|
||||
@InnerUser
|
||||
public Result<List<UserInfo>> getUsersByAccount(@Parameter(name = "accounts", description = "帐号名称") @PathVariable String accounts) {
|
||||
return Result.ok(ssoUserService.getUsersByAccounts(List.of(accounts.split(","))), "获取用户信息成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,4 +98,6 @@ public interface SsoUserMapper extends BaseMapper<SsoUser> {
|
||||
List<SimpleUserInfo> searchUserList(@Param("condition") String condition);
|
||||
|
||||
List<String> getUserIdsByAccounts(@Param("accounts") List<String> accounts);
|
||||
|
||||
List<UserInfo> getUsersByAccounts(@Param("accounts") List<String> accounts);
|
||||
}
|
||||
|
||||
@@ -248,4 +248,10 @@
|
||||
#{account}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getUsersByAccounts" resultType="cn.com.mfish.common.oauth.api.entity.UserInfo">
|
||||
select * from sso_user where account in
|
||||
<foreach collection="accounts" item="account" separator="," open="(" close=")">
|
||||
#{account}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -307,6 +307,11 @@ public class SsoUserServiceImpl extends ServiceImpl<SsoUserMapper, SsoUser> impl
|
||||
return baseMapper.getUserIdsByAccounts(accounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> getUsersByAccounts(List<String> accounts) {
|
||||
return baseMapper.getUsersByAccounts(accounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SsoUser getUserById(String userId) {
|
||||
return userTempCache.getFromCacheAndDB(userId);
|
||||
|
||||
Reference in New Issue
Block a user