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

import cn.skcks.matrix.v2.model.casbin.CasbinConstant;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface CasbinService {
    String SEPARATOR = CasbinConstant.SEPARATOR;
    String USER = CasbinConstant.USER;
    String USER_PREFIX = CasbinConstant.USER_PREFIX;
    String ROLE = CasbinConstant.ROLE;
    String ROLE_PREFIX = CasbinConstant.ROLE_PREFIX;
    String DEFAULT_SYSTEM = CasbinConstant.DEFAULT_SYSTEM;

    String SUPER_PERMISSION = CasbinConstant.SUPER_PERMISSION;
    String SUPER_PERMISSION_NAME = CasbinConstant.SUPER_PERMISSION_NAME;
    String SUPER_ROLE = CasbinConstant.SUPER_ROLE;

    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);

    void reload();
}
