package com.gzzm.lobster.quota;

import net.cyan.thunwind.annotation.ColumnDescription;
import net.cyan.thunwind.annotation.Entity;
import net.cyan.thunwind.annotation.Index;

import java.util.Date;

/**
 * QuotaPolicy —— 配额与限流策略 / Quota and rate-limit policy.
 *
 * <p>按 scope（global / org / user / tool / model）分组配置。
 * Scoped by global / org / user / tool / model.
 */
@Entity(table = "AI_QUOTA_POLICY", keys = "policyId")
public class QuotaPolicy {

    @ColumnDescription(type = "varchar(60)")
    private String policyId;

    /** global / org / user / tool / model */
    @Index
    @ColumnDescription(type = "varchar(20)", nullable = false)
    private String scope;

    /** scope 对应的目标 id：orgId / userId / toolName / modelId / 空（global） */
    @ColumnDescription(type = "varchar(100)")
    private String targetRef;

    /** 最大并发 run / Max concurrent runs */
    @ColumnDescription(type = "number(6)", defaultValue = "3")
    private Integer maxConcurrentRuns;

    /** 每分钟最大模型调用 / Max model calls per minute */
    @ColumnDescription(type = "number(8)", defaultValue = "120")
    private Integer maxModelCallsPerMinute;

    /** 每日预算 tokens / Daily token budget */
    @ColumnDescription(type = "number(12)")
    private Long dailyTokenBudget;

    /** 工具每分钟调用上限 / Tool calls per minute */
    @ColumnDescription(type = "number(8)", defaultValue = "60")
    private Integer maxToolCallsPerMinute;

    /** 单次工具批量大小 / Max batch size per tool call */
    @ColumnDescription(type = "number(8)", defaultValue = "50")
    private Integer maxBatchSize;

    /** 单次工具返回最大字节数 / Max bytes per tool call */
    @ColumnDescription(type = "number(12)", defaultValue = "524288")
    private Long maxBytesPerCall;

    @ColumnDescription(type = "number(1)", defaultValue = "1")
    private Boolean enabled;

    private Date createTime;
    private Date updateTime;

    public QuotaPolicy() {}

    public String getPolicyId() { return policyId; }
    public void setPolicyId(String policyId) { this.policyId = policyId; }
    public String getScope() { return scope; }
    public void setScope(String scope) { this.scope = scope; }
    public String getTargetRef() { return targetRef; }
    public void setTargetRef(String targetRef) { this.targetRef = targetRef; }
    public Integer getMaxConcurrentRuns() { return maxConcurrentRuns; }
    public void setMaxConcurrentRuns(Integer maxConcurrentRuns) { this.maxConcurrentRuns = maxConcurrentRuns; }
    public Integer getMaxModelCallsPerMinute() { return maxModelCallsPerMinute; }
    public void setMaxModelCallsPerMinute(Integer maxModelCallsPerMinute) { this.maxModelCallsPerMinute = maxModelCallsPerMinute; }
    public Long getDailyTokenBudget() { return dailyTokenBudget; }
    public void setDailyTokenBudget(Long dailyTokenBudget) { this.dailyTokenBudget = dailyTokenBudget; }
    public Integer getMaxToolCallsPerMinute() { return maxToolCallsPerMinute; }
    public void setMaxToolCallsPerMinute(Integer maxToolCallsPerMinute) { this.maxToolCallsPerMinute = maxToolCallsPerMinute; }
    public Integer getMaxBatchSize() { return maxBatchSize; }
    public void setMaxBatchSize(Integer maxBatchSize) { this.maxBatchSize = maxBatchSize; }
    public Long getMaxBytesPerCall() { return maxBytesPerCall; }
    public void setMaxBytesPerCall(Long maxBytesPerCall) { this.maxBytesPerCall = maxBytesPerCall; }
    public Boolean getEnabled() { return enabled; }
    public void setEnabled(Boolean enabled) { this.enabled = enabled; }
    public Date getCreateTime() { return createTime; }
    public void setCreateTime(Date createTime) { this.createTime = createTime; }
    public Date getUpdateTime() { return updateTime; }
    public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
}
