feat: 新增 AI 用量落库与统计接口
- 新增 ai_usage_records 表(系统级表,不按租户过滤)与幂等上报接口 - 新增按时间/任务类型/模型的汇总、趋势、明细查询,仅白名单用户可见 - 登录响应返回 aiAdmin,供前端决定是否展示入口
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.guo.learningprogresstracker.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DeepSeek 账户余额(契约 2.5,{@code GET /ai/usage/balance})。
|
||||
*
|
||||
* <p>由 lpt-be 代理 lpt-ai 的 {@code GET /admin/usage/balance};上游未配置或调用失败时只有
|
||||
* {@code configured=false} 一个字段,因此这里用 {@code NON_NULL} 让其余字段直接不出现,
|
||||
* 与契约给的响应体形状一致。</p>
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AiUsageBalance {
|
||||
|
||||
/** 上游是否可用:false 表示 lpt-ai 未配置 API Key 或本次查询失败 */
|
||||
private boolean configured;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String totalBalance;
|
||||
|
||||
private String grantedBalance;
|
||||
|
||||
private String toppedUpBalance;
|
||||
|
||||
/** 上游取数时间(ISO 8601 UTC) */
|
||||
private String fetchedAt;
|
||||
|
||||
/** 上游不可用时的唯一响应:{@code {"configured": false}} */
|
||||
public static AiUsageBalance notConfigured() {
|
||||
return new AiUsageBalance();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user