package com.gzzm.lobster.quota;

import net.cyan.thunwind.annotation.OQL;
import net.cyan.thunwind.dao.GeneralDao;

import java.util.List;

public abstract class QuotaPolicyDao extends GeneralDao {

    @OQL("select q from QuotaPolicy q where q.policyId=:1")
    public abstract QuotaPolicy getPolicy(String policyId) throws Exception;

    @OQL("select q from QuotaPolicy q where q.enabled=1 and q.scope=?1 order by q.targetRef asc")
    public abstract List<QuotaPolicy> listByScope(String scope) throws Exception;

    @OQL("select q from QuotaPolicy q where q.enabled=1 and q.scope=?1 and q.targetRef=?2 limit 0,1")
    public abstract QuotaPolicy findExact(String scope, String targetRef) throws Exception;
}
