|
|
@@ -8,6 +8,7 @@ import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserAccountRole;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserAuthority;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserRegistry;
|
|
|
+import cn.reghao.tnb.common.auth.AccountRole;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Repository;
|
|
|
@@ -89,12 +90,28 @@ public class AccountRepository {
|
|
|
return accountInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取某个 user 拥有的所有 role
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @date 2025-10-17 11:30:05
|
|
|
+ */
|
|
|
public Set<String> getUserRoles(long userId) {
|
|
|
- return userAccountRoleMapper.findByUserId(userId).stream()
|
|
|
+ return userAccountRoleMapper.findRolesByUserId(userId).stream()
|
|
|
.map(UserAccountRole::getName)
|
|
|
.collect(Collectors.toSet());
|
|
|
}
|
|
|
|
|
|
+ public List<Long> getRoleUsers(String role) {
|
|
|
+ for (AccountRole accountRole : AccountRole.values()) {
|
|
|
+ String role1 = accountRole.getValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> userIds = userAccountRoleMapper.findUserIdsByRole(role);
|
|
|
+ return userIds;
|
|
|
+ }
|
|
|
+
|
|
|
public UserRegistry getUserRegistry() {
|
|
|
List<UserRegistry> list = userRegistryMapper.findAll();
|
|
|
if (list.isEmpty()) {
|
|
|
@@ -143,7 +160,7 @@ public class AccountRepository {
|
|
|
}
|
|
|
|
|
|
private UserAccount setAccountAuthorities(UserAccount userAccount) {
|
|
|
- Set<UserAuthority> set = userAccountRoleMapper.findByUserId(userAccount.getUserId()).stream()
|
|
|
+ Set<UserAuthority> set = userAccountRoleMapper.findRolesByUserId(userAccount.getUserId()).stream()
|
|
|
.map(userAccountRole -> new UserAuthority(userAccountRole.getName()))
|
|
|
.collect(Collectors.toSet());
|
|
|
userAccount.setAuthorities(set);
|