新增功能: - 新增 Sora 账号管理和 OAuth 认证 - 新增 Sora 视频/图片生成 API 网关 - 新增 Sora 任务调度和缓存机制 - 新增 Sora 使用统计和计费支持 - 前端增加 Sora 平台配置界面 安全修复(代码审核): - [SEC-001] 限制媒体下载响应体大小(图片 20MB、视频 200MB),防止 DoS 攻击 - [SEC-002] 限制 SDK API 响应大小(1MB),防止内存耗尽 - [SEC-003] 修复 SSRF 风险,添加 URL 验证并强制使用代理配置 BUG 修复(代码审核): - [BUG-001] 修复 for 循环内 defer 累积导致的资源泄漏 - [BUG-002] 修复图片并发槽位获取失败时已持有锁未释放的永久泄漏 性能优化(代码审核): - [PERF-001] 添加 Sentinel Token 缓存(3 分钟有效期),减少 PoW 计算开销 技术细节: - 使用 io.LimitReader 限制所有外部输入的大小 - 添加 urlvalidator 验证防止 SSRF 攻击 - 使用 sync.Map 实现线程安全的包级缓存 - 优化并发槽位管理,添加 releaseAll 模式防止泄漏 影响范围: - 后端:新增 Sora 相关数据模型、服务、网关和管理接口 - 前端:新增 Sora 平台配置、账号管理和监控界面 - 配置:新增 Sora 相关配置项和环境变量 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
161 lines
6.1 KiB
Go
161 lines
6.1 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package sorausagestat
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the sorausagestat type in the database.
|
|
Label = "sora_usage_stat"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
|
FieldCreatedAt = "created_at"
|
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
|
FieldUpdatedAt = "updated_at"
|
|
// FieldAccountID holds the string denoting the account_id field in the database.
|
|
FieldAccountID = "account_id"
|
|
// FieldImageCount holds the string denoting the image_count field in the database.
|
|
FieldImageCount = "image_count"
|
|
// FieldVideoCount holds the string denoting the video_count field in the database.
|
|
FieldVideoCount = "video_count"
|
|
// FieldErrorCount holds the string denoting the error_count field in the database.
|
|
FieldErrorCount = "error_count"
|
|
// FieldLastErrorAt holds the string denoting the last_error_at field in the database.
|
|
FieldLastErrorAt = "last_error_at"
|
|
// FieldTodayImageCount holds the string denoting the today_image_count field in the database.
|
|
FieldTodayImageCount = "today_image_count"
|
|
// FieldTodayVideoCount holds the string denoting the today_video_count field in the database.
|
|
FieldTodayVideoCount = "today_video_count"
|
|
// FieldTodayErrorCount holds the string denoting the today_error_count field in the database.
|
|
FieldTodayErrorCount = "today_error_count"
|
|
// FieldTodayDate holds the string denoting the today_date field in the database.
|
|
FieldTodayDate = "today_date"
|
|
// FieldConsecutiveErrorCount holds the string denoting the consecutive_error_count field in the database.
|
|
FieldConsecutiveErrorCount = "consecutive_error_count"
|
|
// Table holds the table name of the sorausagestat in the database.
|
|
Table = "sora_usage_stats"
|
|
)
|
|
|
|
// Columns holds all SQL columns for sorausagestat fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
FieldAccountID,
|
|
FieldImageCount,
|
|
FieldVideoCount,
|
|
FieldErrorCount,
|
|
FieldLastErrorAt,
|
|
FieldTodayImageCount,
|
|
FieldTodayVideoCount,
|
|
FieldTodayErrorCount,
|
|
FieldTodayDate,
|
|
FieldConsecutiveErrorCount,
|
|
}
|
|
|
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
|
func ValidColumn(column string) bool {
|
|
for i := range Columns {
|
|
if column == Columns[i] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var (
|
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
|
DefaultCreatedAt func() time.Time
|
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
|
DefaultUpdatedAt func() time.Time
|
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
|
UpdateDefaultUpdatedAt func() time.Time
|
|
// DefaultImageCount holds the default value on creation for the "image_count" field.
|
|
DefaultImageCount int
|
|
// DefaultVideoCount holds the default value on creation for the "video_count" field.
|
|
DefaultVideoCount int
|
|
// DefaultErrorCount holds the default value on creation for the "error_count" field.
|
|
DefaultErrorCount int
|
|
// DefaultTodayImageCount holds the default value on creation for the "today_image_count" field.
|
|
DefaultTodayImageCount int
|
|
// DefaultTodayVideoCount holds the default value on creation for the "today_video_count" field.
|
|
DefaultTodayVideoCount int
|
|
// DefaultTodayErrorCount holds the default value on creation for the "today_error_count" field.
|
|
DefaultTodayErrorCount int
|
|
// DefaultConsecutiveErrorCount holds the default value on creation for the "consecutive_error_count" field.
|
|
DefaultConsecutiveErrorCount int
|
|
)
|
|
|
|
// OrderOption defines the ordering options for the SoraUsageStat queries.
|
|
type OrderOption func(*sql.Selector)
|
|
|
|
// ByID orders the results by the id field.
|
|
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByCreatedAt orders the results by the created_at field.
|
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUpdatedAt orders the results by the updated_at field.
|
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByAccountID orders the results by the account_id field.
|
|
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
|
|
}
|
|
|
|
// ByImageCount orders the results by the image_count field.
|
|
func ByImageCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldImageCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByVideoCount orders the results by the video_count field.
|
|
func ByVideoCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldVideoCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByErrorCount orders the results by the error_count field.
|
|
func ByErrorCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldErrorCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByLastErrorAt orders the results by the last_error_at field.
|
|
func ByLastErrorAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldLastErrorAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByTodayImageCount orders the results by the today_image_count field.
|
|
func ByTodayImageCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldTodayImageCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByTodayVideoCount orders the results by the today_video_count field.
|
|
func ByTodayVideoCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldTodayVideoCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByTodayErrorCount orders the results by the today_error_count field.
|
|
func ByTodayErrorCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldTodayErrorCount, opts...).ToFunc()
|
|
}
|
|
|
|
// ByTodayDate orders the results by the today_date field.
|
|
func ByTodayDate(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldTodayDate, opts...).ToFunc()
|
|
}
|
|
|
|
// ByConsecutiveErrorCount orders the results by the consecutive_error_count field.
|
|
func ByConsecutiveErrorCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldConsecutiveErrorCount, opts...).ToFunc()
|
|
}
|