From 2b20145159c4c4eefc73fd449093e639812a64df Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期三, 19 八月 2026 14:35:36 +0800
Subject: [PATCH] 又又更新
---
talent-card-server/src/main/java/com/talentcard/server/business/admin/auth/AdminAuthService.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/admin/auth/AdminAuthService.java b/talent-card-server/src/main/java/com/talentcard/server/business/admin/auth/AdminAuthService.java
index 71a3848..e3fe181 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/admin/auth/AdminAuthService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/admin/auth/AdminAuthService.java
@@ -109,6 +109,25 @@
return displayName.isBlank() ? "管理员" : displayName;
}
+ @Transactional(readOnly = true)
+ public boolean hasPermission(Long operatorId, String permission) {
+ List<Map<String, Object>> result = rows("""
+ select o.role_code, r.permission_codes
+ from admin_operator o left join admin_role r on r.role_code = o.role_code
+ where o.id = ? and o.deleted = 0
+ limit 1
+ """, operatorId);
+ if (result.isEmpty()) return false;
+ Map<String, Object> operator = result.get(0);
+ if ("platform_admin".equals(String.valueOf(operator.get("roleCode")))) return true;
+ String raw = String.valueOf(operator.getOrDefault("permissionCodes", ""));
+ try {
+ return JSON.parseArray(raw, String.class).contains(permission);
+ } catch (Exception ignored) {
+ return false;
+ }
+ }
+
private Map<String, Object> issueSession(Map<String, Object> operator) {
String accessToken = token();
LocalDateTime now = LocalDateTime.now();
--
Gitblit v1.7.1