新增功能: - 新增 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>
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
|
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
|
|
)
|
|
|
|
// SoraCacheFileDelete is the builder for deleting a SoraCacheFile entity.
|
|
type SoraCacheFileDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *SoraCacheFileMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the SoraCacheFileDelete builder.
|
|
func (_d *SoraCacheFileDelete) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileDelete {
|
|
_d.mutation.Where(ps...)
|
|
return _d
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (_d *SoraCacheFileDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_d *SoraCacheFileDelete) ExecX(ctx context.Context) int {
|
|
n, err := _d.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (_d *SoraCacheFileDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(soracachefile.Table, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
|
|
if ps := _d.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
_d.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// SoraCacheFileDeleteOne is the builder for deleting a single SoraCacheFile entity.
|
|
type SoraCacheFileDeleteOne struct {
|
|
_d *SoraCacheFileDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the SoraCacheFileDelete builder.
|
|
func (_d *SoraCacheFileDeleteOne) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileDeleteOne {
|
|
_d._d.mutation.Where(ps...)
|
|
return _d
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (_d *SoraCacheFileDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := _d._d.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{soracachefile.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_d *SoraCacheFileDeleteOne) ExecX(ctx context.Context) {
|
|
if err := _d.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|