cef4e48e27
- Gradle multi-module: ga-common, ga-core, ga-api, ga-batch, ga-admin - Flyway V1-V12: org/product/rule/receive/ledger/settle/batch/code/menu/system + seed - ga-common (complete): - model: ApiResponse, PageResponse, SearchParam, TreeNode - exception: ErrorCode, BizException, GlobalExceptionHandler - annotation + aop: @RequirePermission, @DataChangeLog, ApiLog - auth + security: JWT, SecurityConfig - mybatis: BaseMapper, EncryptTypeHandler, JsonTypeHandler, AuditInterceptor - code (Redis cached) / menu (RBAC tree) / file / system / notification - excel: SXSSF+Cursor export, SAX+batch import (1M/700K rows) - util: Date/Money/Mask/Encrypt/Security
22 lines
757 B
Java
22 lines
757 B
Java
package com.ga.common.menu;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
@RequiredArgsConstructor
|
|
public class PermissionChecker {
|
|
|
|
private final MenuMapper menuMapper;
|
|
|
|
/** 사용자 + 메뉴 + 권한 조합을 체크. 캐시: userPerm::userId_menuCode_permCode */
|
|
@Cacheable(value = "userPerm",
|
|
key = "T(java.lang.String).format('%d_%s_%s', #userId, #menuCode, #permCode)",
|
|
unless = "#result == false")
|
|
public boolean hasPermission(Long userId, String menuCode, String permCode) {
|
|
if (userId == null) return false;
|
|
return menuMapper.hasPermission(userId, menuCode, permCode) > 0;
|
|
}
|
|
}
|