package cn.skcks.matrix.v2.services.casbin;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface CasbinService {
    String SEPARATOR = "::";
    String USER = "USER";
    String USER_PREFIX = USER + SEPARATOR;
    String ROLE = "ROLE";
    String ROLE_PREFIX = ROLE + SEPARATOR;
    String DEFAULT_SYSTEM = "WEB";

    String SUPER_PERMISSION = "root";
    String SUPER_PERMISSION_NAME = "超级管理员";
    String SUPER_ROLE = ROLE_PREFIX + SUPER_PERMISSION;

    boolean addRole(String role, String system, String url, String method);

    boolean addRole(Permission permission);

    void grantRole(String userId, String role, String system);

    void revokeRole(String userId, String role, String system);

    boolean enforce(String identify, String system, String url, String method);

    List<String> getUserRoles(String userId, String system);

    List<String> getRoleUsers(String role, String system);

    List<Permission> getUserPermission(String userId, String system);

    List<String> getRelationForRoleInSystem(String role, String system);

    boolean delRole(String role, String system);
}
