feat(sora): 新增 Sora 平台支持并修复高危安全和性能问题

新增功能:
- 新增 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>
This commit is contained in:
yangjianbo
2026-01-29 16:18:38 +08:00
parent bece1b5201
commit 13262a5698
97 changed files with 29541 additions and 68 deletions

View File

@@ -24,6 +24,10 @@ import (
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
"github.com/Wei-Shaw/sub2api/ent/soratask"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
"github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
"github.com/Wei-Shaw/sub2api/ent/usagelog"
"github.com/Wei-Shaw/sub2api/ent/user"
@@ -58,6 +62,14 @@ type Client struct {
RedeemCode *RedeemCodeClient
// Setting is the client for interacting with the Setting builders.
Setting *SettingClient
// SoraAccount is the client for interacting with the SoraAccount builders.
SoraAccount *SoraAccountClient
// SoraCacheFile is the client for interacting with the SoraCacheFile builders.
SoraCacheFile *SoraCacheFileClient
// SoraTask is the client for interacting with the SoraTask builders.
SoraTask *SoraTaskClient
// SoraUsageStat is the client for interacting with the SoraUsageStat builders.
SoraUsageStat *SoraUsageStatClient
// UsageCleanupTask is the client for interacting with the UsageCleanupTask builders.
UsageCleanupTask *UsageCleanupTaskClient
// UsageLog is the client for interacting with the UsageLog builders.
@@ -92,6 +104,10 @@ func (c *Client) init() {
c.Proxy = NewProxyClient(c.config)
c.RedeemCode = NewRedeemCodeClient(c.config)
c.Setting = NewSettingClient(c.config)
c.SoraAccount = NewSoraAccountClient(c.config)
c.SoraCacheFile = NewSoraCacheFileClient(c.config)
c.SoraTask = NewSoraTaskClient(c.config)
c.SoraUsageStat = NewSoraUsageStatClient(c.config)
c.UsageCleanupTask = NewUsageCleanupTaskClient(c.config)
c.UsageLog = NewUsageLogClient(c.config)
c.User = NewUserClient(c.config)
@@ -200,6 +216,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg),
Setting: NewSettingClient(cfg),
SoraAccount: NewSoraAccountClient(cfg),
SoraCacheFile: NewSoraCacheFileClient(cfg),
SoraTask: NewSoraTaskClient(cfg),
SoraUsageStat: NewSoraUsageStatClient(cfg),
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
UsageLog: NewUsageLogClient(cfg),
User: NewUserClient(cfg),
@@ -235,6 +255,10 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg),
Setting: NewSettingClient(cfg),
SoraAccount: NewSoraAccountClient(cfg),
SoraCacheFile: NewSoraCacheFileClient(cfg),
SoraTask: NewSoraTaskClient(cfg),
SoraUsageStat: NewSoraUsageStatClient(cfg),
UsageCleanupTask: NewUsageCleanupTaskClient(cfg),
UsageLog: NewUsageLogClient(cfg),
User: NewUserClient(cfg),
@@ -272,9 +296,9 @@ func (c *Client) Close() error {
func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.PromoCode, c.PromoCodeUsage,
c.Proxy, c.RedeemCode, c.Setting, c.UsageCleanupTask, c.UsageLog, c.User,
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.UserSubscription,
c.Proxy, c.RedeemCode, c.Setting, c.SoraAccount, c.SoraCacheFile, c.SoraTask,
c.SoraUsageStat, c.UsageCleanupTask, c.UsageLog, c.User, c.UserAllowedGroup,
c.UserAttributeDefinition, c.UserAttributeValue, c.UserSubscription,
} {
n.Use(hooks...)
}
@@ -285,9 +309,9 @@ func (c *Client) Use(hooks ...Hook) {
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.PromoCode, c.PromoCodeUsage,
c.Proxy, c.RedeemCode, c.Setting, c.UsageCleanupTask, c.UsageLog, c.User,
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.UserSubscription,
c.Proxy, c.RedeemCode, c.Setting, c.SoraAccount, c.SoraCacheFile, c.SoraTask,
c.SoraUsageStat, c.UsageCleanupTask, c.UsageLog, c.User, c.UserAllowedGroup,
c.UserAttributeDefinition, c.UserAttributeValue, c.UserSubscription,
} {
n.Intercept(interceptors...)
}
@@ -314,6 +338,14 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.RedeemCode.mutate(ctx, m)
case *SettingMutation:
return c.Setting.mutate(ctx, m)
case *SoraAccountMutation:
return c.SoraAccount.mutate(ctx, m)
case *SoraCacheFileMutation:
return c.SoraCacheFile.mutate(ctx, m)
case *SoraTaskMutation:
return c.SoraTask.mutate(ctx, m)
case *SoraUsageStatMutation:
return c.SoraUsageStat.mutate(ctx, m)
case *UsageCleanupTaskMutation:
return c.UsageCleanupTask.mutate(ctx, m)
case *UsageLogMutation:
@@ -1857,6 +1889,538 @@ func (c *SettingClient) mutate(ctx context.Context, m *SettingMutation) (Value,
}
}
// SoraAccountClient is a client for the SoraAccount schema.
type SoraAccountClient struct {
config
}
// NewSoraAccountClient returns a client for the SoraAccount from the given config.
func NewSoraAccountClient(c config) *SoraAccountClient {
return &SoraAccountClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `soraaccount.Hooks(f(g(h())))`.
func (c *SoraAccountClient) Use(hooks ...Hook) {
c.hooks.SoraAccount = append(c.hooks.SoraAccount, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `soraaccount.Intercept(f(g(h())))`.
func (c *SoraAccountClient) Intercept(interceptors ...Interceptor) {
c.inters.SoraAccount = append(c.inters.SoraAccount, interceptors...)
}
// Create returns a builder for creating a SoraAccount entity.
func (c *SoraAccountClient) Create() *SoraAccountCreate {
mutation := newSoraAccountMutation(c.config, OpCreate)
return &SoraAccountCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of SoraAccount entities.
func (c *SoraAccountClient) CreateBulk(builders ...*SoraAccountCreate) *SoraAccountCreateBulk {
return &SoraAccountCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *SoraAccountClient) MapCreateBulk(slice any, setFunc func(*SoraAccountCreate, int)) *SoraAccountCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &SoraAccountCreateBulk{err: fmt.Errorf("calling to SoraAccountClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*SoraAccountCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &SoraAccountCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for SoraAccount.
func (c *SoraAccountClient) Update() *SoraAccountUpdate {
mutation := newSoraAccountMutation(c.config, OpUpdate)
return &SoraAccountUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *SoraAccountClient) UpdateOne(_m *SoraAccount) *SoraAccountUpdateOne {
mutation := newSoraAccountMutation(c.config, OpUpdateOne, withSoraAccount(_m))
return &SoraAccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *SoraAccountClient) UpdateOneID(id int64) *SoraAccountUpdateOne {
mutation := newSoraAccountMutation(c.config, OpUpdateOne, withSoraAccountID(id))
return &SoraAccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for SoraAccount.
func (c *SoraAccountClient) Delete() *SoraAccountDelete {
mutation := newSoraAccountMutation(c.config, OpDelete)
return &SoraAccountDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *SoraAccountClient) DeleteOne(_m *SoraAccount) *SoraAccountDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SoraAccountClient) DeleteOneID(id int64) *SoraAccountDeleteOne {
builder := c.Delete().Where(soraaccount.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &SoraAccountDeleteOne{builder}
}
// Query returns a query builder for SoraAccount.
func (c *SoraAccountClient) Query() *SoraAccountQuery {
return &SoraAccountQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSoraAccount},
inters: c.Interceptors(),
}
}
// Get returns a SoraAccount entity by its id.
func (c *SoraAccountClient) Get(ctx context.Context, id int64) (*SoraAccount, error) {
return c.Query().Where(soraaccount.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *SoraAccountClient) GetX(ctx context.Context, id int64) *SoraAccount {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *SoraAccountClient) Hooks() []Hook {
return c.hooks.SoraAccount
}
// Interceptors returns the client interceptors.
func (c *SoraAccountClient) Interceptors() []Interceptor {
return c.inters.SoraAccount
}
func (c *SoraAccountClient) mutate(ctx context.Context, m *SoraAccountMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SoraAccountCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SoraAccountUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SoraAccountUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SoraAccountDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown SoraAccount mutation op: %q", m.Op())
}
}
// SoraCacheFileClient is a client for the SoraCacheFile schema.
type SoraCacheFileClient struct {
config
}
// NewSoraCacheFileClient returns a client for the SoraCacheFile from the given config.
func NewSoraCacheFileClient(c config) *SoraCacheFileClient {
return &SoraCacheFileClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `soracachefile.Hooks(f(g(h())))`.
func (c *SoraCacheFileClient) Use(hooks ...Hook) {
c.hooks.SoraCacheFile = append(c.hooks.SoraCacheFile, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `soracachefile.Intercept(f(g(h())))`.
func (c *SoraCacheFileClient) Intercept(interceptors ...Interceptor) {
c.inters.SoraCacheFile = append(c.inters.SoraCacheFile, interceptors...)
}
// Create returns a builder for creating a SoraCacheFile entity.
func (c *SoraCacheFileClient) Create() *SoraCacheFileCreate {
mutation := newSoraCacheFileMutation(c.config, OpCreate)
return &SoraCacheFileCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of SoraCacheFile entities.
func (c *SoraCacheFileClient) CreateBulk(builders ...*SoraCacheFileCreate) *SoraCacheFileCreateBulk {
return &SoraCacheFileCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *SoraCacheFileClient) MapCreateBulk(slice any, setFunc func(*SoraCacheFileCreate, int)) *SoraCacheFileCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &SoraCacheFileCreateBulk{err: fmt.Errorf("calling to SoraCacheFileClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*SoraCacheFileCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &SoraCacheFileCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for SoraCacheFile.
func (c *SoraCacheFileClient) Update() *SoraCacheFileUpdate {
mutation := newSoraCacheFileMutation(c.config, OpUpdate)
return &SoraCacheFileUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *SoraCacheFileClient) UpdateOne(_m *SoraCacheFile) *SoraCacheFileUpdateOne {
mutation := newSoraCacheFileMutation(c.config, OpUpdateOne, withSoraCacheFile(_m))
return &SoraCacheFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *SoraCacheFileClient) UpdateOneID(id int64) *SoraCacheFileUpdateOne {
mutation := newSoraCacheFileMutation(c.config, OpUpdateOne, withSoraCacheFileID(id))
return &SoraCacheFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for SoraCacheFile.
func (c *SoraCacheFileClient) Delete() *SoraCacheFileDelete {
mutation := newSoraCacheFileMutation(c.config, OpDelete)
return &SoraCacheFileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *SoraCacheFileClient) DeleteOne(_m *SoraCacheFile) *SoraCacheFileDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SoraCacheFileClient) DeleteOneID(id int64) *SoraCacheFileDeleteOne {
builder := c.Delete().Where(soracachefile.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &SoraCacheFileDeleteOne{builder}
}
// Query returns a query builder for SoraCacheFile.
func (c *SoraCacheFileClient) Query() *SoraCacheFileQuery {
return &SoraCacheFileQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSoraCacheFile},
inters: c.Interceptors(),
}
}
// Get returns a SoraCacheFile entity by its id.
func (c *SoraCacheFileClient) Get(ctx context.Context, id int64) (*SoraCacheFile, error) {
return c.Query().Where(soracachefile.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *SoraCacheFileClient) GetX(ctx context.Context, id int64) *SoraCacheFile {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *SoraCacheFileClient) Hooks() []Hook {
return c.hooks.SoraCacheFile
}
// Interceptors returns the client interceptors.
func (c *SoraCacheFileClient) Interceptors() []Interceptor {
return c.inters.SoraCacheFile
}
func (c *SoraCacheFileClient) mutate(ctx context.Context, m *SoraCacheFileMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SoraCacheFileCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SoraCacheFileUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SoraCacheFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SoraCacheFileDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown SoraCacheFile mutation op: %q", m.Op())
}
}
// SoraTaskClient is a client for the SoraTask schema.
type SoraTaskClient struct {
config
}
// NewSoraTaskClient returns a client for the SoraTask from the given config.
func NewSoraTaskClient(c config) *SoraTaskClient {
return &SoraTaskClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `soratask.Hooks(f(g(h())))`.
func (c *SoraTaskClient) Use(hooks ...Hook) {
c.hooks.SoraTask = append(c.hooks.SoraTask, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `soratask.Intercept(f(g(h())))`.
func (c *SoraTaskClient) Intercept(interceptors ...Interceptor) {
c.inters.SoraTask = append(c.inters.SoraTask, interceptors...)
}
// Create returns a builder for creating a SoraTask entity.
func (c *SoraTaskClient) Create() *SoraTaskCreate {
mutation := newSoraTaskMutation(c.config, OpCreate)
return &SoraTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of SoraTask entities.
func (c *SoraTaskClient) CreateBulk(builders ...*SoraTaskCreate) *SoraTaskCreateBulk {
return &SoraTaskCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *SoraTaskClient) MapCreateBulk(slice any, setFunc func(*SoraTaskCreate, int)) *SoraTaskCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &SoraTaskCreateBulk{err: fmt.Errorf("calling to SoraTaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*SoraTaskCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &SoraTaskCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for SoraTask.
func (c *SoraTaskClient) Update() *SoraTaskUpdate {
mutation := newSoraTaskMutation(c.config, OpUpdate)
return &SoraTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *SoraTaskClient) UpdateOne(_m *SoraTask) *SoraTaskUpdateOne {
mutation := newSoraTaskMutation(c.config, OpUpdateOne, withSoraTask(_m))
return &SoraTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *SoraTaskClient) UpdateOneID(id int64) *SoraTaskUpdateOne {
mutation := newSoraTaskMutation(c.config, OpUpdateOne, withSoraTaskID(id))
return &SoraTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for SoraTask.
func (c *SoraTaskClient) Delete() *SoraTaskDelete {
mutation := newSoraTaskMutation(c.config, OpDelete)
return &SoraTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *SoraTaskClient) DeleteOne(_m *SoraTask) *SoraTaskDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SoraTaskClient) DeleteOneID(id int64) *SoraTaskDeleteOne {
builder := c.Delete().Where(soratask.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &SoraTaskDeleteOne{builder}
}
// Query returns a query builder for SoraTask.
func (c *SoraTaskClient) Query() *SoraTaskQuery {
return &SoraTaskQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSoraTask},
inters: c.Interceptors(),
}
}
// Get returns a SoraTask entity by its id.
func (c *SoraTaskClient) Get(ctx context.Context, id int64) (*SoraTask, error) {
return c.Query().Where(soratask.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *SoraTaskClient) GetX(ctx context.Context, id int64) *SoraTask {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *SoraTaskClient) Hooks() []Hook {
return c.hooks.SoraTask
}
// Interceptors returns the client interceptors.
func (c *SoraTaskClient) Interceptors() []Interceptor {
return c.inters.SoraTask
}
func (c *SoraTaskClient) mutate(ctx context.Context, m *SoraTaskMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SoraTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SoraTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SoraTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SoraTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown SoraTask mutation op: %q", m.Op())
}
}
// SoraUsageStatClient is a client for the SoraUsageStat schema.
type SoraUsageStatClient struct {
config
}
// NewSoraUsageStatClient returns a client for the SoraUsageStat from the given config.
func NewSoraUsageStatClient(c config) *SoraUsageStatClient {
return &SoraUsageStatClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `sorausagestat.Hooks(f(g(h())))`.
func (c *SoraUsageStatClient) Use(hooks ...Hook) {
c.hooks.SoraUsageStat = append(c.hooks.SoraUsageStat, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `sorausagestat.Intercept(f(g(h())))`.
func (c *SoraUsageStatClient) Intercept(interceptors ...Interceptor) {
c.inters.SoraUsageStat = append(c.inters.SoraUsageStat, interceptors...)
}
// Create returns a builder for creating a SoraUsageStat entity.
func (c *SoraUsageStatClient) Create() *SoraUsageStatCreate {
mutation := newSoraUsageStatMutation(c.config, OpCreate)
return &SoraUsageStatCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of SoraUsageStat entities.
func (c *SoraUsageStatClient) CreateBulk(builders ...*SoraUsageStatCreate) *SoraUsageStatCreateBulk {
return &SoraUsageStatCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *SoraUsageStatClient) MapCreateBulk(slice any, setFunc func(*SoraUsageStatCreate, int)) *SoraUsageStatCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &SoraUsageStatCreateBulk{err: fmt.Errorf("calling to SoraUsageStatClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*SoraUsageStatCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &SoraUsageStatCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for SoraUsageStat.
func (c *SoraUsageStatClient) Update() *SoraUsageStatUpdate {
mutation := newSoraUsageStatMutation(c.config, OpUpdate)
return &SoraUsageStatUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *SoraUsageStatClient) UpdateOne(_m *SoraUsageStat) *SoraUsageStatUpdateOne {
mutation := newSoraUsageStatMutation(c.config, OpUpdateOne, withSoraUsageStat(_m))
return &SoraUsageStatUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *SoraUsageStatClient) UpdateOneID(id int64) *SoraUsageStatUpdateOne {
mutation := newSoraUsageStatMutation(c.config, OpUpdateOne, withSoraUsageStatID(id))
return &SoraUsageStatUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for SoraUsageStat.
func (c *SoraUsageStatClient) Delete() *SoraUsageStatDelete {
mutation := newSoraUsageStatMutation(c.config, OpDelete)
return &SoraUsageStatDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *SoraUsageStatClient) DeleteOne(_m *SoraUsageStat) *SoraUsageStatDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *SoraUsageStatClient) DeleteOneID(id int64) *SoraUsageStatDeleteOne {
builder := c.Delete().Where(sorausagestat.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &SoraUsageStatDeleteOne{builder}
}
// Query returns a query builder for SoraUsageStat.
func (c *SoraUsageStatClient) Query() *SoraUsageStatQuery {
return &SoraUsageStatQuery{
config: c.config,
ctx: &QueryContext{Type: TypeSoraUsageStat},
inters: c.Interceptors(),
}
}
// Get returns a SoraUsageStat entity by its id.
func (c *SoraUsageStatClient) Get(ctx context.Context, id int64) (*SoraUsageStat, error) {
return c.Query().Where(sorausagestat.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *SoraUsageStatClient) GetX(ctx context.Context, id int64) *SoraUsageStat {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// Hooks returns the client hooks.
func (c *SoraUsageStatClient) Hooks() []Hook {
return c.hooks.SoraUsageStat
}
// Interceptors returns the client interceptors.
func (c *SoraUsageStatClient) Interceptors() []Interceptor {
return c.inters.SoraUsageStat
}
func (c *SoraUsageStatClient) mutate(ctx context.Context, m *SoraUsageStatMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&SoraUsageStatCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&SoraUsageStatUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&SoraUsageStatUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&SoraUsageStatDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown SoraUsageStat mutation op: %q", m.Op())
}
}
// UsageCleanupTaskClient is a client for the UsageCleanupTask schema.
type UsageCleanupTaskClient struct {
config
@@ -3117,13 +3681,15 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
type (
hooks struct {
APIKey, Account, AccountGroup, Group, PromoCode, PromoCodeUsage, Proxy,
RedeemCode, Setting, UsageCleanupTask, UsageLog, User, UserAllowedGroup,
UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Hook
RedeemCode, Setting, SoraAccount, SoraCacheFile, SoraTask, SoraUsageStat,
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
UserAttributeValue, UserSubscription []ent.Hook
}
inters struct {
APIKey, Account, AccountGroup, Group, PromoCode, PromoCodeUsage, Proxy,
RedeemCode, Setting, UsageCleanupTask, UsageLog, User, UserAllowedGroup,
UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Interceptor
RedeemCode, Setting, SoraAccount, SoraCacheFile, SoraTask, SoraUsageStat,
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
UserAttributeValue, UserSubscription []ent.Interceptor
}
)

View File

@@ -21,6 +21,10 @@ import (
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
"github.com/Wei-Shaw/sub2api/ent/soratask"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
"github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
"github.com/Wei-Shaw/sub2api/ent/usagelog"
"github.com/Wei-Shaw/sub2api/ent/user"
@@ -97,6 +101,10 @@ func checkColumn(t, c string) error {
proxy.Table: proxy.ValidColumn,
redeemcode.Table: redeemcode.ValidColumn,
setting.Table: setting.ValidColumn,
soraaccount.Table: soraaccount.ValidColumn,
soracachefile.Table: soracachefile.ValidColumn,
soratask.Table: soratask.ValidColumn,
sorausagestat.Table: sorausagestat.ValidColumn,
usagecleanuptask.Table: usagecleanuptask.ValidColumn,
usagelog.Table: usagelog.ValidColumn,
user.Table: user.ValidColumn,

View File

@@ -117,6 +117,54 @@ func (f SettingFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, err
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SettingMutation", m)
}
// The SoraAccountFunc type is an adapter to allow the use of ordinary
// function as SoraAccount mutator.
type SoraAccountFunc func(context.Context, *ent.SoraAccountMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f SoraAccountFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.SoraAccountMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SoraAccountMutation", m)
}
// The SoraCacheFileFunc type is an adapter to allow the use of ordinary
// function as SoraCacheFile mutator.
type SoraCacheFileFunc func(context.Context, *ent.SoraCacheFileMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f SoraCacheFileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.SoraCacheFileMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SoraCacheFileMutation", m)
}
// The SoraTaskFunc type is an adapter to allow the use of ordinary
// function as SoraTask mutator.
type SoraTaskFunc func(context.Context, *ent.SoraTaskMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f SoraTaskFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.SoraTaskMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SoraTaskMutation", m)
}
// The SoraUsageStatFunc type is an adapter to allow the use of ordinary
// function as SoraUsageStat mutator.
type SoraUsageStatFunc func(context.Context, *ent.SoraUsageStatMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f SoraUsageStatFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.SoraUsageStatMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SoraUsageStatMutation", m)
}
// The UsageCleanupTaskFunc type is an adapter to allow the use of ordinary
// function as UsageCleanupTask mutator.
type UsageCleanupTaskFunc func(context.Context, *ent.UsageCleanupTaskMutation) (ent.Value, error)

View File

@@ -18,6 +18,10 @@ import (
"github.com/Wei-Shaw/sub2api/ent/proxy"
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
"github.com/Wei-Shaw/sub2api/ent/soratask"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
"github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
"github.com/Wei-Shaw/sub2api/ent/usagelog"
"github.com/Wei-Shaw/sub2api/ent/user"
@@ -326,6 +330,114 @@ func (f TraverseSetting) Traverse(ctx context.Context, q ent.Query) error {
return fmt.Errorf("unexpected query type %T. expect *ent.SettingQuery", q)
}
// The SoraAccountFunc type is an adapter to allow the use of ordinary function as a Querier.
type SoraAccountFunc func(context.Context, *ent.SoraAccountQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f SoraAccountFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.SoraAccountQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.SoraAccountQuery", q)
}
// The TraverseSoraAccount type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSoraAccount func(context.Context, *ent.SoraAccountQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSoraAccount) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseSoraAccount) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.SoraAccountQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.SoraAccountQuery", q)
}
// The SoraCacheFileFunc type is an adapter to allow the use of ordinary function as a Querier.
type SoraCacheFileFunc func(context.Context, *ent.SoraCacheFileQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f SoraCacheFileFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.SoraCacheFileQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.SoraCacheFileQuery", q)
}
// The TraverseSoraCacheFile type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSoraCacheFile func(context.Context, *ent.SoraCacheFileQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSoraCacheFile) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseSoraCacheFile) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.SoraCacheFileQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.SoraCacheFileQuery", q)
}
// The SoraTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type SoraTaskFunc func(context.Context, *ent.SoraTaskQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f SoraTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.SoraTaskQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.SoraTaskQuery", q)
}
// The TraverseSoraTask type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSoraTask func(context.Context, *ent.SoraTaskQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSoraTask) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseSoraTask) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.SoraTaskQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.SoraTaskQuery", q)
}
// The SoraUsageStatFunc type is an adapter to allow the use of ordinary function as a Querier.
type SoraUsageStatFunc func(context.Context, *ent.SoraUsageStatQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f SoraUsageStatFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.SoraUsageStatQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.SoraUsageStatQuery", q)
}
// The TraverseSoraUsageStat type is an adapter to allow the use of ordinary function as Traverser.
type TraverseSoraUsageStat func(context.Context, *ent.SoraUsageStatQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseSoraUsageStat) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseSoraUsageStat) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.SoraUsageStatQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.SoraUsageStatQuery", q)
}
// The UsageCleanupTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type UsageCleanupTaskFunc func(context.Context, *ent.UsageCleanupTaskQuery) (ent.Value, error)
@@ -536,6 +648,14 @@ func NewQuery(q ent.Query) (Query, error) {
return &query[*ent.RedeemCodeQuery, predicate.RedeemCode, redeemcode.OrderOption]{typ: ent.TypeRedeemCode, tq: q}, nil
case *ent.SettingQuery:
return &query[*ent.SettingQuery, predicate.Setting, setting.OrderOption]{typ: ent.TypeSetting, tq: q}, nil
case *ent.SoraAccountQuery:
return &query[*ent.SoraAccountQuery, predicate.SoraAccount, soraaccount.OrderOption]{typ: ent.TypeSoraAccount, tq: q}, nil
case *ent.SoraCacheFileQuery:
return &query[*ent.SoraCacheFileQuery, predicate.SoraCacheFile, soracachefile.OrderOption]{typ: ent.TypeSoraCacheFile, tq: q}, nil
case *ent.SoraTaskQuery:
return &query[*ent.SoraTaskQuery, predicate.SoraTask, soratask.OrderOption]{typ: ent.TypeSoraTask, tq: q}, nil
case *ent.SoraUsageStatQuery:
return &query[*ent.SoraUsageStatQuery, predicate.SoraUsageStat, sorausagestat.OrderOption]{typ: ent.TypeSoraUsageStat, tq: q}, nil
case *ent.UsageCleanupTaskQuery:
return &query[*ent.UsageCleanupTaskQuery, predicate.UsageCleanupTask, usagecleanuptask.OrderOption]{typ: ent.TypeUsageCleanupTask, tq: q}, nil
case *ent.UsageLogQuery:

View File

@@ -434,6 +434,172 @@ var (
Columns: SettingsColumns,
PrimaryKey: []*schema.Column{SettingsColumns[0]},
}
// SoraAccountsColumns holds the columns for the "sora_accounts" table.
SoraAccountsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "account_id", Type: field.TypeInt64},
{Name: "access_token", Type: field.TypeString, Nullable: true},
{Name: "session_token", Type: field.TypeString, Nullable: true},
{Name: "refresh_token", Type: field.TypeString, Nullable: true},
{Name: "client_id", Type: field.TypeString, Nullable: true},
{Name: "email", Type: field.TypeString, Nullable: true},
{Name: "username", Type: field.TypeString, Nullable: true},
{Name: "remark", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}},
{Name: "use_count", Type: field.TypeInt, Default: 0},
{Name: "plan_type", Type: field.TypeString, Nullable: true},
{Name: "plan_title", Type: field.TypeString, Nullable: true},
{Name: "subscription_end", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "sora_supported", Type: field.TypeBool, Default: false},
{Name: "sora_invite_code", Type: field.TypeString, Nullable: true},
{Name: "sora_redeemed_count", Type: field.TypeInt, Default: 0},
{Name: "sora_remaining_count", Type: field.TypeInt, Default: 0},
{Name: "sora_total_count", Type: field.TypeInt, Default: 0},
{Name: "sora_cooldown_until", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "cooled_until", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "image_enabled", Type: field.TypeBool, Default: true},
{Name: "video_enabled", Type: field.TypeBool, Default: true},
{Name: "image_concurrency", Type: field.TypeInt, Default: -1},
{Name: "video_concurrency", Type: field.TypeInt, Default: -1},
{Name: "is_expired", Type: field.TypeBool, Default: false},
}
// SoraAccountsTable holds the schema information for the "sora_accounts" table.
SoraAccountsTable = &schema.Table{
Name: "sora_accounts",
Columns: SoraAccountsColumns,
PrimaryKey: []*schema.Column{SoraAccountsColumns[0]},
Indexes: []*schema.Index{
{
Name: "soraaccount_account_id",
Unique: true,
Columns: []*schema.Column{SoraAccountsColumns[3]},
},
{
Name: "soraaccount_plan_type",
Unique: false,
Columns: []*schema.Column{SoraAccountsColumns[12]},
},
{
Name: "soraaccount_sora_supported",
Unique: false,
Columns: []*schema.Column{SoraAccountsColumns[15]},
},
{
Name: "soraaccount_image_enabled",
Unique: false,
Columns: []*schema.Column{SoraAccountsColumns[22]},
},
{
Name: "soraaccount_video_enabled",
Unique: false,
Columns: []*schema.Column{SoraAccountsColumns[23]},
},
},
}
// SoraCacheFilesColumns holds the columns for the "sora_cache_files" table.
SoraCacheFilesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "task_id", Type: field.TypeString, Nullable: true, Size: 120},
{Name: "account_id", Type: field.TypeInt64},
{Name: "user_id", Type: field.TypeInt64},
{Name: "media_type", Type: field.TypeString, Size: 32},
{Name: "original_url", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}},
{Name: "cache_path", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}},
{Name: "cache_url", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}},
{Name: "size_bytes", Type: field.TypeInt64, Default: 0},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
}
// SoraCacheFilesTable holds the schema information for the "sora_cache_files" table.
SoraCacheFilesTable = &schema.Table{
Name: "sora_cache_files",
Columns: SoraCacheFilesColumns,
PrimaryKey: []*schema.Column{SoraCacheFilesColumns[0]},
Indexes: []*schema.Index{
{
Name: "soracachefile_account_id",
Unique: false,
Columns: []*schema.Column{SoraCacheFilesColumns[2]},
},
{
Name: "soracachefile_user_id",
Unique: false,
Columns: []*schema.Column{SoraCacheFilesColumns[3]},
},
{
Name: "soracachefile_media_type",
Unique: false,
Columns: []*schema.Column{SoraCacheFilesColumns[4]},
},
},
}
// SoraTasksColumns holds the columns for the "sora_tasks" table.
SoraTasksColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "task_id", Type: field.TypeString, Unique: true, Size: 120},
{Name: "account_id", Type: field.TypeInt64},
{Name: "model", Type: field.TypeString, Size: 120},
{Name: "prompt", Type: field.TypeString, SchemaType: map[string]string{"postgres": "text"}},
{Name: "status", Type: field.TypeString, Size: 32, Default: "processing"},
{Name: "progress", Type: field.TypeFloat64, Default: 0},
{Name: "result_urls", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}},
{Name: "error_message", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"postgres": "text"}},
{Name: "retry_count", Type: field.TypeInt, Default: 0},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "completed_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
}
// SoraTasksTable holds the schema information for the "sora_tasks" table.
SoraTasksTable = &schema.Table{
Name: "sora_tasks",
Columns: SoraTasksColumns,
PrimaryKey: []*schema.Column{SoraTasksColumns[0]},
Indexes: []*schema.Index{
{
Name: "soratask_account_id",
Unique: false,
Columns: []*schema.Column{SoraTasksColumns[2]},
},
{
Name: "soratask_status",
Unique: false,
Columns: []*schema.Column{SoraTasksColumns[5]},
},
},
}
// SoraUsageStatsColumns holds the columns for the "sora_usage_stats" table.
SoraUsageStatsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "account_id", Type: field.TypeInt64},
{Name: "image_count", Type: field.TypeInt, Default: 0},
{Name: "video_count", Type: field.TypeInt, Default: 0},
{Name: "error_count", Type: field.TypeInt, Default: 0},
{Name: "last_error_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "today_image_count", Type: field.TypeInt, Default: 0},
{Name: "today_video_count", Type: field.TypeInt, Default: 0},
{Name: "today_error_count", Type: field.TypeInt, Default: 0},
{Name: "today_date", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"postgres": "date"}},
{Name: "consecutive_error_count", Type: field.TypeInt, Default: 0},
}
// SoraUsageStatsTable holds the schema information for the "sora_usage_stats" table.
SoraUsageStatsTable = &schema.Table{
Name: "sora_usage_stats",
Columns: SoraUsageStatsColumns,
PrimaryKey: []*schema.Column{SoraUsageStatsColumns[0]},
Indexes: []*schema.Index{
{
Name: "sorausagestat_account_id",
Unique: true,
Columns: []*schema.Column{SoraUsageStatsColumns[3]},
},
{
Name: "sorausagestat_today_date",
Unique: false,
Columns: []*schema.Column{SoraUsageStatsColumns[11]},
},
},
}
// UsageCleanupTasksColumns holds the columns for the "usage_cleanup_tasks" table.
UsageCleanupTasksColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
@@ -843,6 +1009,10 @@ var (
ProxiesTable,
RedeemCodesTable,
SettingsTable,
SoraAccountsTable,
SoraCacheFilesTable,
SoraTasksTable,
SoraUsageStatsTable,
UsageCleanupTasksTable,
UsageLogsTable,
UsersTable,
@@ -890,6 +1060,18 @@ func init() {
SettingsTable.Annotation = &entsql.Annotation{
Table: "settings",
}
SoraAccountsTable.Annotation = &entsql.Annotation{
Table: "sora_accounts",
}
SoraCacheFilesTable.Annotation = &entsql.Annotation{
Table: "sora_cache_files",
}
SoraTasksTable.Annotation = &entsql.Annotation{
Table: "sora_tasks",
}
SoraUsageStatsTable.Annotation = &entsql.Annotation{
Table: "sora_usage_stats",
}
UsageCleanupTasksTable.Annotation = &entsql.Annotation{
Table: "usage_cleanup_tasks",
}

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,18 @@ type RedeemCode func(*sql.Selector)
// Setting is the predicate function for setting builders.
type Setting func(*sql.Selector)
// SoraAccount is the predicate function for soraaccount builders.
type SoraAccount func(*sql.Selector)
// SoraCacheFile is the predicate function for soracachefile builders.
type SoraCacheFile func(*sql.Selector)
// SoraTask is the predicate function for soratask builders.
type SoraTask func(*sql.Selector)
// SoraUsageStat is the predicate function for sorausagestat builders.
type SoraUsageStat func(*sql.Selector)
// UsageCleanupTask is the predicate function for usagecleanuptask builders.
type UsageCleanupTask func(*sql.Selector)

View File

@@ -15,6 +15,10 @@ import (
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
"github.com/Wei-Shaw/sub2api/ent/schema"
"github.com/Wei-Shaw/sub2api/ent/setting"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
"github.com/Wei-Shaw/sub2api/ent/soratask"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
"github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
"github.com/Wei-Shaw/sub2api/ent/usagelog"
"github.com/Wei-Shaw/sub2api/ent/user"
@@ -496,6 +500,150 @@ func init() {
setting.DefaultUpdatedAt = settingDescUpdatedAt.Default.(func() time.Time)
// setting.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
setting.UpdateDefaultUpdatedAt = settingDescUpdatedAt.UpdateDefault.(func() time.Time)
soraaccountMixin := schema.SoraAccount{}.Mixin()
soraaccountMixinFields0 := soraaccountMixin[0].Fields()
_ = soraaccountMixinFields0
soraaccountFields := schema.SoraAccount{}.Fields()
_ = soraaccountFields
// soraaccountDescCreatedAt is the schema descriptor for created_at field.
soraaccountDescCreatedAt := soraaccountMixinFields0[0].Descriptor()
// soraaccount.DefaultCreatedAt holds the default value on creation for the created_at field.
soraaccount.DefaultCreatedAt = soraaccountDescCreatedAt.Default.(func() time.Time)
// soraaccountDescUpdatedAt is the schema descriptor for updated_at field.
soraaccountDescUpdatedAt := soraaccountMixinFields0[1].Descriptor()
// soraaccount.DefaultUpdatedAt holds the default value on creation for the updated_at field.
soraaccount.DefaultUpdatedAt = soraaccountDescUpdatedAt.Default.(func() time.Time)
// soraaccount.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
soraaccount.UpdateDefaultUpdatedAt = soraaccountDescUpdatedAt.UpdateDefault.(func() time.Time)
// soraaccountDescUseCount is the schema descriptor for use_count field.
soraaccountDescUseCount := soraaccountFields[8].Descriptor()
// soraaccount.DefaultUseCount holds the default value on creation for the use_count field.
soraaccount.DefaultUseCount = soraaccountDescUseCount.Default.(int)
// soraaccountDescSoraSupported is the schema descriptor for sora_supported field.
soraaccountDescSoraSupported := soraaccountFields[12].Descriptor()
// soraaccount.DefaultSoraSupported holds the default value on creation for the sora_supported field.
soraaccount.DefaultSoraSupported = soraaccountDescSoraSupported.Default.(bool)
// soraaccountDescSoraRedeemedCount is the schema descriptor for sora_redeemed_count field.
soraaccountDescSoraRedeemedCount := soraaccountFields[14].Descriptor()
// soraaccount.DefaultSoraRedeemedCount holds the default value on creation for the sora_redeemed_count field.
soraaccount.DefaultSoraRedeemedCount = soraaccountDescSoraRedeemedCount.Default.(int)
// soraaccountDescSoraRemainingCount is the schema descriptor for sora_remaining_count field.
soraaccountDescSoraRemainingCount := soraaccountFields[15].Descriptor()
// soraaccount.DefaultSoraRemainingCount holds the default value on creation for the sora_remaining_count field.
soraaccount.DefaultSoraRemainingCount = soraaccountDescSoraRemainingCount.Default.(int)
// soraaccountDescSoraTotalCount is the schema descriptor for sora_total_count field.
soraaccountDescSoraTotalCount := soraaccountFields[16].Descriptor()
// soraaccount.DefaultSoraTotalCount holds the default value on creation for the sora_total_count field.
soraaccount.DefaultSoraTotalCount = soraaccountDescSoraTotalCount.Default.(int)
// soraaccountDescImageEnabled is the schema descriptor for image_enabled field.
soraaccountDescImageEnabled := soraaccountFields[19].Descriptor()
// soraaccount.DefaultImageEnabled holds the default value on creation for the image_enabled field.
soraaccount.DefaultImageEnabled = soraaccountDescImageEnabled.Default.(bool)
// soraaccountDescVideoEnabled is the schema descriptor for video_enabled field.
soraaccountDescVideoEnabled := soraaccountFields[20].Descriptor()
// soraaccount.DefaultVideoEnabled holds the default value on creation for the video_enabled field.
soraaccount.DefaultVideoEnabled = soraaccountDescVideoEnabled.Default.(bool)
// soraaccountDescImageConcurrency is the schema descriptor for image_concurrency field.
soraaccountDescImageConcurrency := soraaccountFields[21].Descriptor()
// soraaccount.DefaultImageConcurrency holds the default value on creation for the image_concurrency field.
soraaccount.DefaultImageConcurrency = soraaccountDescImageConcurrency.Default.(int)
// soraaccountDescVideoConcurrency is the schema descriptor for video_concurrency field.
soraaccountDescVideoConcurrency := soraaccountFields[22].Descriptor()
// soraaccount.DefaultVideoConcurrency holds the default value on creation for the video_concurrency field.
soraaccount.DefaultVideoConcurrency = soraaccountDescVideoConcurrency.Default.(int)
// soraaccountDescIsExpired is the schema descriptor for is_expired field.
soraaccountDescIsExpired := soraaccountFields[23].Descriptor()
// soraaccount.DefaultIsExpired holds the default value on creation for the is_expired field.
soraaccount.DefaultIsExpired = soraaccountDescIsExpired.Default.(bool)
soracachefileFields := schema.SoraCacheFile{}.Fields()
_ = soracachefileFields
// soracachefileDescTaskID is the schema descriptor for task_id field.
soracachefileDescTaskID := soracachefileFields[0].Descriptor()
// soracachefile.TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
soracachefile.TaskIDValidator = soracachefileDescTaskID.Validators[0].(func(string) error)
// soracachefileDescMediaType is the schema descriptor for media_type field.
soracachefileDescMediaType := soracachefileFields[3].Descriptor()
// soracachefile.MediaTypeValidator is a validator for the "media_type" field. It is called by the builders before save.
soracachefile.MediaTypeValidator = soracachefileDescMediaType.Validators[0].(func(string) error)
// soracachefileDescSizeBytes is the schema descriptor for size_bytes field.
soracachefileDescSizeBytes := soracachefileFields[7].Descriptor()
// soracachefile.DefaultSizeBytes holds the default value on creation for the size_bytes field.
soracachefile.DefaultSizeBytes = soracachefileDescSizeBytes.Default.(int64)
// soracachefileDescCreatedAt is the schema descriptor for created_at field.
soracachefileDescCreatedAt := soracachefileFields[8].Descriptor()
// soracachefile.DefaultCreatedAt holds the default value on creation for the created_at field.
soracachefile.DefaultCreatedAt = soracachefileDescCreatedAt.Default.(func() time.Time)
sorataskFields := schema.SoraTask{}.Fields()
_ = sorataskFields
// sorataskDescTaskID is the schema descriptor for task_id field.
sorataskDescTaskID := sorataskFields[0].Descriptor()
// soratask.TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
soratask.TaskIDValidator = sorataskDescTaskID.Validators[0].(func(string) error)
// sorataskDescModel is the schema descriptor for model field.
sorataskDescModel := sorataskFields[2].Descriptor()
// soratask.ModelValidator is a validator for the "model" field. It is called by the builders before save.
soratask.ModelValidator = sorataskDescModel.Validators[0].(func(string) error)
// sorataskDescStatus is the schema descriptor for status field.
sorataskDescStatus := sorataskFields[4].Descriptor()
// soratask.DefaultStatus holds the default value on creation for the status field.
soratask.DefaultStatus = sorataskDescStatus.Default.(string)
// soratask.StatusValidator is a validator for the "status" field. It is called by the builders before save.
soratask.StatusValidator = sorataskDescStatus.Validators[0].(func(string) error)
// sorataskDescProgress is the schema descriptor for progress field.
sorataskDescProgress := sorataskFields[5].Descriptor()
// soratask.DefaultProgress holds the default value on creation for the progress field.
soratask.DefaultProgress = sorataskDescProgress.Default.(float64)
// sorataskDescRetryCount is the schema descriptor for retry_count field.
sorataskDescRetryCount := sorataskFields[8].Descriptor()
// soratask.DefaultRetryCount holds the default value on creation for the retry_count field.
soratask.DefaultRetryCount = sorataskDescRetryCount.Default.(int)
// sorataskDescCreatedAt is the schema descriptor for created_at field.
sorataskDescCreatedAt := sorataskFields[9].Descriptor()
// soratask.DefaultCreatedAt holds the default value on creation for the created_at field.
soratask.DefaultCreatedAt = sorataskDescCreatedAt.Default.(func() time.Time)
sorausagestatMixin := schema.SoraUsageStat{}.Mixin()
sorausagestatMixinFields0 := sorausagestatMixin[0].Fields()
_ = sorausagestatMixinFields0
sorausagestatFields := schema.SoraUsageStat{}.Fields()
_ = sorausagestatFields
// sorausagestatDescCreatedAt is the schema descriptor for created_at field.
sorausagestatDescCreatedAt := sorausagestatMixinFields0[0].Descriptor()
// sorausagestat.DefaultCreatedAt holds the default value on creation for the created_at field.
sorausagestat.DefaultCreatedAt = sorausagestatDescCreatedAt.Default.(func() time.Time)
// sorausagestatDescUpdatedAt is the schema descriptor for updated_at field.
sorausagestatDescUpdatedAt := sorausagestatMixinFields0[1].Descriptor()
// sorausagestat.DefaultUpdatedAt holds the default value on creation for the updated_at field.
sorausagestat.DefaultUpdatedAt = sorausagestatDescUpdatedAt.Default.(func() time.Time)
// sorausagestat.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
sorausagestat.UpdateDefaultUpdatedAt = sorausagestatDescUpdatedAt.UpdateDefault.(func() time.Time)
// sorausagestatDescImageCount is the schema descriptor for image_count field.
sorausagestatDescImageCount := sorausagestatFields[1].Descriptor()
// sorausagestat.DefaultImageCount holds the default value on creation for the image_count field.
sorausagestat.DefaultImageCount = sorausagestatDescImageCount.Default.(int)
// sorausagestatDescVideoCount is the schema descriptor for video_count field.
sorausagestatDescVideoCount := sorausagestatFields[2].Descriptor()
// sorausagestat.DefaultVideoCount holds the default value on creation for the video_count field.
sorausagestat.DefaultVideoCount = sorausagestatDescVideoCount.Default.(int)
// sorausagestatDescErrorCount is the schema descriptor for error_count field.
sorausagestatDescErrorCount := sorausagestatFields[3].Descriptor()
// sorausagestat.DefaultErrorCount holds the default value on creation for the error_count field.
sorausagestat.DefaultErrorCount = sorausagestatDescErrorCount.Default.(int)
// sorausagestatDescTodayImageCount is the schema descriptor for today_image_count field.
sorausagestatDescTodayImageCount := sorausagestatFields[5].Descriptor()
// sorausagestat.DefaultTodayImageCount holds the default value on creation for the today_image_count field.
sorausagestat.DefaultTodayImageCount = sorausagestatDescTodayImageCount.Default.(int)
// sorausagestatDescTodayVideoCount is the schema descriptor for today_video_count field.
sorausagestatDescTodayVideoCount := sorausagestatFields[6].Descriptor()
// sorausagestat.DefaultTodayVideoCount holds the default value on creation for the today_video_count field.
sorausagestat.DefaultTodayVideoCount = sorausagestatDescTodayVideoCount.Default.(int)
// sorausagestatDescTodayErrorCount is the schema descriptor for today_error_count field.
sorausagestatDescTodayErrorCount := sorausagestatFields[7].Descriptor()
// sorausagestat.DefaultTodayErrorCount holds the default value on creation for the today_error_count field.
sorausagestat.DefaultTodayErrorCount = sorausagestatDescTodayErrorCount.Default.(int)
// sorausagestatDescConsecutiveErrorCount is the schema descriptor for consecutive_error_count field.
sorausagestatDescConsecutiveErrorCount := sorausagestatFields[9].Descriptor()
// sorausagestat.DefaultConsecutiveErrorCount holds the default value on creation for the consecutive_error_count field.
sorausagestat.DefaultConsecutiveErrorCount = sorausagestatDescConsecutiveErrorCount.Default.(int)
usagecleanuptaskMixin := schema.UsageCleanupTask{}.Mixin()
usagecleanuptaskMixinFields0 := usagecleanuptaskMixin[0].Fields()
_ = usagecleanuptaskMixinFields0

View File

@@ -0,0 +1,115 @@
// Package schema 定义 Ent ORM 的数据库 schema。
// 每个文件对应一个数据库实体(表),定义其字段、边(关联)和索引。
package schema
import (
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// SoraAccount 定义 Sora 账号扩展表。
type SoraAccount struct {
ent.Schema
}
// Annotations 返回 schema 的注解配置。
func (SoraAccount) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sora_accounts"},
}
}
// Mixin 返回该 schema 使用的混入组件。
func (SoraAccount) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.TimeMixin{},
}
}
// Fields 定义 SoraAccount 的字段。
func (SoraAccount) Fields() []ent.Field {
return []ent.Field{
field.Int64("account_id").
Comment("关联 accounts 表的 ID"),
field.String("access_token").
Optional().
Nillable(),
field.String("session_token").
Optional().
Nillable(),
field.String("refresh_token").
Optional().
Nillable(),
field.String("client_id").
Optional().
Nillable(),
field.String("email").
Optional().
Nillable(),
field.String("username").
Optional().
Nillable(),
field.String("remark").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.Int("use_count").
Default(0),
field.String("plan_type").
Optional().
Nillable(),
field.String("plan_title").
Optional().
Nillable(),
field.Time("subscription_end").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
field.Bool("sora_supported").
Default(false),
field.String("sora_invite_code").
Optional().
Nillable(),
field.Int("sora_redeemed_count").
Default(0),
field.Int("sora_remaining_count").
Default(0),
field.Int("sora_total_count").
Default(0),
field.Time("sora_cooldown_until").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
field.Time("cooled_until").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
field.Bool("image_enabled").
Default(true),
field.Bool("video_enabled").
Default(true),
field.Int("image_concurrency").
Default(-1),
field.Int("video_concurrency").
Default(-1),
field.Bool("is_expired").
Default(false),
}
}
// Indexes 定义索引。
func (SoraAccount) Indexes() []ent.Index {
return []ent.Index{
index.Fields("account_id").Unique(),
index.Fields("plan_type"),
index.Fields("sora_supported"),
index.Fields("image_enabled"),
index.Fields("video_enabled"),
}
}

View File

@@ -0,0 +1,60 @@
// Package schema 定义 Ent ORM 的数据库 schema。
// 每个文件对应一个数据库实体(表),定义其字段、边(关联)和索引。
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// SoraCacheFile 定义 Sora 缓存文件表。
type SoraCacheFile struct {
ent.Schema
}
// Annotations 返回 schema 的注解配置。
func (SoraCacheFile) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sora_cache_files"},
}
}
// Fields 定义 SoraCacheFile 的字段。
func (SoraCacheFile) Fields() []ent.Field {
return []ent.Field{
field.String("task_id").
MaxLen(120).
Optional().
Nillable(),
field.Int64("account_id"),
field.Int64("user_id"),
field.String("media_type").
MaxLen(32),
field.String("original_url").
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.String("cache_path").
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.String("cache_url").
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.Int64("size_bytes").
Default(0),
field.Time("created_at").
Default(time.Now).
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
}
}
// Indexes 定义索引。
func (SoraCacheFile) Indexes() []ent.Index {
return []ent.Index{
index.Fields("account_id"),
index.Fields("user_id"),
index.Fields("media_type"),
}
}

View File

@@ -0,0 +1,70 @@
// Package schema 定义 Ent ORM 的数据库 schema。
// 每个文件对应一个数据库实体(表),定义其字段、边(关联)和索引。
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// SoraTask 定义 Sora 任务记录表。
type SoraTask struct {
ent.Schema
}
// Annotations 返回 schema 的注解配置。
func (SoraTask) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sora_tasks"},
}
}
// Fields 定义 SoraTask 的字段。
func (SoraTask) Fields() []ent.Field {
return []ent.Field{
field.String("task_id").
MaxLen(120).
Unique(),
field.Int64("account_id"),
field.String("model").
MaxLen(120),
field.String("prompt").
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.String("status").
MaxLen(32).
Default("processing"),
field.Float("progress").
Default(0),
field.String("result_urls").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.String("error_message").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "text"}),
field.Int("retry_count").
Default(0),
field.Time("created_at").
Default(time.Now).
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
field.Time("completed_at").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
}
}
// Indexes 定义索引。
func (SoraTask) Indexes() []ent.Index {
return []ent.Index{
index.Fields("account_id"),
index.Fields("status"),
}
}

View File

@@ -0,0 +1,71 @@
// Package schema 定义 Ent ORM 的数据库 schema。
// 每个文件对应一个数据库实体(表),定义其字段、边(关联)和索引。
package schema
import (
"github.com/Wei-Shaw/sub2api/ent/schema/mixins"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// SoraUsageStat 定义 Sora 调用统计表。
type SoraUsageStat struct {
ent.Schema
}
// Annotations 返回 schema 的注解配置。
func (SoraUsageStat) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sora_usage_stats"},
}
}
// Mixin 返回该 schema 使用的混入组件。
func (SoraUsageStat) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.TimeMixin{},
}
}
// Fields 定义 SoraUsageStat 的字段。
func (SoraUsageStat) Fields() []ent.Field {
return []ent.Field{
field.Int64("account_id").
Comment("关联 accounts 表的 ID"),
field.Int("image_count").
Default(0),
field.Int("video_count").
Default(0),
field.Int("error_count").
Default(0),
field.Time("last_error_at").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "timestamptz"}),
field.Int("today_image_count").
Default(0),
field.Int("today_video_count").
Default(0),
field.Int("today_error_count").
Default(0),
field.Time("today_date").
Optional().
Nillable().
SchemaType(map[string]string{dialect.Postgres: "date"}),
field.Int("consecutive_error_count").
Default(0),
}
}
// Indexes 定义索引。
func (SoraUsageStat) Indexes() []ent.Index {
return []ent.Index{
index.Fields("account_id").Unique(),
index.Fields("today_date"),
}
}

422
backend/ent/soraaccount.go Normal file
View File

@@ -0,0 +1,422 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
)
// SoraAccount is the model entity for the SoraAccount schema.
type SoraAccount struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 关联 accounts 表的 ID
AccountID int64 `json:"account_id,omitempty"`
// AccessToken holds the value of the "access_token" field.
AccessToken *string `json:"access_token,omitempty"`
// SessionToken holds the value of the "session_token" field.
SessionToken *string `json:"session_token,omitempty"`
// RefreshToken holds the value of the "refresh_token" field.
RefreshToken *string `json:"refresh_token,omitempty"`
// ClientID holds the value of the "client_id" field.
ClientID *string `json:"client_id,omitempty"`
// Email holds the value of the "email" field.
Email *string `json:"email,omitempty"`
// Username holds the value of the "username" field.
Username *string `json:"username,omitempty"`
// Remark holds the value of the "remark" field.
Remark *string `json:"remark,omitempty"`
// UseCount holds the value of the "use_count" field.
UseCount int `json:"use_count,omitempty"`
// PlanType holds the value of the "plan_type" field.
PlanType *string `json:"plan_type,omitempty"`
// PlanTitle holds the value of the "plan_title" field.
PlanTitle *string `json:"plan_title,omitempty"`
// SubscriptionEnd holds the value of the "subscription_end" field.
SubscriptionEnd *time.Time `json:"subscription_end,omitempty"`
// SoraSupported holds the value of the "sora_supported" field.
SoraSupported bool `json:"sora_supported,omitempty"`
// SoraInviteCode holds the value of the "sora_invite_code" field.
SoraInviteCode *string `json:"sora_invite_code,omitempty"`
// SoraRedeemedCount holds the value of the "sora_redeemed_count" field.
SoraRedeemedCount int `json:"sora_redeemed_count,omitempty"`
// SoraRemainingCount holds the value of the "sora_remaining_count" field.
SoraRemainingCount int `json:"sora_remaining_count,omitempty"`
// SoraTotalCount holds the value of the "sora_total_count" field.
SoraTotalCount int `json:"sora_total_count,omitempty"`
// SoraCooldownUntil holds the value of the "sora_cooldown_until" field.
SoraCooldownUntil *time.Time `json:"sora_cooldown_until,omitempty"`
// CooledUntil holds the value of the "cooled_until" field.
CooledUntil *time.Time `json:"cooled_until,omitempty"`
// ImageEnabled holds the value of the "image_enabled" field.
ImageEnabled bool `json:"image_enabled,omitempty"`
// VideoEnabled holds the value of the "video_enabled" field.
VideoEnabled bool `json:"video_enabled,omitempty"`
// ImageConcurrency holds the value of the "image_concurrency" field.
ImageConcurrency int `json:"image_concurrency,omitempty"`
// VideoConcurrency holds the value of the "video_concurrency" field.
VideoConcurrency int `json:"video_concurrency,omitempty"`
// IsExpired holds the value of the "is_expired" field.
IsExpired bool `json:"is_expired,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraAccount) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case soraaccount.FieldSoraSupported, soraaccount.FieldImageEnabled, soraaccount.FieldVideoEnabled, soraaccount.FieldIsExpired:
values[i] = new(sql.NullBool)
case soraaccount.FieldID, soraaccount.FieldAccountID, soraaccount.FieldUseCount, soraaccount.FieldSoraRedeemedCount, soraaccount.FieldSoraRemainingCount, soraaccount.FieldSoraTotalCount, soraaccount.FieldImageConcurrency, soraaccount.FieldVideoConcurrency:
values[i] = new(sql.NullInt64)
case soraaccount.FieldAccessToken, soraaccount.FieldSessionToken, soraaccount.FieldRefreshToken, soraaccount.FieldClientID, soraaccount.FieldEmail, soraaccount.FieldUsername, soraaccount.FieldRemark, soraaccount.FieldPlanType, soraaccount.FieldPlanTitle, soraaccount.FieldSoraInviteCode:
values[i] = new(sql.NullString)
case soraaccount.FieldCreatedAt, soraaccount.FieldUpdatedAt, soraaccount.FieldSubscriptionEnd, soraaccount.FieldSoraCooldownUntil, soraaccount.FieldCooledUntil:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraAccount fields.
func (_m *SoraAccount) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case soraaccount.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case soraaccount.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case soraaccount.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case soraaccount.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case soraaccount.FieldAccessToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field access_token", values[i])
} else if value.Valid {
_m.AccessToken = new(string)
*_m.AccessToken = value.String
}
case soraaccount.FieldSessionToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field session_token", values[i])
} else if value.Valid {
_m.SessionToken = new(string)
*_m.SessionToken = value.String
}
case soraaccount.FieldRefreshToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field refresh_token", values[i])
} else if value.Valid {
_m.RefreshToken = new(string)
*_m.RefreshToken = value.String
}
case soraaccount.FieldClientID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field client_id", values[i])
} else if value.Valid {
_m.ClientID = new(string)
*_m.ClientID = value.String
}
case soraaccount.FieldEmail:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field email", values[i])
} else if value.Valid {
_m.Email = new(string)
*_m.Email = value.String
}
case soraaccount.FieldUsername:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field username", values[i])
} else if value.Valid {
_m.Username = new(string)
*_m.Username = value.String
}
case soraaccount.FieldRemark:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field remark", values[i])
} else if value.Valid {
_m.Remark = new(string)
*_m.Remark = value.String
}
case soraaccount.FieldUseCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field use_count", values[i])
} else if value.Valid {
_m.UseCount = int(value.Int64)
}
case soraaccount.FieldPlanType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field plan_type", values[i])
} else if value.Valid {
_m.PlanType = new(string)
*_m.PlanType = value.String
}
case soraaccount.FieldPlanTitle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field plan_title", values[i])
} else if value.Valid {
_m.PlanTitle = new(string)
*_m.PlanTitle = value.String
}
case soraaccount.FieldSubscriptionEnd:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field subscription_end", values[i])
} else if value.Valid {
_m.SubscriptionEnd = new(time.Time)
*_m.SubscriptionEnd = value.Time
}
case soraaccount.FieldSoraSupported:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field sora_supported", values[i])
} else if value.Valid {
_m.SoraSupported = value.Bool
}
case soraaccount.FieldSoraInviteCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sora_invite_code", values[i])
} else if value.Valid {
_m.SoraInviteCode = new(string)
*_m.SoraInviteCode = value.String
}
case soraaccount.FieldSoraRedeemedCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sora_redeemed_count", values[i])
} else if value.Valid {
_m.SoraRedeemedCount = int(value.Int64)
}
case soraaccount.FieldSoraRemainingCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sora_remaining_count", values[i])
} else if value.Valid {
_m.SoraRemainingCount = int(value.Int64)
}
case soraaccount.FieldSoraTotalCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sora_total_count", values[i])
} else if value.Valid {
_m.SoraTotalCount = int(value.Int64)
}
case soraaccount.FieldSoraCooldownUntil:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field sora_cooldown_until", values[i])
} else if value.Valid {
_m.SoraCooldownUntil = new(time.Time)
*_m.SoraCooldownUntil = value.Time
}
case soraaccount.FieldCooledUntil:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field cooled_until", values[i])
} else if value.Valid {
_m.CooledUntil = new(time.Time)
*_m.CooledUntil = value.Time
}
case soraaccount.FieldImageEnabled:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field image_enabled", values[i])
} else if value.Valid {
_m.ImageEnabled = value.Bool
}
case soraaccount.FieldVideoEnabled:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field video_enabled", values[i])
} else if value.Valid {
_m.VideoEnabled = value.Bool
}
case soraaccount.FieldImageConcurrency:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field image_concurrency", values[i])
} else if value.Valid {
_m.ImageConcurrency = int(value.Int64)
}
case soraaccount.FieldVideoConcurrency:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field video_concurrency", values[i])
} else if value.Valid {
_m.VideoConcurrency = int(value.Int64)
}
case soraaccount.FieldIsExpired:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_expired", values[i])
} else if value.Valid {
_m.IsExpired = value.Bool
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraAccount.
// This includes values selected through modifiers, order, etc.
func (_m *SoraAccount) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraAccount.
// Note that you need to call SoraAccount.Unwrap() before calling this method if this SoraAccount
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraAccount) Update() *SoraAccountUpdateOne {
return NewSoraAccountClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraAccount entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraAccount) Unwrap() *SoraAccount {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraAccount is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraAccount) String() string {
var builder strings.Builder
builder.WriteString("SoraAccount(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
if v := _m.AccessToken; v != nil {
builder.WriteString("access_token=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.SessionToken; v != nil {
builder.WriteString("session_token=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.RefreshToken; v != nil {
builder.WriteString("refresh_token=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.ClientID; v != nil {
builder.WriteString("client_id=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.Email; v != nil {
builder.WriteString("email=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.Username; v != nil {
builder.WriteString("username=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.Remark; v != nil {
builder.WriteString("remark=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("use_count=")
builder.WriteString(fmt.Sprintf("%v", _m.UseCount))
builder.WriteString(", ")
if v := _m.PlanType; v != nil {
builder.WriteString("plan_type=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.PlanTitle; v != nil {
builder.WriteString("plan_title=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.SubscriptionEnd; v != nil {
builder.WriteString("subscription_end=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("sora_supported=")
builder.WriteString(fmt.Sprintf("%v", _m.SoraSupported))
builder.WriteString(", ")
if v := _m.SoraInviteCode; v != nil {
builder.WriteString("sora_invite_code=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("sora_redeemed_count=")
builder.WriteString(fmt.Sprintf("%v", _m.SoraRedeemedCount))
builder.WriteString(", ")
builder.WriteString("sora_remaining_count=")
builder.WriteString(fmt.Sprintf("%v", _m.SoraRemainingCount))
builder.WriteString(", ")
builder.WriteString("sora_total_count=")
builder.WriteString(fmt.Sprintf("%v", _m.SoraTotalCount))
builder.WriteString(", ")
if v := _m.SoraCooldownUntil; v != nil {
builder.WriteString("sora_cooldown_until=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.CooledUntil; v != nil {
builder.WriteString("cooled_until=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("image_enabled=")
builder.WriteString(fmt.Sprintf("%v", _m.ImageEnabled))
builder.WriteString(", ")
builder.WriteString("video_enabled=")
builder.WriteString(fmt.Sprintf("%v", _m.VideoEnabled))
builder.WriteString(", ")
builder.WriteString("image_concurrency=")
builder.WriteString(fmt.Sprintf("%v", _m.ImageConcurrency))
builder.WriteString(", ")
builder.WriteString("video_concurrency=")
builder.WriteString(fmt.Sprintf("%v", _m.VideoConcurrency))
builder.WriteString(", ")
builder.WriteString("is_expired=")
builder.WriteString(fmt.Sprintf("%v", _m.IsExpired))
builder.WriteByte(')')
return builder.String()
}
// SoraAccounts is a parsable slice of SoraAccount.
type SoraAccounts []*SoraAccount

View File

@@ -0,0 +1,278 @@
// Code generated by ent, DO NOT EDIT.
package soraaccount
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the soraaccount type in the database.
Label = "sora_account"
// 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"
// FieldAccessToken holds the string denoting the access_token field in the database.
FieldAccessToken = "access_token"
// FieldSessionToken holds the string denoting the session_token field in the database.
FieldSessionToken = "session_token"
// FieldRefreshToken holds the string denoting the refresh_token field in the database.
FieldRefreshToken = "refresh_token"
// FieldClientID holds the string denoting the client_id field in the database.
FieldClientID = "client_id"
// FieldEmail holds the string denoting the email field in the database.
FieldEmail = "email"
// FieldUsername holds the string denoting the username field in the database.
FieldUsername = "username"
// FieldRemark holds the string denoting the remark field in the database.
FieldRemark = "remark"
// FieldUseCount holds the string denoting the use_count field in the database.
FieldUseCount = "use_count"
// FieldPlanType holds the string denoting the plan_type field in the database.
FieldPlanType = "plan_type"
// FieldPlanTitle holds the string denoting the plan_title field in the database.
FieldPlanTitle = "plan_title"
// FieldSubscriptionEnd holds the string denoting the subscription_end field in the database.
FieldSubscriptionEnd = "subscription_end"
// FieldSoraSupported holds the string denoting the sora_supported field in the database.
FieldSoraSupported = "sora_supported"
// FieldSoraInviteCode holds the string denoting the sora_invite_code field in the database.
FieldSoraInviteCode = "sora_invite_code"
// FieldSoraRedeemedCount holds the string denoting the sora_redeemed_count field in the database.
FieldSoraRedeemedCount = "sora_redeemed_count"
// FieldSoraRemainingCount holds the string denoting the sora_remaining_count field in the database.
FieldSoraRemainingCount = "sora_remaining_count"
// FieldSoraTotalCount holds the string denoting the sora_total_count field in the database.
FieldSoraTotalCount = "sora_total_count"
// FieldSoraCooldownUntil holds the string denoting the sora_cooldown_until field in the database.
FieldSoraCooldownUntil = "sora_cooldown_until"
// FieldCooledUntil holds the string denoting the cooled_until field in the database.
FieldCooledUntil = "cooled_until"
// FieldImageEnabled holds the string denoting the image_enabled field in the database.
FieldImageEnabled = "image_enabled"
// FieldVideoEnabled holds the string denoting the video_enabled field in the database.
FieldVideoEnabled = "video_enabled"
// FieldImageConcurrency holds the string denoting the image_concurrency field in the database.
FieldImageConcurrency = "image_concurrency"
// FieldVideoConcurrency holds the string denoting the video_concurrency field in the database.
FieldVideoConcurrency = "video_concurrency"
// FieldIsExpired holds the string denoting the is_expired field in the database.
FieldIsExpired = "is_expired"
// Table holds the table name of the soraaccount in the database.
Table = "sora_accounts"
)
// Columns holds all SQL columns for soraaccount fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldAccountID,
FieldAccessToken,
FieldSessionToken,
FieldRefreshToken,
FieldClientID,
FieldEmail,
FieldUsername,
FieldRemark,
FieldUseCount,
FieldPlanType,
FieldPlanTitle,
FieldSubscriptionEnd,
FieldSoraSupported,
FieldSoraInviteCode,
FieldSoraRedeemedCount,
FieldSoraRemainingCount,
FieldSoraTotalCount,
FieldSoraCooldownUntil,
FieldCooledUntil,
FieldImageEnabled,
FieldVideoEnabled,
FieldImageConcurrency,
FieldVideoConcurrency,
FieldIsExpired,
}
// 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
// DefaultUseCount holds the default value on creation for the "use_count" field.
DefaultUseCount int
// DefaultSoraSupported holds the default value on creation for the "sora_supported" field.
DefaultSoraSupported bool
// DefaultSoraRedeemedCount holds the default value on creation for the "sora_redeemed_count" field.
DefaultSoraRedeemedCount int
// DefaultSoraRemainingCount holds the default value on creation for the "sora_remaining_count" field.
DefaultSoraRemainingCount int
// DefaultSoraTotalCount holds the default value on creation for the "sora_total_count" field.
DefaultSoraTotalCount int
// DefaultImageEnabled holds the default value on creation for the "image_enabled" field.
DefaultImageEnabled bool
// DefaultVideoEnabled holds the default value on creation for the "video_enabled" field.
DefaultVideoEnabled bool
// DefaultImageConcurrency holds the default value on creation for the "image_concurrency" field.
DefaultImageConcurrency int
// DefaultVideoConcurrency holds the default value on creation for the "video_concurrency" field.
DefaultVideoConcurrency int
// DefaultIsExpired holds the default value on creation for the "is_expired" field.
DefaultIsExpired bool
)
// OrderOption defines the ordering options for the SoraAccount 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()
}
// ByAccessToken orders the results by the access_token field.
func ByAccessToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccessToken, opts...).ToFunc()
}
// BySessionToken orders the results by the session_token field.
func BySessionToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSessionToken, opts...).ToFunc()
}
// ByRefreshToken orders the results by the refresh_token field.
func ByRefreshToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRefreshToken, opts...).ToFunc()
}
// ByClientID orders the results by the client_id field.
func ByClientID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldClientID, opts...).ToFunc()
}
// ByEmail orders the results by the email field.
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEmail, opts...).ToFunc()
}
// ByUsername orders the results by the username field.
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUsername, opts...).ToFunc()
}
// ByRemark orders the results by the remark field.
func ByRemark(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRemark, opts...).ToFunc()
}
// ByUseCount orders the results by the use_count field.
func ByUseCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUseCount, opts...).ToFunc()
}
// ByPlanType orders the results by the plan_type field.
func ByPlanType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlanType, opts...).ToFunc()
}
// ByPlanTitle orders the results by the plan_title field.
func ByPlanTitle(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlanTitle, opts...).ToFunc()
}
// BySubscriptionEnd orders the results by the subscription_end field.
func BySubscriptionEnd(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSubscriptionEnd, opts...).ToFunc()
}
// BySoraSupported orders the results by the sora_supported field.
func BySoraSupported(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraSupported, opts...).ToFunc()
}
// BySoraInviteCode orders the results by the sora_invite_code field.
func BySoraInviteCode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraInviteCode, opts...).ToFunc()
}
// BySoraRedeemedCount orders the results by the sora_redeemed_count field.
func BySoraRedeemedCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraRedeemedCount, opts...).ToFunc()
}
// BySoraRemainingCount orders the results by the sora_remaining_count field.
func BySoraRemainingCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraRemainingCount, opts...).ToFunc()
}
// BySoraTotalCount orders the results by the sora_total_count field.
func BySoraTotalCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraTotalCount, opts...).ToFunc()
}
// BySoraCooldownUntil orders the results by the sora_cooldown_until field.
func BySoraCooldownUntil(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoraCooldownUntil, opts...).ToFunc()
}
// ByCooledUntil orders the results by the cooled_until field.
func ByCooledUntil(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCooledUntil, opts...).ToFunc()
}
// ByImageEnabled orders the results by the image_enabled field.
func ByImageEnabled(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldImageEnabled, opts...).ToFunc()
}
// ByVideoEnabled orders the results by the video_enabled field.
func ByVideoEnabled(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVideoEnabled, opts...).ToFunc()
}
// ByImageConcurrency orders the results by the image_concurrency field.
func ByImageConcurrency(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldImageConcurrency, opts...).ToFunc()
}
// ByVideoConcurrency orders the results by the video_concurrency field.
func ByVideoConcurrency(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVideoConcurrency, opts...).ToFunc()
}
// ByIsExpired orders the results by the is_expired field.
func ByIsExpired(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIsExpired, opts...).ToFunc()
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
// 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/soraaccount"
)
// SoraAccountDelete is the builder for deleting a SoraAccount entity.
type SoraAccountDelete struct {
config
hooks []Hook
mutation *SoraAccountMutation
}
// Where appends a list predicates to the SoraAccountDelete builder.
func (_d *SoraAccountDelete) Where(ps ...predicate.SoraAccount) *SoraAccountDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraAccountDelete) 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 *SoraAccountDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraAccountDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(soraaccount.Table, sqlgraph.NewFieldSpec(soraaccount.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
}
// SoraAccountDeleteOne is the builder for deleting a single SoraAccount entity.
type SoraAccountDeleteOne struct {
_d *SoraAccountDelete
}
// Where appends a list predicates to the SoraAccountDelete builder.
func (_d *SoraAccountDeleteOne) Where(ps ...predicate.SoraAccount) *SoraAccountDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraAccountDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{soraaccount.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraAccountDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,564 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"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/soraaccount"
)
// SoraAccountQuery is the builder for querying SoraAccount entities.
type SoraAccountQuery struct {
config
ctx *QueryContext
order []soraaccount.OrderOption
inters []Interceptor
predicates []predicate.SoraAccount
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraAccountQuery builder.
func (_q *SoraAccountQuery) Where(ps ...predicate.SoraAccount) *SoraAccountQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraAccountQuery) Limit(limit int) *SoraAccountQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraAccountQuery) Offset(offset int) *SoraAccountQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraAccountQuery) Unique(unique bool) *SoraAccountQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraAccountQuery) Order(o ...soraaccount.OrderOption) *SoraAccountQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraAccount entity from the query.
// Returns a *NotFoundError when no SoraAccount was found.
func (_q *SoraAccountQuery) First(ctx context.Context) (*SoraAccount, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{soraaccount.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraAccountQuery) FirstX(ctx context.Context) *SoraAccount {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraAccount ID from the query.
// Returns a *NotFoundError when no SoraAccount ID was found.
func (_q *SoraAccountQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{soraaccount.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraAccountQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraAccount entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraAccount entity is found.
// Returns a *NotFoundError when no SoraAccount entities are found.
func (_q *SoraAccountQuery) Only(ctx context.Context) (*SoraAccount, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{soraaccount.Label}
default:
return nil, &NotSingularError{soraaccount.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraAccountQuery) OnlyX(ctx context.Context) *SoraAccount {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraAccount ID in the query.
// Returns a *NotSingularError when more than one SoraAccount ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraAccountQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{soraaccount.Label}
default:
err = &NotSingularError{soraaccount.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraAccountQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraAccounts.
func (_q *SoraAccountQuery) All(ctx context.Context) ([]*SoraAccount, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraAccount, *SoraAccountQuery]()
return withInterceptors[[]*SoraAccount](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraAccountQuery) AllX(ctx context.Context) []*SoraAccount {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraAccount IDs.
func (_q *SoraAccountQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(soraaccount.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraAccountQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraAccountQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraAccountQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraAccountQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraAccountQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraAccountQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraAccountQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraAccountQuery) Clone() *SoraAccountQuery {
if _q == nil {
return nil
}
return &SoraAccountQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]soraaccount.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraAccount{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraAccount.Query().
// GroupBy(soraaccount.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraAccountQuery) GroupBy(field string, fields ...string) *SoraAccountGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraAccountGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = soraaccount.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.SoraAccount.Query().
// Select(soraaccount.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *SoraAccountQuery) Select(fields ...string) *SoraAccountSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraAccountSelect{SoraAccountQuery: _q}
sbuild.label = soraaccount.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraAccountSelect configured with the given aggregations.
func (_q *SoraAccountQuery) Aggregate(fns ...AggregateFunc) *SoraAccountSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraAccountQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !soraaccount.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraAccountQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraAccount, error) {
var (
nodes = []*SoraAccount{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraAccount).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraAccount{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraAccountQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraAccountQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(soraaccount.Table, soraaccount.Columns, sqlgraph.NewFieldSpec(soraaccount.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soraaccount.FieldID)
for i := range fields {
if fields[i] != soraaccount.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraAccountQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(soraaccount.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = soraaccount.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraAccountQuery) ForUpdate(opts ...sql.LockOption) *SoraAccountQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraAccountQuery) ForShare(opts ...sql.LockOption) *SoraAccountQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraAccountGroupBy is the group-by builder for SoraAccount entities.
type SoraAccountGroupBy struct {
selector
build *SoraAccountQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraAccountGroupBy) Aggregate(fns ...AggregateFunc) *SoraAccountGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraAccountGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraAccountQuery, *SoraAccountGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraAccountGroupBy) sqlScan(ctx context.Context, root *SoraAccountQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraAccountSelect is the builder for selecting fields of SoraAccount entities.
type SoraAccountSelect struct {
*SoraAccountQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraAccountSelect) Aggregate(fns ...AggregateFunc) *SoraAccountSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraAccountSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraAccountQuery, *SoraAccountSelect](ctx, _s.SoraAccountQuery, _s, _s.inters, v)
}
func (_s *SoraAccountSelect) sqlScan(ctx context.Context, root *SoraAccountQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,197 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFile is the model entity for the SoraCacheFile schema.
type SoraCacheFile struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// TaskID holds the value of the "task_id" field.
TaskID *string `json:"task_id,omitempty"`
// AccountID holds the value of the "account_id" field.
AccountID int64 `json:"account_id,omitempty"`
// UserID holds the value of the "user_id" field.
UserID int64 `json:"user_id,omitempty"`
// MediaType holds the value of the "media_type" field.
MediaType string `json:"media_type,omitempty"`
// OriginalURL holds the value of the "original_url" field.
OriginalURL string `json:"original_url,omitempty"`
// CachePath holds the value of the "cache_path" field.
CachePath string `json:"cache_path,omitempty"`
// CacheURL holds the value of the "cache_url" field.
CacheURL string `json:"cache_url,omitempty"`
// SizeBytes holds the value of the "size_bytes" field.
SizeBytes int64 `json:"size_bytes,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraCacheFile) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case soracachefile.FieldID, soracachefile.FieldAccountID, soracachefile.FieldUserID, soracachefile.FieldSizeBytes:
values[i] = new(sql.NullInt64)
case soracachefile.FieldTaskID, soracachefile.FieldMediaType, soracachefile.FieldOriginalURL, soracachefile.FieldCachePath, soracachefile.FieldCacheURL:
values[i] = new(sql.NullString)
case soracachefile.FieldCreatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraCacheFile fields.
func (_m *SoraCacheFile) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case soracachefile.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case soracachefile.FieldTaskID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field task_id", values[i])
} else if value.Valid {
_m.TaskID = new(string)
*_m.TaskID = value.String
}
case soracachefile.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case soracachefile.FieldUserID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
_m.UserID = value.Int64
}
case soracachefile.FieldMediaType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field media_type", values[i])
} else if value.Valid {
_m.MediaType = value.String
}
case soracachefile.FieldOriginalURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field original_url", values[i])
} else if value.Valid {
_m.OriginalURL = value.String
}
case soracachefile.FieldCachePath:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field cache_path", values[i])
} else if value.Valid {
_m.CachePath = value.String
}
case soracachefile.FieldCacheURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field cache_url", values[i])
} else if value.Valid {
_m.CacheURL = value.String
}
case soracachefile.FieldSizeBytes:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field size_bytes", values[i])
} else if value.Valid {
_m.SizeBytes = value.Int64
}
case soracachefile.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraCacheFile.
// This includes values selected through modifiers, order, etc.
func (_m *SoraCacheFile) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraCacheFile.
// Note that you need to call SoraCacheFile.Unwrap() before calling this method if this SoraCacheFile
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraCacheFile) Update() *SoraCacheFileUpdateOne {
return NewSoraCacheFileClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraCacheFile entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraCacheFile) Unwrap() *SoraCacheFile {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraCacheFile is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraCacheFile) String() string {
var builder strings.Builder
builder.WriteString("SoraCacheFile(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.TaskID; v != nil {
builder.WriteString("task_id=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
builder.WriteString(", ")
builder.WriteString("media_type=")
builder.WriteString(_m.MediaType)
builder.WriteString(", ")
builder.WriteString("original_url=")
builder.WriteString(_m.OriginalURL)
builder.WriteString(", ")
builder.WriteString("cache_path=")
builder.WriteString(_m.CachePath)
builder.WriteString(", ")
builder.WriteString("cache_url=")
builder.WriteString(_m.CacheURL)
builder.WriteString(", ")
builder.WriteString("size_bytes=")
builder.WriteString(fmt.Sprintf("%v", _m.SizeBytes))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// SoraCacheFiles is a parsable slice of SoraCacheFile.
type SoraCacheFiles []*SoraCacheFile

View File

@@ -0,0 +1,124 @@
// Code generated by ent, DO NOT EDIT.
package soracachefile
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the soracachefile type in the database.
Label = "sora_cache_file"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTaskID holds the string denoting the task_id field in the database.
FieldTaskID = "task_id"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldMediaType holds the string denoting the media_type field in the database.
FieldMediaType = "media_type"
// FieldOriginalURL holds the string denoting the original_url field in the database.
FieldOriginalURL = "original_url"
// FieldCachePath holds the string denoting the cache_path field in the database.
FieldCachePath = "cache_path"
// FieldCacheURL holds the string denoting the cache_url field in the database.
FieldCacheURL = "cache_url"
// FieldSizeBytes holds the string denoting the size_bytes field in the database.
FieldSizeBytes = "size_bytes"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// Table holds the table name of the soracachefile in the database.
Table = "sora_cache_files"
)
// Columns holds all SQL columns for soracachefile fields.
var Columns = []string{
FieldID,
FieldTaskID,
FieldAccountID,
FieldUserID,
FieldMediaType,
FieldOriginalURL,
FieldCachePath,
FieldCacheURL,
FieldSizeBytes,
FieldCreatedAt,
}
// 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 (
// TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
TaskIDValidator func(string) error
// MediaTypeValidator is a validator for the "media_type" field. It is called by the builders before save.
MediaTypeValidator func(string) error
// DefaultSizeBytes holds the default value on creation for the "size_bytes" field.
DefaultSizeBytes int64
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the SoraCacheFile 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()
}
// ByTaskID orders the results by the task_id field.
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByMediaType orders the results by the media_type field.
func ByMediaType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaType, opts...).ToFunc()
}
// ByOriginalURL orders the results by the original_url field.
func ByOriginalURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOriginalURL, opts...).ToFunc()
}
// ByCachePath orders the results by the cache_path field.
func ByCachePath(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCachePath, opts...).ToFunc()
}
// ByCacheURL orders the results by the cache_url field.
func ByCacheURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCacheURL, opts...).ToFunc()
}
// BySizeBytes orders the results by the size_bytes field.
func BySizeBytes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSizeBytes, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

View File

@@ -0,0 +1,610 @@
// Code generated by ent, DO NOT EDIT.
package soracachefile
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldID, id))
}
// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
func TaskID(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldTaskID, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldAccountID, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldUserID, v))
}
// MediaType applies equality check predicate on the "media_type" field. It's identical to MediaTypeEQ.
func MediaType(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldMediaType, v))
}
// OriginalURL applies equality check predicate on the "original_url" field. It's identical to OriginalURLEQ.
func OriginalURL(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldOriginalURL, v))
}
// CachePath applies equality check predicate on the "cache_path" field. It's identical to CachePathEQ.
func CachePath(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCachePath, v))
}
// CacheURL applies equality check predicate on the "cache_url" field. It's identical to CacheURLEQ.
func CacheURL(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCacheURL, v))
}
// SizeBytes applies equality check predicate on the "size_bytes" field. It's identical to SizeBytesEQ.
func SizeBytes(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldSizeBytes, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCreatedAt, v))
}
// TaskIDEQ applies the EQ predicate on the "task_id" field.
func TaskIDEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldTaskID, v))
}
// TaskIDNEQ applies the NEQ predicate on the "task_id" field.
func TaskIDNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldTaskID, v))
}
// TaskIDIn applies the In predicate on the "task_id" field.
func TaskIDIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldTaskID, vs...))
}
// TaskIDNotIn applies the NotIn predicate on the "task_id" field.
func TaskIDNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldTaskID, vs...))
}
// TaskIDGT applies the GT predicate on the "task_id" field.
func TaskIDGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldTaskID, v))
}
// TaskIDGTE applies the GTE predicate on the "task_id" field.
func TaskIDGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldTaskID, v))
}
// TaskIDLT applies the LT predicate on the "task_id" field.
func TaskIDLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldTaskID, v))
}
// TaskIDLTE applies the LTE predicate on the "task_id" field.
func TaskIDLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldTaskID, v))
}
// TaskIDContains applies the Contains predicate on the "task_id" field.
func TaskIDContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldTaskID, v))
}
// TaskIDHasPrefix applies the HasPrefix predicate on the "task_id" field.
func TaskIDHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldTaskID, v))
}
// TaskIDHasSuffix applies the HasSuffix predicate on the "task_id" field.
func TaskIDHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldTaskID, v))
}
// TaskIDIsNil applies the IsNil predicate on the "task_id" field.
func TaskIDIsNil() predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIsNull(FieldTaskID))
}
// TaskIDNotNil applies the NotNil predicate on the "task_id" field.
func TaskIDNotNil() predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotNull(FieldTaskID))
}
// TaskIDEqualFold applies the EqualFold predicate on the "task_id" field.
func TaskIDEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldTaskID, v))
}
// TaskIDContainsFold applies the ContainsFold predicate on the "task_id" field.
func TaskIDContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldTaskID, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldAccountID, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldUserID, v))
}
// MediaTypeEQ applies the EQ predicate on the "media_type" field.
func MediaTypeEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldMediaType, v))
}
// MediaTypeNEQ applies the NEQ predicate on the "media_type" field.
func MediaTypeNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldMediaType, v))
}
// MediaTypeIn applies the In predicate on the "media_type" field.
func MediaTypeIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldMediaType, vs...))
}
// MediaTypeNotIn applies the NotIn predicate on the "media_type" field.
func MediaTypeNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldMediaType, vs...))
}
// MediaTypeGT applies the GT predicate on the "media_type" field.
func MediaTypeGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldMediaType, v))
}
// MediaTypeGTE applies the GTE predicate on the "media_type" field.
func MediaTypeGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldMediaType, v))
}
// MediaTypeLT applies the LT predicate on the "media_type" field.
func MediaTypeLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldMediaType, v))
}
// MediaTypeLTE applies the LTE predicate on the "media_type" field.
func MediaTypeLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldMediaType, v))
}
// MediaTypeContains applies the Contains predicate on the "media_type" field.
func MediaTypeContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldMediaType, v))
}
// MediaTypeHasPrefix applies the HasPrefix predicate on the "media_type" field.
func MediaTypeHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldMediaType, v))
}
// MediaTypeHasSuffix applies the HasSuffix predicate on the "media_type" field.
func MediaTypeHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldMediaType, v))
}
// MediaTypeEqualFold applies the EqualFold predicate on the "media_type" field.
func MediaTypeEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldMediaType, v))
}
// MediaTypeContainsFold applies the ContainsFold predicate on the "media_type" field.
func MediaTypeContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldMediaType, v))
}
// OriginalURLEQ applies the EQ predicate on the "original_url" field.
func OriginalURLEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldOriginalURL, v))
}
// OriginalURLNEQ applies the NEQ predicate on the "original_url" field.
func OriginalURLNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldOriginalURL, v))
}
// OriginalURLIn applies the In predicate on the "original_url" field.
func OriginalURLIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldOriginalURL, vs...))
}
// OriginalURLNotIn applies the NotIn predicate on the "original_url" field.
func OriginalURLNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldOriginalURL, vs...))
}
// OriginalURLGT applies the GT predicate on the "original_url" field.
func OriginalURLGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldOriginalURL, v))
}
// OriginalURLGTE applies the GTE predicate on the "original_url" field.
func OriginalURLGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldOriginalURL, v))
}
// OriginalURLLT applies the LT predicate on the "original_url" field.
func OriginalURLLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldOriginalURL, v))
}
// OriginalURLLTE applies the LTE predicate on the "original_url" field.
func OriginalURLLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldOriginalURL, v))
}
// OriginalURLContains applies the Contains predicate on the "original_url" field.
func OriginalURLContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldOriginalURL, v))
}
// OriginalURLHasPrefix applies the HasPrefix predicate on the "original_url" field.
func OriginalURLHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldOriginalURL, v))
}
// OriginalURLHasSuffix applies the HasSuffix predicate on the "original_url" field.
func OriginalURLHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldOriginalURL, v))
}
// OriginalURLEqualFold applies the EqualFold predicate on the "original_url" field.
func OriginalURLEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldOriginalURL, v))
}
// OriginalURLContainsFold applies the ContainsFold predicate on the "original_url" field.
func OriginalURLContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldOriginalURL, v))
}
// CachePathEQ applies the EQ predicate on the "cache_path" field.
func CachePathEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCachePath, v))
}
// CachePathNEQ applies the NEQ predicate on the "cache_path" field.
func CachePathNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCachePath, v))
}
// CachePathIn applies the In predicate on the "cache_path" field.
func CachePathIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCachePath, vs...))
}
// CachePathNotIn applies the NotIn predicate on the "cache_path" field.
func CachePathNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCachePath, vs...))
}
// CachePathGT applies the GT predicate on the "cache_path" field.
func CachePathGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCachePath, v))
}
// CachePathGTE applies the GTE predicate on the "cache_path" field.
func CachePathGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCachePath, v))
}
// CachePathLT applies the LT predicate on the "cache_path" field.
func CachePathLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCachePath, v))
}
// CachePathLTE applies the LTE predicate on the "cache_path" field.
func CachePathLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCachePath, v))
}
// CachePathContains applies the Contains predicate on the "cache_path" field.
func CachePathContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldCachePath, v))
}
// CachePathHasPrefix applies the HasPrefix predicate on the "cache_path" field.
func CachePathHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldCachePath, v))
}
// CachePathHasSuffix applies the HasSuffix predicate on the "cache_path" field.
func CachePathHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldCachePath, v))
}
// CachePathEqualFold applies the EqualFold predicate on the "cache_path" field.
func CachePathEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldCachePath, v))
}
// CachePathContainsFold applies the ContainsFold predicate on the "cache_path" field.
func CachePathContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldCachePath, v))
}
// CacheURLEQ applies the EQ predicate on the "cache_url" field.
func CacheURLEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCacheURL, v))
}
// CacheURLNEQ applies the NEQ predicate on the "cache_url" field.
func CacheURLNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCacheURL, v))
}
// CacheURLIn applies the In predicate on the "cache_url" field.
func CacheURLIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCacheURL, vs...))
}
// CacheURLNotIn applies the NotIn predicate on the "cache_url" field.
func CacheURLNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCacheURL, vs...))
}
// CacheURLGT applies the GT predicate on the "cache_url" field.
func CacheURLGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCacheURL, v))
}
// CacheURLGTE applies the GTE predicate on the "cache_url" field.
func CacheURLGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCacheURL, v))
}
// CacheURLLT applies the LT predicate on the "cache_url" field.
func CacheURLLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCacheURL, v))
}
// CacheURLLTE applies the LTE predicate on the "cache_url" field.
func CacheURLLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCacheURL, v))
}
// CacheURLContains applies the Contains predicate on the "cache_url" field.
func CacheURLContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldCacheURL, v))
}
// CacheURLHasPrefix applies the HasPrefix predicate on the "cache_url" field.
func CacheURLHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldCacheURL, v))
}
// CacheURLHasSuffix applies the HasSuffix predicate on the "cache_url" field.
func CacheURLHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldCacheURL, v))
}
// CacheURLEqualFold applies the EqualFold predicate on the "cache_url" field.
func CacheURLEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldCacheURL, v))
}
// CacheURLContainsFold applies the ContainsFold predicate on the "cache_url" field.
func CacheURLContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldCacheURL, v))
}
// SizeBytesEQ applies the EQ predicate on the "size_bytes" field.
func SizeBytesEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldSizeBytes, v))
}
// SizeBytesNEQ applies the NEQ predicate on the "size_bytes" field.
func SizeBytesNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldSizeBytes, v))
}
// SizeBytesIn applies the In predicate on the "size_bytes" field.
func SizeBytesIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldSizeBytes, vs...))
}
// SizeBytesNotIn applies the NotIn predicate on the "size_bytes" field.
func SizeBytesNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldSizeBytes, vs...))
}
// SizeBytesGT applies the GT predicate on the "size_bytes" field.
func SizeBytesGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldSizeBytes, v))
}
// SizeBytesGTE applies the GTE predicate on the "size_bytes" field.
func SizeBytesGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldSizeBytes, v))
}
// SizeBytesLT applies the LT predicate on the "size_bytes" field.
func SizeBytesLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldSizeBytes, v))
}
// SizeBytesLTE applies the LTE predicate on the "size_bytes" field.
func SizeBytesLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldSizeBytes, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCreatedAt, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.NotPredicates(p))
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
// 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)
}
}

View File

@@ -0,0 +1,564 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"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"
)
// SoraCacheFileQuery is the builder for querying SoraCacheFile entities.
type SoraCacheFileQuery struct {
config
ctx *QueryContext
order []soracachefile.OrderOption
inters []Interceptor
predicates []predicate.SoraCacheFile
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraCacheFileQuery builder.
func (_q *SoraCacheFileQuery) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraCacheFileQuery) Limit(limit int) *SoraCacheFileQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraCacheFileQuery) Offset(offset int) *SoraCacheFileQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraCacheFileQuery) Unique(unique bool) *SoraCacheFileQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraCacheFileQuery) Order(o ...soracachefile.OrderOption) *SoraCacheFileQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraCacheFile entity from the query.
// Returns a *NotFoundError when no SoraCacheFile was found.
func (_q *SoraCacheFileQuery) First(ctx context.Context) (*SoraCacheFile, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{soracachefile.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraCacheFileQuery) FirstX(ctx context.Context) *SoraCacheFile {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraCacheFile ID from the query.
// Returns a *NotFoundError when no SoraCacheFile ID was found.
func (_q *SoraCacheFileQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{soracachefile.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraCacheFileQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraCacheFile entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraCacheFile entity is found.
// Returns a *NotFoundError when no SoraCacheFile entities are found.
func (_q *SoraCacheFileQuery) Only(ctx context.Context) (*SoraCacheFile, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{soracachefile.Label}
default:
return nil, &NotSingularError{soracachefile.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraCacheFileQuery) OnlyX(ctx context.Context) *SoraCacheFile {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraCacheFile ID in the query.
// Returns a *NotSingularError when more than one SoraCacheFile ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraCacheFileQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{soracachefile.Label}
default:
err = &NotSingularError{soracachefile.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraCacheFileQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraCacheFiles.
func (_q *SoraCacheFileQuery) All(ctx context.Context) ([]*SoraCacheFile, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraCacheFile, *SoraCacheFileQuery]()
return withInterceptors[[]*SoraCacheFile](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraCacheFileQuery) AllX(ctx context.Context) []*SoraCacheFile {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraCacheFile IDs.
func (_q *SoraCacheFileQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(soracachefile.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraCacheFileQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraCacheFileQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraCacheFileQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraCacheFileQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraCacheFileQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraCacheFileQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraCacheFileQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraCacheFileQuery) Clone() *SoraCacheFileQuery {
if _q == nil {
return nil
}
return &SoraCacheFileQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]soracachefile.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraCacheFile{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraCacheFile.Query().
// GroupBy(soracachefile.FieldTaskID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraCacheFileQuery) GroupBy(field string, fields ...string) *SoraCacheFileGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraCacheFileGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = soracachefile.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// }
//
// client.SoraCacheFile.Query().
// Select(soracachefile.FieldTaskID).
// Scan(ctx, &v)
func (_q *SoraCacheFileQuery) Select(fields ...string) *SoraCacheFileSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraCacheFileSelect{SoraCacheFileQuery: _q}
sbuild.label = soracachefile.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraCacheFileSelect configured with the given aggregations.
func (_q *SoraCacheFileQuery) Aggregate(fns ...AggregateFunc) *SoraCacheFileSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraCacheFileQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !soracachefile.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraCacheFileQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraCacheFile, error) {
var (
nodes = []*SoraCacheFile{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraCacheFile).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraCacheFile{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraCacheFileQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraCacheFileQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soracachefile.FieldID)
for i := range fields {
if fields[i] != soracachefile.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraCacheFileQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(soracachefile.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = soracachefile.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraCacheFileQuery) ForUpdate(opts ...sql.LockOption) *SoraCacheFileQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraCacheFileQuery) ForShare(opts ...sql.LockOption) *SoraCacheFileQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraCacheFileGroupBy is the group-by builder for SoraCacheFile entities.
type SoraCacheFileGroupBy struct {
selector
build *SoraCacheFileQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraCacheFileGroupBy) Aggregate(fns ...AggregateFunc) *SoraCacheFileGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraCacheFileGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraCacheFileQuery, *SoraCacheFileGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraCacheFileGroupBy) sqlScan(ctx context.Context, root *SoraCacheFileQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraCacheFileSelect is the builder for selecting fields of SoraCacheFile entities.
type SoraCacheFileSelect struct {
*SoraCacheFileQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraCacheFileSelect) Aggregate(fns ...AggregateFunc) *SoraCacheFileSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraCacheFileSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraCacheFileQuery, *SoraCacheFileSelect](ctx, _s.SoraCacheFileQuery, _s, _s.inters, v)
}
func (_s *SoraCacheFileSelect) sqlScan(ctx context.Context, root *SoraCacheFileQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -0,0 +1,596 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"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"
)
// SoraCacheFileUpdate is the builder for updating SoraCacheFile entities.
type SoraCacheFileUpdate struct {
config
hooks []Hook
mutation *SoraCacheFileMutation
}
// Where appends a list predicates to the SoraCacheFileUpdate builder.
func (_u *SoraCacheFileUpdate) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetTaskID sets the "task_id" field.
func (_u *SoraCacheFileUpdate) SetTaskID(v string) *SoraCacheFileUpdate {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableTaskID(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// ClearTaskID clears the value of the "task_id" field.
func (_u *SoraCacheFileUpdate) ClearTaskID() *SoraCacheFileUpdate {
_u.mutation.ClearTaskID()
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraCacheFileUpdate) SetAccountID(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableAccountID(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraCacheFileUpdate) AddAccountID(v int64) *SoraCacheFileUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *SoraCacheFileUpdate) SetUserID(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetUserID()
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableUserID(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// AddUserID adds value to the "user_id" field.
func (_u *SoraCacheFileUpdate) AddUserID(v int64) *SoraCacheFileUpdate {
_u.mutation.AddUserID(v)
return _u
}
// SetMediaType sets the "media_type" field.
func (_u *SoraCacheFileUpdate) SetMediaType(v string) *SoraCacheFileUpdate {
_u.mutation.SetMediaType(v)
return _u
}
// SetNillableMediaType sets the "media_type" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableMediaType(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetMediaType(*v)
}
return _u
}
// SetOriginalURL sets the "original_url" field.
func (_u *SoraCacheFileUpdate) SetOriginalURL(v string) *SoraCacheFileUpdate {
_u.mutation.SetOriginalURL(v)
return _u
}
// SetNillableOriginalURL sets the "original_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableOriginalURL(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetOriginalURL(*v)
}
return _u
}
// SetCachePath sets the "cache_path" field.
func (_u *SoraCacheFileUpdate) SetCachePath(v string) *SoraCacheFileUpdate {
_u.mutation.SetCachePath(v)
return _u
}
// SetNillableCachePath sets the "cache_path" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCachePath(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetCachePath(*v)
}
return _u
}
// SetCacheURL sets the "cache_url" field.
func (_u *SoraCacheFileUpdate) SetCacheURL(v string) *SoraCacheFileUpdate {
_u.mutation.SetCacheURL(v)
return _u
}
// SetNillableCacheURL sets the "cache_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCacheURL(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetCacheURL(*v)
}
return _u
}
// SetSizeBytes sets the "size_bytes" field.
func (_u *SoraCacheFileUpdate) SetSizeBytes(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetSizeBytes()
_u.mutation.SetSizeBytes(v)
return _u
}
// SetNillableSizeBytes sets the "size_bytes" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableSizeBytes(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetSizeBytes(*v)
}
return _u
}
// AddSizeBytes adds value to the "size_bytes" field.
func (_u *SoraCacheFileUpdate) AddSizeBytes(v int64) *SoraCacheFileUpdate {
_u.mutation.AddSizeBytes(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraCacheFileUpdate) SetCreatedAt(v time.Time) *SoraCacheFileUpdate {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCreatedAt(v *time.Time) *SoraCacheFileUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// Mutation returns the SoraCacheFileMutation object of the builder.
func (_u *SoraCacheFileUpdate) Mutation() *SoraCacheFileMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraCacheFileUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraCacheFileUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraCacheFileUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraCacheFileUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraCacheFileUpdate) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soracachefile.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.MediaType(); ok {
if err := soracachefile.MediaTypeValidator(v); err != nil {
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.media_type": %w`, err)}
}
}
return nil
}
func (_u *SoraCacheFileUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.TaskID(); ok {
_spec.SetField(soracachefile.FieldTaskID, field.TypeString, value)
}
if _u.mutation.TaskIDCleared() {
_spec.ClearField(soracachefile.FieldTaskID, field.TypeString)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.UserID(); ok {
_spec.SetField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedUserID(); ok {
_spec.AddField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.MediaType(); ok {
_spec.SetField(soracachefile.FieldMediaType, field.TypeString, value)
}
if value, ok := _u.mutation.OriginalURL(); ok {
_spec.SetField(soracachefile.FieldOriginalURL, field.TypeString, value)
}
if value, ok := _u.mutation.CachePath(); ok {
_spec.SetField(soracachefile.FieldCachePath, field.TypeString, value)
}
if value, ok := _u.mutation.CacheURL(); ok {
_spec.SetField(soracachefile.FieldCacheURL, field.TypeString, value)
}
if value, ok := _u.mutation.SizeBytes(); ok {
_spec.SetField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedSizeBytes(); ok {
_spec.AddField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soracachefile.FieldCreatedAt, field.TypeTime, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soracachefile.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraCacheFileUpdateOne is the builder for updating a single SoraCacheFile entity.
type SoraCacheFileUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraCacheFileMutation
}
// SetTaskID sets the "task_id" field.
func (_u *SoraCacheFileUpdateOne) SetTaskID(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableTaskID(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// ClearTaskID clears the value of the "task_id" field.
func (_u *SoraCacheFileUpdateOne) ClearTaskID() *SoraCacheFileUpdateOne {
_u.mutation.ClearTaskID()
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraCacheFileUpdateOne) SetAccountID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableAccountID(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraCacheFileUpdateOne) AddAccountID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *SoraCacheFileUpdateOne) SetUserID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetUserID()
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableUserID(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// AddUserID adds value to the "user_id" field.
func (_u *SoraCacheFileUpdateOne) AddUserID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddUserID(v)
return _u
}
// SetMediaType sets the "media_type" field.
func (_u *SoraCacheFileUpdateOne) SetMediaType(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetMediaType(v)
return _u
}
// SetNillableMediaType sets the "media_type" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableMediaType(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetMediaType(*v)
}
return _u
}
// SetOriginalURL sets the "original_url" field.
func (_u *SoraCacheFileUpdateOne) SetOriginalURL(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetOriginalURL(v)
return _u
}
// SetNillableOriginalURL sets the "original_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableOriginalURL(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetOriginalURL(*v)
}
return _u
}
// SetCachePath sets the "cache_path" field.
func (_u *SoraCacheFileUpdateOne) SetCachePath(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetCachePath(v)
return _u
}
// SetNillableCachePath sets the "cache_path" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCachePath(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCachePath(*v)
}
return _u
}
// SetCacheURL sets the "cache_url" field.
func (_u *SoraCacheFileUpdateOne) SetCacheURL(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetCacheURL(v)
return _u
}
// SetNillableCacheURL sets the "cache_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCacheURL(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCacheURL(*v)
}
return _u
}
// SetSizeBytes sets the "size_bytes" field.
func (_u *SoraCacheFileUpdateOne) SetSizeBytes(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetSizeBytes()
_u.mutation.SetSizeBytes(v)
return _u
}
// SetNillableSizeBytes sets the "size_bytes" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableSizeBytes(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetSizeBytes(*v)
}
return _u
}
// AddSizeBytes adds value to the "size_bytes" field.
func (_u *SoraCacheFileUpdateOne) AddSizeBytes(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddSizeBytes(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraCacheFileUpdateOne) SetCreatedAt(v time.Time) *SoraCacheFileUpdateOne {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCreatedAt(v *time.Time) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// Mutation returns the SoraCacheFileMutation object of the builder.
func (_u *SoraCacheFileUpdateOne) Mutation() *SoraCacheFileMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraCacheFileUpdate builder.
func (_u *SoraCacheFileUpdateOne) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *SoraCacheFileUpdateOne) Select(field string, fields ...string) *SoraCacheFileUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraCacheFile entity.
func (_u *SoraCacheFileUpdateOne) Save(ctx context.Context) (*SoraCacheFile, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraCacheFileUpdateOne) SaveX(ctx context.Context) *SoraCacheFile {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraCacheFileUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraCacheFileUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraCacheFileUpdateOne) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soracachefile.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.MediaType(); ok {
if err := soracachefile.MediaTypeValidator(v); err != nil {
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.media_type": %w`, err)}
}
}
return nil
}
func (_u *SoraCacheFileUpdateOne) sqlSave(ctx context.Context) (_node *SoraCacheFile, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraCacheFile.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soracachefile.FieldID)
for _, f := range fields {
if !soracachefile.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != soracachefile.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.TaskID(); ok {
_spec.SetField(soracachefile.FieldTaskID, field.TypeString, value)
}
if _u.mutation.TaskIDCleared() {
_spec.ClearField(soracachefile.FieldTaskID, field.TypeString)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.UserID(); ok {
_spec.SetField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedUserID(); ok {
_spec.AddField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.MediaType(); ok {
_spec.SetField(soracachefile.FieldMediaType, field.TypeString, value)
}
if value, ok := _u.mutation.OriginalURL(); ok {
_spec.SetField(soracachefile.FieldOriginalURL, field.TypeString, value)
}
if value, ok := _u.mutation.CachePath(); ok {
_spec.SetField(soracachefile.FieldCachePath, field.TypeString, value)
}
if value, ok := _u.mutation.CacheURL(); ok {
_spec.SetField(soracachefile.FieldCacheURL, field.TypeString, value)
}
if value, ok := _u.mutation.SizeBytes(); ok {
_spec.SetField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedSizeBytes(); ok {
_spec.AddField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soracachefile.FieldCreatedAt, field.TypeTime, value)
}
_node = &SoraCacheFile{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soracachefile.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}

227
backend/ent/soratask.go Normal file
View File

@@ -0,0 +1,227 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTask is the model entity for the SoraTask schema.
type SoraTask struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// TaskID holds the value of the "task_id" field.
TaskID string `json:"task_id,omitempty"`
// AccountID holds the value of the "account_id" field.
AccountID int64 `json:"account_id,omitempty"`
// Model holds the value of the "model" field.
Model string `json:"model,omitempty"`
// Prompt holds the value of the "prompt" field.
Prompt string `json:"prompt,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// Progress holds the value of the "progress" field.
Progress float64 `json:"progress,omitempty"`
// ResultUrls holds the value of the "result_urls" field.
ResultUrls *string `json:"result_urls,omitempty"`
// ErrorMessage holds the value of the "error_message" field.
ErrorMessage *string `json:"error_message,omitempty"`
// RetryCount holds the value of the "retry_count" field.
RetryCount int `json:"retry_count,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// CompletedAt holds the value of the "completed_at" field.
CompletedAt *time.Time `json:"completed_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraTask) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case soratask.FieldProgress:
values[i] = new(sql.NullFloat64)
case soratask.FieldID, soratask.FieldAccountID, soratask.FieldRetryCount:
values[i] = new(sql.NullInt64)
case soratask.FieldTaskID, soratask.FieldModel, soratask.FieldPrompt, soratask.FieldStatus, soratask.FieldResultUrls, soratask.FieldErrorMessage:
values[i] = new(sql.NullString)
case soratask.FieldCreatedAt, soratask.FieldCompletedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraTask fields.
func (_m *SoraTask) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case soratask.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case soratask.FieldTaskID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field task_id", values[i])
} else if value.Valid {
_m.TaskID = value.String
}
case soratask.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case soratask.FieldModel:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field model", values[i])
} else if value.Valid {
_m.Model = value.String
}
case soratask.FieldPrompt:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field prompt", values[i])
} else if value.Valid {
_m.Prompt = value.String
}
case soratask.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = value.String
}
case soratask.FieldProgress:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field progress", values[i])
} else if value.Valid {
_m.Progress = value.Float64
}
case soratask.FieldResultUrls:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field result_urls", values[i])
} else if value.Valid {
_m.ResultUrls = new(string)
*_m.ResultUrls = value.String
}
case soratask.FieldErrorMessage:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error_message", values[i])
} else if value.Valid {
_m.ErrorMessage = new(string)
*_m.ErrorMessage = value.String
}
case soratask.FieldRetryCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field retry_count", values[i])
} else if value.Valid {
_m.RetryCount = int(value.Int64)
}
case soratask.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case soratask.FieldCompletedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field completed_at", values[i])
} else if value.Valid {
_m.CompletedAt = new(time.Time)
*_m.CompletedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraTask.
// This includes values selected through modifiers, order, etc.
func (_m *SoraTask) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraTask.
// Note that you need to call SoraTask.Unwrap() before calling this method if this SoraTask
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraTask) Update() *SoraTaskUpdateOne {
return NewSoraTaskClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraTask entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraTask) Unwrap() *SoraTask {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraTask is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraTask) String() string {
var builder strings.Builder
builder.WriteString("SoraTask(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("task_id=")
builder.WriteString(_m.TaskID)
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("model=")
builder.WriteString(_m.Model)
builder.WriteString(", ")
builder.WriteString("prompt=")
builder.WriteString(_m.Prompt)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
builder.WriteString("progress=")
builder.WriteString(fmt.Sprintf("%v", _m.Progress))
builder.WriteString(", ")
if v := _m.ResultUrls; v != nil {
builder.WriteString("result_urls=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.ErrorMessage; v != nil {
builder.WriteString("error_message=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("retry_count=")
builder.WriteString(fmt.Sprintf("%v", _m.RetryCount))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
if v := _m.CompletedAt; v != nil {
builder.WriteString("completed_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteByte(')')
return builder.String()
}
// SoraTasks is a parsable slice of SoraTask.
type SoraTasks []*SoraTask

View File

@@ -0,0 +1,146 @@
// Code generated by ent, DO NOT EDIT.
package soratask
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the soratask type in the database.
Label = "sora_task"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTaskID holds the string denoting the task_id field in the database.
FieldTaskID = "task_id"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldModel holds the string denoting the model field in the database.
FieldModel = "model"
// FieldPrompt holds the string denoting the prompt field in the database.
FieldPrompt = "prompt"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldProgress holds the string denoting the progress field in the database.
FieldProgress = "progress"
// FieldResultUrls holds the string denoting the result_urls field in the database.
FieldResultUrls = "result_urls"
// FieldErrorMessage holds the string denoting the error_message field in the database.
FieldErrorMessage = "error_message"
// FieldRetryCount holds the string denoting the retry_count field in the database.
FieldRetryCount = "retry_count"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldCompletedAt holds the string denoting the completed_at field in the database.
FieldCompletedAt = "completed_at"
// Table holds the table name of the soratask in the database.
Table = "sora_tasks"
)
// Columns holds all SQL columns for soratask fields.
var Columns = []string{
FieldID,
FieldTaskID,
FieldAccountID,
FieldModel,
FieldPrompt,
FieldStatus,
FieldProgress,
FieldResultUrls,
FieldErrorMessage,
FieldRetryCount,
FieldCreatedAt,
FieldCompletedAt,
}
// 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 (
// TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
TaskIDValidator func(string) error
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
ModelValidator func(string) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus string
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
StatusValidator func(string) error
// DefaultProgress holds the default value on creation for the "progress" field.
DefaultProgress float64
// DefaultRetryCount holds the default value on creation for the "retry_count" field.
DefaultRetryCount int
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the SoraTask 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()
}
// ByTaskID orders the results by the task_id field.
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByModel orders the results by the model field.
func ByModel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModel, opts...).ToFunc()
}
// ByPrompt orders the results by the prompt field.
func ByPrompt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPrompt, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByProgress orders the results by the progress field.
func ByProgress(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProgress, opts...).ToFunc()
}
// ByResultUrls orders the results by the result_urls field.
func ByResultUrls(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldResultUrls, opts...).ToFunc()
}
// ByErrorMessage orders the results by the error_message field.
func ByErrorMessage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldErrorMessage, opts...).ToFunc()
}
// ByRetryCount orders the results by the retry_count field.
func ByRetryCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRetryCount, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByCompletedAt orders the results by the completed_at field.
func ByCompletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCompletedAt, opts...).ToFunc()
}

View File

@@ -0,0 +1,745 @@
// Code generated by ent, DO NOT EDIT.
package soratask
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldID, id))
}
// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
func TaskID(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldTaskID, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldAccountID, v))
}
// Model applies equality check predicate on the "model" field. It's identical to ModelEQ.
func Model(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldModel, v))
}
// Prompt applies equality check predicate on the "prompt" field. It's identical to PromptEQ.
func Prompt(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldPrompt, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldStatus, v))
}
// Progress applies equality check predicate on the "progress" field. It's identical to ProgressEQ.
func Progress(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldProgress, v))
}
// ResultUrls applies equality check predicate on the "result_urls" field. It's identical to ResultUrlsEQ.
func ResultUrls(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldResultUrls, v))
}
// ErrorMessage applies equality check predicate on the "error_message" field. It's identical to ErrorMessageEQ.
func ErrorMessage(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldErrorMessage, v))
}
// RetryCount applies equality check predicate on the "retry_count" field. It's identical to RetryCountEQ.
func RetryCount(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldRetryCount, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCreatedAt, v))
}
// CompletedAt applies equality check predicate on the "completed_at" field. It's identical to CompletedAtEQ.
func CompletedAt(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCompletedAt, v))
}
// TaskIDEQ applies the EQ predicate on the "task_id" field.
func TaskIDEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldTaskID, v))
}
// TaskIDNEQ applies the NEQ predicate on the "task_id" field.
func TaskIDNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldTaskID, v))
}
// TaskIDIn applies the In predicate on the "task_id" field.
func TaskIDIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldTaskID, vs...))
}
// TaskIDNotIn applies the NotIn predicate on the "task_id" field.
func TaskIDNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldTaskID, vs...))
}
// TaskIDGT applies the GT predicate on the "task_id" field.
func TaskIDGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldTaskID, v))
}
// TaskIDGTE applies the GTE predicate on the "task_id" field.
func TaskIDGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldTaskID, v))
}
// TaskIDLT applies the LT predicate on the "task_id" field.
func TaskIDLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldTaskID, v))
}
// TaskIDLTE applies the LTE predicate on the "task_id" field.
func TaskIDLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldTaskID, v))
}
// TaskIDContains applies the Contains predicate on the "task_id" field.
func TaskIDContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldTaskID, v))
}
// TaskIDHasPrefix applies the HasPrefix predicate on the "task_id" field.
func TaskIDHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldTaskID, v))
}
// TaskIDHasSuffix applies the HasSuffix predicate on the "task_id" field.
func TaskIDHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldTaskID, v))
}
// TaskIDEqualFold applies the EqualFold predicate on the "task_id" field.
func TaskIDEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldTaskID, v))
}
// TaskIDContainsFold applies the ContainsFold predicate on the "task_id" field.
func TaskIDContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldTaskID, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldAccountID, v))
}
// ModelEQ applies the EQ predicate on the "model" field.
func ModelEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldModel, v))
}
// ModelNEQ applies the NEQ predicate on the "model" field.
func ModelNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldModel, v))
}
// ModelIn applies the In predicate on the "model" field.
func ModelIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldModel, vs...))
}
// ModelNotIn applies the NotIn predicate on the "model" field.
func ModelNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldModel, vs...))
}
// ModelGT applies the GT predicate on the "model" field.
func ModelGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldModel, v))
}
// ModelGTE applies the GTE predicate on the "model" field.
func ModelGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldModel, v))
}
// ModelLT applies the LT predicate on the "model" field.
func ModelLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldModel, v))
}
// ModelLTE applies the LTE predicate on the "model" field.
func ModelLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldModel, v))
}
// ModelContains applies the Contains predicate on the "model" field.
func ModelContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldModel, v))
}
// ModelHasPrefix applies the HasPrefix predicate on the "model" field.
func ModelHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldModel, v))
}
// ModelHasSuffix applies the HasSuffix predicate on the "model" field.
func ModelHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldModel, v))
}
// ModelEqualFold applies the EqualFold predicate on the "model" field.
func ModelEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldModel, v))
}
// ModelContainsFold applies the ContainsFold predicate on the "model" field.
func ModelContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldModel, v))
}
// PromptEQ applies the EQ predicate on the "prompt" field.
func PromptEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldPrompt, v))
}
// PromptNEQ applies the NEQ predicate on the "prompt" field.
func PromptNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldPrompt, v))
}
// PromptIn applies the In predicate on the "prompt" field.
func PromptIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldPrompt, vs...))
}
// PromptNotIn applies the NotIn predicate on the "prompt" field.
func PromptNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldPrompt, vs...))
}
// PromptGT applies the GT predicate on the "prompt" field.
func PromptGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldPrompt, v))
}
// PromptGTE applies the GTE predicate on the "prompt" field.
func PromptGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldPrompt, v))
}
// PromptLT applies the LT predicate on the "prompt" field.
func PromptLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldPrompt, v))
}
// PromptLTE applies the LTE predicate on the "prompt" field.
func PromptLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldPrompt, v))
}
// PromptContains applies the Contains predicate on the "prompt" field.
func PromptContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldPrompt, v))
}
// PromptHasPrefix applies the HasPrefix predicate on the "prompt" field.
func PromptHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldPrompt, v))
}
// PromptHasSuffix applies the HasSuffix predicate on the "prompt" field.
func PromptHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldPrompt, v))
}
// PromptEqualFold applies the EqualFold predicate on the "prompt" field.
func PromptEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldPrompt, v))
}
// PromptContainsFold applies the ContainsFold predicate on the "prompt" field.
func PromptContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldPrompt, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldStatus, v))
}
// StatusContains applies the Contains predicate on the "status" field.
func StatusContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldStatus, v))
}
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func StatusHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldStatus, v))
}
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func StatusHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldStatus, v))
}
// StatusEqualFold applies the EqualFold predicate on the "status" field.
func StatusEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldStatus, v))
}
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
func StatusContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldStatus, v))
}
// ProgressEQ applies the EQ predicate on the "progress" field.
func ProgressEQ(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldProgress, v))
}
// ProgressNEQ applies the NEQ predicate on the "progress" field.
func ProgressNEQ(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldProgress, v))
}
// ProgressIn applies the In predicate on the "progress" field.
func ProgressIn(vs ...float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldProgress, vs...))
}
// ProgressNotIn applies the NotIn predicate on the "progress" field.
func ProgressNotIn(vs ...float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldProgress, vs...))
}
// ProgressGT applies the GT predicate on the "progress" field.
func ProgressGT(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldProgress, v))
}
// ProgressGTE applies the GTE predicate on the "progress" field.
func ProgressGTE(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldProgress, v))
}
// ProgressLT applies the LT predicate on the "progress" field.
func ProgressLT(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldProgress, v))
}
// ProgressLTE applies the LTE predicate on the "progress" field.
func ProgressLTE(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldProgress, v))
}
// ResultUrlsEQ applies the EQ predicate on the "result_urls" field.
func ResultUrlsEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldResultUrls, v))
}
// ResultUrlsNEQ applies the NEQ predicate on the "result_urls" field.
func ResultUrlsNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldResultUrls, v))
}
// ResultUrlsIn applies the In predicate on the "result_urls" field.
func ResultUrlsIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldResultUrls, vs...))
}
// ResultUrlsNotIn applies the NotIn predicate on the "result_urls" field.
func ResultUrlsNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldResultUrls, vs...))
}
// ResultUrlsGT applies the GT predicate on the "result_urls" field.
func ResultUrlsGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldResultUrls, v))
}
// ResultUrlsGTE applies the GTE predicate on the "result_urls" field.
func ResultUrlsGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldResultUrls, v))
}
// ResultUrlsLT applies the LT predicate on the "result_urls" field.
func ResultUrlsLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldResultUrls, v))
}
// ResultUrlsLTE applies the LTE predicate on the "result_urls" field.
func ResultUrlsLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldResultUrls, v))
}
// ResultUrlsContains applies the Contains predicate on the "result_urls" field.
func ResultUrlsContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldResultUrls, v))
}
// ResultUrlsHasPrefix applies the HasPrefix predicate on the "result_urls" field.
func ResultUrlsHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldResultUrls, v))
}
// ResultUrlsHasSuffix applies the HasSuffix predicate on the "result_urls" field.
func ResultUrlsHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldResultUrls, v))
}
// ResultUrlsIsNil applies the IsNil predicate on the "result_urls" field.
func ResultUrlsIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldResultUrls))
}
// ResultUrlsNotNil applies the NotNil predicate on the "result_urls" field.
func ResultUrlsNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldResultUrls))
}
// ResultUrlsEqualFold applies the EqualFold predicate on the "result_urls" field.
func ResultUrlsEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldResultUrls, v))
}
// ResultUrlsContainsFold applies the ContainsFold predicate on the "result_urls" field.
func ResultUrlsContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldResultUrls, v))
}
// ErrorMessageEQ applies the EQ predicate on the "error_message" field.
func ErrorMessageEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldErrorMessage, v))
}
// ErrorMessageNEQ applies the NEQ predicate on the "error_message" field.
func ErrorMessageNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldErrorMessage, v))
}
// ErrorMessageIn applies the In predicate on the "error_message" field.
func ErrorMessageIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldErrorMessage, vs...))
}
// ErrorMessageNotIn applies the NotIn predicate on the "error_message" field.
func ErrorMessageNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldErrorMessage, vs...))
}
// ErrorMessageGT applies the GT predicate on the "error_message" field.
func ErrorMessageGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldErrorMessage, v))
}
// ErrorMessageGTE applies the GTE predicate on the "error_message" field.
func ErrorMessageGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldErrorMessage, v))
}
// ErrorMessageLT applies the LT predicate on the "error_message" field.
func ErrorMessageLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldErrorMessage, v))
}
// ErrorMessageLTE applies the LTE predicate on the "error_message" field.
func ErrorMessageLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldErrorMessage, v))
}
// ErrorMessageContains applies the Contains predicate on the "error_message" field.
func ErrorMessageContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldErrorMessage, v))
}
// ErrorMessageHasPrefix applies the HasPrefix predicate on the "error_message" field.
func ErrorMessageHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldErrorMessage, v))
}
// ErrorMessageHasSuffix applies the HasSuffix predicate on the "error_message" field.
func ErrorMessageHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldErrorMessage, v))
}
// ErrorMessageIsNil applies the IsNil predicate on the "error_message" field.
func ErrorMessageIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldErrorMessage))
}
// ErrorMessageNotNil applies the NotNil predicate on the "error_message" field.
func ErrorMessageNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldErrorMessage))
}
// ErrorMessageEqualFold applies the EqualFold predicate on the "error_message" field.
func ErrorMessageEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldErrorMessage, v))
}
// ErrorMessageContainsFold applies the ContainsFold predicate on the "error_message" field.
func ErrorMessageContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldErrorMessage, v))
}
// RetryCountEQ applies the EQ predicate on the "retry_count" field.
func RetryCountEQ(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldRetryCount, v))
}
// RetryCountNEQ applies the NEQ predicate on the "retry_count" field.
func RetryCountNEQ(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldRetryCount, v))
}
// RetryCountIn applies the In predicate on the "retry_count" field.
func RetryCountIn(vs ...int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldRetryCount, vs...))
}
// RetryCountNotIn applies the NotIn predicate on the "retry_count" field.
func RetryCountNotIn(vs ...int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldRetryCount, vs...))
}
// RetryCountGT applies the GT predicate on the "retry_count" field.
func RetryCountGT(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldRetryCount, v))
}
// RetryCountGTE applies the GTE predicate on the "retry_count" field.
func RetryCountGTE(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldRetryCount, v))
}
// RetryCountLT applies the LT predicate on the "retry_count" field.
func RetryCountLT(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldRetryCount, v))
}
// RetryCountLTE applies the LTE predicate on the "retry_count" field.
func RetryCountLTE(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldRetryCount, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldCreatedAt, v))
}
// CompletedAtEQ applies the EQ predicate on the "completed_at" field.
func CompletedAtEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCompletedAt, v))
}
// CompletedAtNEQ applies the NEQ predicate on the "completed_at" field.
func CompletedAtNEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldCompletedAt, v))
}
// CompletedAtIn applies the In predicate on the "completed_at" field.
func CompletedAtIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldCompletedAt, vs...))
}
// CompletedAtNotIn applies the NotIn predicate on the "completed_at" field.
func CompletedAtNotIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldCompletedAt, vs...))
}
// CompletedAtGT applies the GT predicate on the "completed_at" field.
func CompletedAtGT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldCompletedAt, v))
}
// CompletedAtGTE applies the GTE predicate on the "completed_at" field.
func CompletedAtGTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldCompletedAt, v))
}
// CompletedAtLT applies the LT predicate on the "completed_at" field.
func CompletedAtLT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldCompletedAt, v))
}
// CompletedAtLTE applies the LTE predicate on the "completed_at" field.
func CompletedAtLTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldCompletedAt, v))
}
// CompletedAtIsNil applies the IsNil predicate on the "completed_at" field.
func CompletedAtIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldCompletedAt))
}
// CompletedAtNotNil applies the NotNil predicate on the "completed_at" field.
func CompletedAtNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldCompletedAt))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.NotPredicates(p))
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
// 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/soratask"
)
// SoraTaskDelete is the builder for deleting a SoraTask entity.
type SoraTaskDelete struct {
config
hooks []Hook
mutation *SoraTaskMutation
}
// Where appends a list predicates to the SoraTaskDelete builder.
func (_d *SoraTaskDelete) Where(ps ...predicate.SoraTask) *SoraTaskDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraTaskDelete) 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 *SoraTaskDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraTaskDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(soratask.Table, sqlgraph.NewFieldSpec(soratask.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
}
// SoraTaskDeleteOne is the builder for deleting a single SoraTask entity.
type SoraTaskDeleteOne struct {
_d *SoraTaskDelete
}
// Where appends a list predicates to the SoraTaskDelete builder.
func (_d *SoraTaskDeleteOne) Where(ps ...predicate.SoraTask) *SoraTaskDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraTaskDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{soratask.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraTaskDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,564 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"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/soratask"
)
// SoraTaskQuery is the builder for querying SoraTask entities.
type SoraTaskQuery struct {
config
ctx *QueryContext
order []soratask.OrderOption
inters []Interceptor
predicates []predicate.SoraTask
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraTaskQuery builder.
func (_q *SoraTaskQuery) Where(ps ...predicate.SoraTask) *SoraTaskQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraTaskQuery) Limit(limit int) *SoraTaskQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraTaskQuery) Offset(offset int) *SoraTaskQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraTaskQuery) Unique(unique bool) *SoraTaskQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraTaskQuery) Order(o ...soratask.OrderOption) *SoraTaskQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraTask entity from the query.
// Returns a *NotFoundError when no SoraTask was found.
func (_q *SoraTaskQuery) First(ctx context.Context) (*SoraTask, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{soratask.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraTaskQuery) FirstX(ctx context.Context) *SoraTask {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraTask ID from the query.
// Returns a *NotFoundError when no SoraTask ID was found.
func (_q *SoraTaskQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{soratask.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraTaskQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraTask entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraTask entity is found.
// Returns a *NotFoundError when no SoraTask entities are found.
func (_q *SoraTaskQuery) Only(ctx context.Context) (*SoraTask, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{soratask.Label}
default:
return nil, &NotSingularError{soratask.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraTaskQuery) OnlyX(ctx context.Context) *SoraTask {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraTask ID in the query.
// Returns a *NotSingularError when more than one SoraTask ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraTaskQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{soratask.Label}
default:
err = &NotSingularError{soratask.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraTaskQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraTasks.
func (_q *SoraTaskQuery) All(ctx context.Context) ([]*SoraTask, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraTask, *SoraTaskQuery]()
return withInterceptors[[]*SoraTask](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraTaskQuery) AllX(ctx context.Context) []*SoraTask {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraTask IDs.
func (_q *SoraTaskQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(soratask.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraTaskQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraTaskQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraTaskQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraTaskQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraTaskQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraTaskQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraTaskQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraTaskQuery) Clone() *SoraTaskQuery {
if _q == nil {
return nil
}
return &SoraTaskQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]soratask.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraTask{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraTask.Query().
// GroupBy(soratask.FieldTaskID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraTaskQuery) GroupBy(field string, fields ...string) *SoraTaskGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraTaskGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = soratask.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// }
//
// client.SoraTask.Query().
// Select(soratask.FieldTaskID).
// Scan(ctx, &v)
func (_q *SoraTaskQuery) Select(fields ...string) *SoraTaskSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraTaskSelect{SoraTaskQuery: _q}
sbuild.label = soratask.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraTaskSelect configured with the given aggregations.
func (_q *SoraTaskQuery) Aggregate(fns ...AggregateFunc) *SoraTaskSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraTaskQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !soratask.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraTask, error) {
var (
nodes = []*SoraTask{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraTask).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraTask{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraTaskQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraTaskQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soratask.FieldID)
for i := range fields {
if fields[i] != soratask.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraTaskQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(soratask.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = soratask.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraTaskQuery) ForUpdate(opts ...sql.LockOption) *SoraTaskQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraTaskQuery) ForShare(opts ...sql.LockOption) *SoraTaskQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraTaskGroupBy is the group-by builder for SoraTask entities.
type SoraTaskGroupBy struct {
selector
build *SoraTaskQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraTaskGroupBy) Aggregate(fns ...AggregateFunc) *SoraTaskGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraTaskGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraTaskQuery, *SoraTaskGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraTaskGroupBy) sqlScan(ctx context.Context, root *SoraTaskQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraTaskSelect is the builder for selecting fields of SoraTask entities.
type SoraTaskSelect struct {
*SoraTaskQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraTaskSelect) Aggregate(fns ...AggregateFunc) *SoraTaskSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraTaskSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraTaskQuery, *SoraTaskSelect](ctx, _s.SoraTaskQuery, _s, _s.inters, v)
}
func (_s *SoraTaskSelect) sqlScan(ctx context.Context, root *SoraTaskQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -0,0 +1,710 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"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/soratask"
)
// SoraTaskUpdate is the builder for updating SoraTask entities.
type SoraTaskUpdate struct {
config
hooks []Hook
mutation *SoraTaskMutation
}
// Where appends a list predicates to the SoraTaskUpdate builder.
func (_u *SoraTaskUpdate) Where(ps ...predicate.SoraTask) *SoraTaskUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetTaskID sets the "task_id" field.
func (_u *SoraTaskUpdate) SetTaskID(v string) *SoraTaskUpdate {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableTaskID(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraTaskUpdate) SetAccountID(v int64) *SoraTaskUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableAccountID(v *int64) *SoraTaskUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraTaskUpdate) AddAccountID(v int64) *SoraTaskUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetModel sets the "model" field.
func (_u *SoraTaskUpdate) SetModel(v string) *SoraTaskUpdate {
_u.mutation.SetModel(v)
return _u
}
// SetNillableModel sets the "model" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableModel(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetModel(*v)
}
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *SoraTaskUpdate) SetPrompt(v string) *SoraTaskUpdate {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillablePrompt(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *SoraTaskUpdate) SetStatus(v string) *SoraTaskUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableStatus(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetProgress sets the "progress" field.
func (_u *SoraTaskUpdate) SetProgress(v float64) *SoraTaskUpdate {
_u.mutation.ResetProgress()
_u.mutation.SetProgress(v)
return _u
}
// SetNillableProgress sets the "progress" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableProgress(v *float64) *SoraTaskUpdate {
if v != nil {
_u.SetProgress(*v)
}
return _u
}
// AddProgress adds value to the "progress" field.
func (_u *SoraTaskUpdate) AddProgress(v float64) *SoraTaskUpdate {
_u.mutation.AddProgress(v)
return _u
}
// SetResultUrls sets the "result_urls" field.
func (_u *SoraTaskUpdate) SetResultUrls(v string) *SoraTaskUpdate {
_u.mutation.SetResultUrls(v)
return _u
}
// SetNillableResultUrls sets the "result_urls" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableResultUrls(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetResultUrls(*v)
}
return _u
}
// ClearResultUrls clears the value of the "result_urls" field.
func (_u *SoraTaskUpdate) ClearResultUrls() *SoraTaskUpdate {
_u.mutation.ClearResultUrls()
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *SoraTaskUpdate) SetErrorMessage(v string) *SoraTaskUpdate {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableErrorMessage(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *SoraTaskUpdate) ClearErrorMessage() *SoraTaskUpdate {
_u.mutation.ClearErrorMessage()
return _u
}
// SetRetryCount sets the "retry_count" field.
func (_u *SoraTaskUpdate) SetRetryCount(v int) *SoraTaskUpdate {
_u.mutation.ResetRetryCount()
_u.mutation.SetRetryCount(v)
return _u
}
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableRetryCount(v *int) *SoraTaskUpdate {
if v != nil {
_u.SetRetryCount(*v)
}
return _u
}
// AddRetryCount adds value to the "retry_count" field.
func (_u *SoraTaskUpdate) AddRetryCount(v int) *SoraTaskUpdate {
_u.mutation.AddRetryCount(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraTaskUpdate) SetCreatedAt(v time.Time) *SoraTaskUpdate {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableCreatedAt(v *time.Time) *SoraTaskUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// SetCompletedAt sets the "completed_at" field.
func (_u *SoraTaskUpdate) SetCompletedAt(v time.Time) *SoraTaskUpdate {
_u.mutation.SetCompletedAt(v)
return _u
}
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableCompletedAt(v *time.Time) *SoraTaskUpdate {
if v != nil {
_u.SetCompletedAt(*v)
}
return _u
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (_u *SoraTaskUpdate) ClearCompletedAt() *SoraTaskUpdate {
_u.mutation.ClearCompletedAt()
return _u
}
// Mutation returns the SoraTaskMutation object of the builder.
func (_u *SoraTaskUpdate) Mutation() *SoraTaskMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraTaskUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraTaskUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraTaskUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraTaskUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraTaskUpdate) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soratask.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraTask.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.Model(); ok {
if err := soratask.ModelValidator(v); err != nil {
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "SoraTask.model": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := soratask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "SoraTask.status": %w`, err)}
}
}
return nil
}
func (_u *SoraTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.TaskID(); ok {
_spec.SetField(soratask.FieldTaskID, field.TypeString, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.Model(); ok {
_spec.SetField(soratask.FieldModel, field.TypeString, value)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(soratask.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(soratask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Progress(); ok {
_spec.SetField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.AddedProgress(); ok {
_spec.AddField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.ResultUrls(); ok {
_spec.SetField(soratask.FieldResultUrls, field.TypeString, value)
}
if _u.mutation.ResultUrlsCleared() {
_spec.ClearField(soratask.FieldResultUrls, field.TypeString)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(soratask.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(soratask.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.RetryCount(); ok {
_spec.SetField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedRetryCount(); ok {
_spec.AddField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soratask.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.CompletedAt(); ok {
_spec.SetField(soratask.FieldCompletedAt, field.TypeTime, value)
}
if _u.mutation.CompletedAtCleared() {
_spec.ClearField(soratask.FieldCompletedAt, field.TypeTime)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soratask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraTaskUpdateOne is the builder for updating a single SoraTask entity.
type SoraTaskUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraTaskMutation
}
// SetTaskID sets the "task_id" field.
func (_u *SoraTaskUpdateOne) SetTaskID(v string) *SoraTaskUpdateOne {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableTaskID(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraTaskUpdateOne) SetAccountID(v int64) *SoraTaskUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableAccountID(v *int64) *SoraTaskUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraTaskUpdateOne) AddAccountID(v int64) *SoraTaskUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetModel sets the "model" field.
func (_u *SoraTaskUpdateOne) SetModel(v string) *SoraTaskUpdateOne {
_u.mutation.SetModel(v)
return _u
}
// SetNillableModel sets the "model" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableModel(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetModel(*v)
}
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *SoraTaskUpdateOne) SetPrompt(v string) *SoraTaskUpdateOne {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillablePrompt(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *SoraTaskUpdateOne) SetStatus(v string) *SoraTaskUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableStatus(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetProgress sets the "progress" field.
func (_u *SoraTaskUpdateOne) SetProgress(v float64) *SoraTaskUpdateOne {
_u.mutation.ResetProgress()
_u.mutation.SetProgress(v)
return _u
}
// SetNillableProgress sets the "progress" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableProgress(v *float64) *SoraTaskUpdateOne {
if v != nil {
_u.SetProgress(*v)
}
return _u
}
// AddProgress adds value to the "progress" field.
func (_u *SoraTaskUpdateOne) AddProgress(v float64) *SoraTaskUpdateOne {
_u.mutation.AddProgress(v)
return _u
}
// SetResultUrls sets the "result_urls" field.
func (_u *SoraTaskUpdateOne) SetResultUrls(v string) *SoraTaskUpdateOne {
_u.mutation.SetResultUrls(v)
return _u
}
// SetNillableResultUrls sets the "result_urls" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableResultUrls(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetResultUrls(*v)
}
return _u
}
// ClearResultUrls clears the value of the "result_urls" field.
func (_u *SoraTaskUpdateOne) ClearResultUrls() *SoraTaskUpdateOne {
_u.mutation.ClearResultUrls()
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *SoraTaskUpdateOne) SetErrorMessage(v string) *SoraTaskUpdateOne {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableErrorMessage(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *SoraTaskUpdateOne) ClearErrorMessage() *SoraTaskUpdateOne {
_u.mutation.ClearErrorMessage()
return _u
}
// SetRetryCount sets the "retry_count" field.
func (_u *SoraTaskUpdateOne) SetRetryCount(v int) *SoraTaskUpdateOne {
_u.mutation.ResetRetryCount()
_u.mutation.SetRetryCount(v)
return _u
}
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableRetryCount(v *int) *SoraTaskUpdateOne {
if v != nil {
_u.SetRetryCount(*v)
}
return _u
}
// AddRetryCount adds value to the "retry_count" field.
func (_u *SoraTaskUpdateOne) AddRetryCount(v int) *SoraTaskUpdateOne {
_u.mutation.AddRetryCount(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraTaskUpdateOne) SetCreatedAt(v time.Time) *SoraTaskUpdateOne {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableCreatedAt(v *time.Time) *SoraTaskUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// SetCompletedAt sets the "completed_at" field.
func (_u *SoraTaskUpdateOne) SetCompletedAt(v time.Time) *SoraTaskUpdateOne {
_u.mutation.SetCompletedAt(v)
return _u
}
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableCompletedAt(v *time.Time) *SoraTaskUpdateOne {
if v != nil {
_u.SetCompletedAt(*v)
}
return _u
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (_u *SoraTaskUpdateOne) ClearCompletedAt() *SoraTaskUpdateOne {
_u.mutation.ClearCompletedAt()
return _u
}
// Mutation returns the SoraTaskMutation object of the builder.
func (_u *SoraTaskUpdateOne) Mutation() *SoraTaskMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraTaskUpdate builder.
func (_u *SoraTaskUpdateOne) Where(ps ...predicate.SoraTask) *SoraTaskUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *SoraTaskUpdateOne) Select(field string, fields ...string) *SoraTaskUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraTask entity.
func (_u *SoraTaskUpdateOne) Save(ctx context.Context) (*SoraTask, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraTaskUpdateOne) SaveX(ctx context.Context) *SoraTask {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraTaskUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraTaskUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraTaskUpdateOne) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soratask.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraTask.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.Model(); ok {
if err := soratask.ModelValidator(v); err != nil {
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "SoraTask.model": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := soratask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "SoraTask.status": %w`, err)}
}
}
return nil
}
func (_u *SoraTaskUpdateOne) sqlSave(ctx context.Context) (_node *SoraTask, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraTask.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soratask.FieldID)
for _, f := range fields {
if !soratask.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != soratask.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.TaskID(); ok {
_spec.SetField(soratask.FieldTaskID, field.TypeString, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.Model(); ok {
_spec.SetField(soratask.FieldModel, field.TypeString, value)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(soratask.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(soratask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Progress(); ok {
_spec.SetField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.AddedProgress(); ok {
_spec.AddField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.ResultUrls(); ok {
_spec.SetField(soratask.FieldResultUrls, field.TypeString, value)
}
if _u.mutation.ResultUrlsCleared() {
_spec.ClearField(soratask.FieldResultUrls, field.TypeString)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(soratask.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(soratask.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.RetryCount(); ok {
_spec.SetField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedRetryCount(); ok {
_spec.AddField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soratask.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.CompletedAt(); ok {
_spec.SetField(soratask.FieldCompletedAt, field.TypeTime, value)
}
if _u.mutation.CompletedAtCleared() {
_spec.ClearField(soratask.FieldCompletedAt, field.TypeTime)
}
_node = &SoraTask{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soratask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}

View File

@@ -0,0 +1,231 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
)
// SoraUsageStat is the model entity for the SoraUsageStat schema.
type SoraUsageStat struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 关联 accounts 表的 ID
AccountID int64 `json:"account_id,omitempty"`
// ImageCount holds the value of the "image_count" field.
ImageCount int `json:"image_count,omitempty"`
// VideoCount holds the value of the "video_count" field.
VideoCount int `json:"video_count,omitempty"`
// ErrorCount holds the value of the "error_count" field.
ErrorCount int `json:"error_count,omitempty"`
// LastErrorAt holds the value of the "last_error_at" field.
LastErrorAt *time.Time `json:"last_error_at,omitempty"`
// TodayImageCount holds the value of the "today_image_count" field.
TodayImageCount int `json:"today_image_count,omitempty"`
// TodayVideoCount holds the value of the "today_video_count" field.
TodayVideoCount int `json:"today_video_count,omitempty"`
// TodayErrorCount holds the value of the "today_error_count" field.
TodayErrorCount int `json:"today_error_count,omitempty"`
// TodayDate holds the value of the "today_date" field.
TodayDate *time.Time `json:"today_date,omitempty"`
// ConsecutiveErrorCount holds the value of the "consecutive_error_count" field.
ConsecutiveErrorCount int `json:"consecutive_error_count,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraUsageStat) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case sorausagestat.FieldID, sorausagestat.FieldAccountID, sorausagestat.FieldImageCount, sorausagestat.FieldVideoCount, sorausagestat.FieldErrorCount, sorausagestat.FieldTodayImageCount, sorausagestat.FieldTodayVideoCount, sorausagestat.FieldTodayErrorCount, sorausagestat.FieldConsecutiveErrorCount:
values[i] = new(sql.NullInt64)
case sorausagestat.FieldCreatedAt, sorausagestat.FieldUpdatedAt, sorausagestat.FieldLastErrorAt, sorausagestat.FieldTodayDate:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraUsageStat fields.
func (_m *SoraUsageStat) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case sorausagestat.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case sorausagestat.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case sorausagestat.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case sorausagestat.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case sorausagestat.FieldImageCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field image_count", values[i])
} else if value.Valid {
_m.ImageCount = int(value.Int64)
}
case sorausagestat.FieldVideoCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field video_count", values[i])
} else if value.Valid {
_m.VideoCount = int(value.Int64)
}
case sorausagestat.FieldErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field error_count", values[i])
} else if value.Valid {
_m.ErrorCount = int(value.Int64)
}
case sorausagestat.FieldLastErrorAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field last_error_at", values[i])
} else if value.Valid {
_m.LastErrorAt = new(time.Time)
*_m.LastErrorAt = value.Time
}
case sorausagestat.FieldTodayImageCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_image_count", values[i])
} else if value.Valid {
_m.TodayImageCount = int(value.Int64)
}
case sorausagestat.FieldTodayVideoCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_video_count", values[i])
} else if value.Valid {
_m.TodayVideoCount = int(value.Int64)
}
case sorausagestat.FieldTodayErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_error_count", values[i])
} else if value.Valid {
_m.TodayErrorCount = int(value.Int64)
}
case sorausagestat.FieldTodayDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field today_date", values[i])
} else if value.Valid {
_m.TodayDate = new(time.Time)
*_m.TodayDate = value.Time
}
case sorausagestat.FieldConsecutiveErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field consecutive_error_count", values[i])
} else if value.Valid {
_m.ConsecutiveErrorCount = int(value.Int64)
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraUsageStat.
// This includes values selected through modifiers, order, etc.
func (_m *SoraUsageStat) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraUsageStat.
// Note that you need to call SoraUsageStat.Unwrap() before calling this method if this SoraUsageStat
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraUsageStat) Update() *SoraUsageStatUpdateOne {
return NewSoraUsageStatClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraUsageStat entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraUsageStat) Unwrap() *SoraUsageStat {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraUsageStat is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraUsageStat) String() string {
var builder strings.Builder
builder.WriteString("SoraUsageStat(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("image_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ImageCount))
builder.WriteString(", ")
builder.WriteString("video_count=")
builder.WriteString(fmt.Sprintf("%v", _m.VideoCount))
builder.WriteString(", ")
builder.WriteString("error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount))
builder.WriteString(", ")
if v := _m.LastErrorAt; v != nil {
builder.WriteString("last_error_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("today_image_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayImageCount))
builder.WriteString(", ")
builder.WriteString("today_video_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayVideoCount))
builder.WriteString(", ")
builder.WriteString("today_error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayErrorCount))
builder.WriteString(", ")
if v := _m.TodayDate; v != nil {
builder.WriteString("today_date=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("consecutive_error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ConsecutiveErrorCount))
builder.WriteByte(')')
return builder.String()
}
// SoraUsageStats is a parsable slice of SoraUsageStat.
type SoraUsageStats []*SoraUsageStat

View File

@@ -0,0 +1,160 @@
// 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()
}

View File

@@ -0,0 +1,630 @@
// Code generated by ent, DO NOT EDIT.
package sorausagestat
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldUpdatedAt, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldAccountID, v))
}
// ImageCount applies equality check predicate on the "image_count" field. It's identical to ImageCountEQ.
func ImageCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldImageCount, v))
}
// VideoCount applies equality check predicate on the "video_count" field. It's identical to VideoCountEQ.
func VideoCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldVideoCount, v))
}
// ErrorCount applies equality check predicate on the "error_count" field. It's identical to ErrorCountEQ.
func ErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldErrorCount, v))
}
// LastErrorAt applies equality check predicate on the "last_error_at" field. It's identical to LastErrorAtEQ.
func LastErrorAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldLastErrorAt, v))
}
// TodayImageCount applies equality check predicate on the "today_image_count" field. It's identical to TodayImageCountEQ.
func TodayImageCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayImageCount, v))
}
// TodayVideoCount applies equality check predicate on the "today_video_count" field. It's identical to TodayVideoCountEQ.
func TodayVideoCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayVideoCount, v))
}
// TodayErrorCount applies equality check predicate on the "today_error_count" field. It's identical to TodayErrorCountEQ.
func TodayErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayErrorCount, v))
}
// TodayDate applies equality check predicate on the "today_date" field. It's identical to TodayDateEQ.
func TodayDate(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayDate, v))
}
// ConsecutiveErrorCount applies equality check predicate on the "consecutive_error_count" field. It's identical to ConsecutiveErrorCountEQ.
func ConsecutiveErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldConsecutiveErrorCount, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldUpdatedAt, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldAccountID, v))
}
// ImageCountEQ applies the EQ predicate on the "image_count" field.
func ImageCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldImageCount, v))
}
// ImageCountNEQ applies the NEQ predicate on the "image_count" field.
func ImageCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldImageCount, v))
}
// ImageCountIn applies the In predicate on the "image_count" field.
func ImageCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldImageCount, vs...))
}
// ImageCountNotIn applies the NotIn predicate on the "image_count" field.
func ImageCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldImageCount, vs...))
}
// ImageCountGT applies the GT predicate on the "image_count" field.
func ImageCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldImageCount, v))
}
// ImageCountGTE applies the GTE predicate on the "image_count" field.
func ImageCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldImageCount, v))
}
// ImageCountLT applies the LT predicate on the "image_count" field.
func ImageCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldImageCount, v))
}
// ImageCountLTE applies the LTE predicate on the "image_count" field.
func ImageCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldImageCount, v))
}
// VideoCountEQ applies the EQ predicate on the "video_count" field.
func VideoCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldVideoCount, v))
}
// VideoCountNEQ applies the NEQ predicate on the "video_count" field.
func VideoCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldVideoCount, v))
}
// VideoCountIn applies the In predicate on the "video_count" field.
func VideoCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldVideoCount, vs...))
}
// VideoCountNotIn applies the NotIn predicate on the "video_count" field.
func VideoCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldVideoCount, vs...))
}
// VideoCountGT applies the GT predicate on the "video_count" field.
func VideoCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldVideoCount, v))
}
// VideoCountGTE applies the GTE predicate on the "video_count" field.
func VideoCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldVideoCount, v))
}
// VideoCountLT applies the LT predicate on the "video_count" field.
func VideoCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldVideoCount, v))
}
// VideoCountLTE applies the LTE predicate on the "video_count" field.
func VideoCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldVideoCount, v))
}
// ErrorCountEQ applies the EQ predicate on the "error_count" field.
func ErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldErrorCount, v))
}
// ErrorCountNEQ applies the NEQ predicate on the "error_count" field.
func ErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldErrorCount, v))
}
// ErrorCountIn applies the In predicate on the "error_count" field.
func ErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldErrorCount, vs...))
}
// ErrorCountNotIn applies the NotIn predicate on the "error_count" field.
func ErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldErrorCount, vs...))
}
// ErrorCountGT applies the GT predicate on the "error_count" field.
func ErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldErrorCount, v))
}
// ErrorCountGTE applies the GTE predicate on the "error_count" field.
func ErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldErrorCount, v))
}
// ErrorCountLT applies the LT predicate on the "error_count" field.
func ErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldErrorCount, v))
}
// ErrorCountLTE applies the LTE predicate on the "error_count" field.
func ErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldErrorCount, v))
}
// LastErrorAtEQ applies the EQ predicate on the "last_error_at" field.
func LastErrorAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldLastErrorAt, v))
}
// LastErrorAtNEQ applies the NEQ predicate on the "last_error_at" field.
func LastErrorAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldLastErrorAt, v))
}
// LastErrorAtIn applies the In predicate on the "last_error_at" field.
func LastErrorAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldLastErrorAt, vs...))
}
// LastErrorAtNotIn applies the NotIn predicate on the "last_error_at" field.
func LastErrorAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldLastErrorAt, vs...))
}
// LastErrorAtGT applies the GT predicate on the "last_error_at" field.
func LastErrorAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldLastErrorAt, v))
}
// LastErrorAtGTE applies the GTE predicate on the "last_error_at" field.
func LastErrorAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldLastErrorAt, v))
}
// LastErrorAtLT applies the LT predicate on the "last_error_at" field.
func LastErrorAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldLastErrorAt, v))
}
// LastErrorAtLTE applies the LTE predicate on the "last_error_at" field.
func LastErrorAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldLastErrorAt, v))
}
// LastErrorAtIsNil applies the IsNil predicate on the "last_error_at" field.
func LastErrorAtIsNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIsNull(FieldLastErrorAt))
}
// LastErrorAtNotNil applies the NotNil predicate on the "last_error_at" field.
func LastErrorAtNotNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotNull(FieldLastErrorAt))
}
// TodayImageCountEQ applies the EQ predicate on the "today_image_count" field.
func TodayImageCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayImageCount, v))
}
// TodayImageCountNEQ applies the NEQ predicate on the "today_image_count" field.
func TodayImageCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayImageCount, v))
}
// TodayImageCountIn applies the In predicate on the "today_image_count" field.
func TodayImageCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayImageCount, vs...))
}
// TodayImageCountNotIn applies the NotIn predicate on the "today_image_count" field.
func TodayImageCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayImageCount, vs...))
}
// TodayImageCountGT applies the GT predicate on the "today_image_count" field.
func TodayImageCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayImageCount, v))
}
// TodayImageCountGTE applies the GTE predicate on the "today_image_count" field.
func TodayImageCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayImageCount, v))
}
// TodayImageCountLT applies the LT predicate on the "today_image_count" field.
func TodayImageCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayImageCount, v))
}
// TodayImageCountLTE applies the LTE predicate on the "today_image_count" field.
func TodayImageCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayImageCount, v))
}
// TodayVideoCountEQ applies the EQ predicate on the "today_video_count" field.
func TodayVideoCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayVideoCount, v))
}
// TodayVideoCountNEQ applies the NEQ predicate on the "today_video_count" field.
func TodayVideoCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayVideoCount, v))
}
// TodayVideoCountIn applies the In predicate on the "today_video_count" field.
func TodayVideoCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayVideoCount, vs...))
}
// TodayVideoCountNotIn applies the NotIn predicate on the "today_video_count" field.
func TodayVideoCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayVideoCount, vs...))
}
// TodayVideoCountGT applies the GT predicate on the "today_video_count" field.
func TodayVideoCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayVideoCount, v))
}
// TodayVideoCountGTE applies the GTE predicate on the "today_video_count" field.
func TodayVideoCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayVideoCount, v))
}
// TodayVideoCountLT applies the LT predicate on the "today_video_count" field.
func TodayVideoCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayVideoCount, v))
}
// TodayVideoCountLTE applies the LTE predicate on the "today_video_count" field.
func TodayVideoCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayVideoCount, v))
}
// TodayErrorCountEQ applies the EQ predicate on the "today_error_count" field.
func TodayErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayErrorCount, v))
}
// TodayErrorCountNEQ applies the NEQ predicate on the "today_error_count" field.
func TodayErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayErrorCount, v))
}
// TodayErrorCountIn applies the In predicate on the "today_error_count" field.
func TodayErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayErrorCount, vs...))
}
// TodayErrorCountNotIn applies the NotIn predicate on the "today_error_count" field.
func TodayErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayErrorCount, vs...))
}
// TodayErrorCountGT applies the GT predicate on the "today_error_count" field.
func TodayErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayErrorCount, v))
}
// TodayErrorCountGTE applies the GTE predicate on the "today_error_count" field.
func TodayErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayErrorCount, v))
}
// TodayErrorCountLT applies the LT predicate on the "today_error_count" field.
func TodayErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayErrorCount, v))
}
// TodayErrorCountLTE applies the LTE predicate on the "today_error_count" field.
func TodayErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayErrorCount, v))
}
// TodayDateEQ applies the EQ predicate on the "today_date" field.
func TodayDateEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayDate, v))
}
// TodayDateNEQ applies the NEQ predicate on the "today_date" field.
func TodayDateNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayDate, v))
}
// TodayDateIn applies the In predicate on the "today_date" field.
func TodayDateIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayDate, vs...))
}
// TodayDateNotIn applies the NotIn predicate on the "today_date" field.
func TodayDateNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayDate, vs...))
}
// TodayDateGT applies the GT predicate on the "today_date" field.
func TodayDateGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayDate, v))
}
// TodayDateGTE applies the GTE predicate on the "today_date" field.
func TodayDateGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayDate, v))
}
// TodayDateLT applies the LT predicate on the "today_date" field.
func TodayDateLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayDate, v))
}
// TodayDateLTE applies the LTE predicate on the "today_date" field.
func TodayDateLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayDate, v))
}
// TodayDateIsNil applies the IsNil predicate on the "today_date" field.
func TodayDateIsNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIsNull(FieldTodayDate))
}
// TodayDateNotNil applies the NotNil predicate on the "today_date" field.
func TodayDateNotNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotNull(FieldTodayDate))
}
// ConsecutiveErrorCountEQ applies the EQ predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountNEQ applies the NEQ predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountIn applies the In predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldConsecutiveErrorCount, vs...))
}
// ConsecutiveErrorCountNotIn applies the NotIn predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldConsecutiveErrorCount, vs...))
}
// ConsecutiveErrorCountGT applies the GT predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountGTE applies the GTE predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountLT applies the LT predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountLTE applies the LTE predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldConsecutiveErrorCount, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.NotPredicates(p))
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
// 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/sorausagestat"
)
// SoraUsageStatDelete is the builder for deleting a SoraUsageStat entity.
type SoraUsageStatDelete struct {
config
hooks []Hook
mutation *SoraUsageStatMutation
}
// Where appends a list predicates to the SoraUsageStatDelete builder.
func (_d *SoraUsageStatDelete) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraUsageStatDelete) 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 *SoraUsageStatDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraUsageStatDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(sorausagestat.Table, sqlgraph.NewFieldSpec(sorausagestat.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
}
// SoraUsageStatDeleteOne is the builder for deleting a single SoraUsageStat entity.
type SoraUsageStatDeleteOne struct {
_d *SoraUsageStatDelete
}
// Where appends a list predicates to the SoraUsageStatDelete builder.
func (_d *SoraUsageStatDeleteOne) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraUsageStatDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{sorausagestat.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraUsageStatDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,564 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"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/sorausagestat"
)
// SoraUsageStatQuery is the builder for querying SoraUsageStat entities.
type SoraUsageStatQuery struct {
config
ctx *QueryContext
order []sorausagestat.OrderOption
inters []Interceptor
predicates []predicate.SoraUsageStat
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraUsageStatQuery builder.
func (_q *SoraUsageStatQuery) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraUsageStatQuery) Limit(limit int) *SoraUsageStatQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraUsageStatQuery) Offset(offset int) *SoraUsageStatQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraUsageStatQuery) Unique(unique bool) *SoraUsageStatQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraUsageStatQuery) Order(o ...sorausagestat.OrderOption) *SoraUsageStatQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraUsageStat entity from the query.
// Returns a *NotFoundError when no SoraUsageStat was found.
func (_q *SoraUsageStatQuery) First(ctx context.Context) (*SoraUsageStat, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{sorausagestat.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraUsageStatQuery) FirstX(ctx context.Context) *SoraUsageStat {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraUsageStat ID from the query.
// Returns a *NotFoundError when no SoraUsageStat ID was found.
func (_q *SoraUsageStatQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{sorausagestat.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraUsageStatQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraUsageStat entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraUsageStat entity is found.
// Returns a *NotFoundError when no SoraUsageStat entities are found.
func (_q *SoraUsageStatQuery) Only(ctx context.Context) (*SoraUsageStat, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{sorausagestat.Label}
default:
return nil, &NotSingularError{sorausagestat.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraUsageStatQuery) OnlyX(ctx context.Context) *SoraUsageStat {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraUsageStat ID in the query.
// Returns a *NotSingularError when more than one SoraUsageStat ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraUsageStatQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{sorausagestat.Label}
default:
err = &NotSingularError{sorausagestat.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraUsageStatQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraUsageStats.
func (_q *SoraUsageStatQuery) All(ctx context.Context) ([]*SoraUsageStat, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraUsageStat, *SoraUsageStatQuery]()
return withInterceptors[[]*SoraUsageStat](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraUsageStatQuery) AllX(ctx context.Context) []*SoraUsageStat {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraUsageStat IDs.
func (_q *SoraUsageStatQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(sorausagestat.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraUsageStatQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraUsageStatQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraUsageStatQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraUsageStatQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraUsageStatQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraUsageStatQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraUsageStatQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraUsageStatQuery) Clone() *SoraUsageStatQuery {
if _q == nil {
return nil
}
return &SoraUsageStatQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]sorausagestat.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraUsageStat{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraUsageStat.Query().
// GroupBy(sorausagestat.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraUsageStatQuery) GroupBy(field string, fields ...string) *SoraUsageStatGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraUsageStatGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = sorausagestat.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.SoraUsageStat.Query().
// Select(sorausagestat.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *SoraUsageStatQuery) Select(fields ...string) *SoraUsageStatSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraUsageStatSelect{SoraUsageStatQuery: _q}
sbuild.label = sorausagestat.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraUsageStatSelect configured with the given aggregations.
func (_q *SoraUsageStatQuery) Aggregate(fns ...AggregateFunc) *SoraUsageStatSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraUsageStatQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !sorausagestat.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraUsageStatQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraUsageStat, error) {
var (
nodes = []*SoraUsageStat{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraUsageStat).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraUsageStat{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraUsageStatQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraUsageStatQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(sorausagestat.Table, sorausagestat.Columns, sqlgraph.NewFieldSpec(sorausagestat.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, sorausagestat.FieldID)
for i := range fields {
if fields[i] != sorausagestat.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraUsageStatQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(sorausagestat.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = sorausagestat.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraUsageStatQuery) ForUpdate(opts ...sql.LockOption) *SoraUsageStatQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraUsageStatQuery) ForShare(opts ...sql.LockOption) *SoraUsageStatQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraUsageStatGroupBy is the group-by builder for SoraUsageStat entities.
type SoraUsageStatGroupBy struct {
selector
build *SoraUsageStatQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraUsageStatGroupBy) Aggregate(fns ...AggregateFunc) *SoraUsageStatGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraUsageStatGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraUsageStatQuery, *SoraUsageStatGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraUsageStatGroupBy) sqlScan(ctx context.Context, root *SoraUsageStatQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraUsageStatSelect is the builder for selecting fields of SoraUsageStat entities.
type SoraUsageStatSelect struct {
*SoraUsageStatQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraUsageStatSelect) Aggregate(fns ...AggregateFunc) *SoraUsageStatSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraUsageStatSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraUsageStatQuery, *SoraUsageStatSelect](ctx, _s.SoraUsageStatQuery, _s, _s.inters, v)
}
func (_s *SoraUsageStatSelect) sqlScan(ctx context.Context, root *SoraUsageStatQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -0,0 +1,748 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"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/sorausagestat"
)
// SoraUsageStatUpdate is the builder for updating SoraUsageStat entities.
type SoraUsageStatUpdate struct {
config
hooks []Hook
mutation *SoraUsageStatMutation
}
// Where appends a list predicates to the SoraUsageStatUpdate builder.
func (_u *SoraUsageStatUpdate) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *SoraUsageStatUpdate) SetUpdatedAt(v time.Time) *SoraUsageStatUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraUsageStatUpdate) SetAccountID(v int64) *SoraUsageStatUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableAccountID(v *int64) *SoraUsageStatUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraUsageStatUpdate) AddAccountID(v int64) *SoraUsageStatUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetImageCount sets the "image_count" field.
func (_u *SoraUsageStatUpdate) SetImageCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetImageCount()
_u.mutation.SetImageCount(v)
return _u
}
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableImageCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetImageCount(*v)
}
return _u
}
// AddImageCount adds value to the "image_count" field.
func (_u *SoraUsageStatUpdate) AddImageCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddImageCount(v)
return _u
}
// SetVideoCount sets the "video_count" field.
func (_u *SoraUsageStatUpdate) SetVideoCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetVideoCount()
_u.mutation.SetVideoCount(v)
return _u
}
// SetNillableVideoCount sets the "video_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableVideoCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetVideoCount(*v)
}
return _u
}
// AddVideoCount adds value to the "video_count" field.
func (_u *SoraUsageStatUpdate) AddVideoCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddVideoCount(v)
return _u
}
// SetErrorCount sets the "error_count" field.
func (_u *SoraUsageStatUpdate) SetErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetErrorCount()
_u.mutation.SetErrorCount(v)
return _u
}
// SetNillableErrorCount sets the "error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableErrorCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetErrorCount(*v)
}
return _u
}
// AddErrorCount adds value to the "error_count" field.
func (_u *SoraUsageStatUpdate) AddErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddErrorCount(v)
return _u
}
// SetLastErrorAt sets the "last_error_at" field.
func (_u *SoraUsageStatUpdate) SetLastErrorAt(v time.Time) *SoraUsageStatUpdate {
_u.mutation.SetLastErrorAt(v)
return _u
}
// SetNillableLastErrorAt sets the "last_error_at" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableLastErrorAt(v *time.Time) *SoraUsageStatUpdate {
if v != nil {
_u.SetLastErrorAt(*v)
}
return _u
}
// ClearLastErrorAt clears the value of the "last_error_at" field.
func (_u *SoraUsageStatUpdate) ClearLastErrorAt() *SoraUsageStatUpdate {
_u.mutation.ClearLastErrorAt()
return _u
}
// SetTodayImageCount sets the "today_image_count" field.
func (_u *SoraUsageStatUpdate) SetTodayImageCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetTodayImageCount()
_u.mutation.SetTodayImageCount(v)
return _u
}
// SetNillableTodayImageCount sets the "today_image_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableTodayImageCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetTodayImageCount(*v)
}
return _u
}
// AddTodayImageCount adds value to the "today_image_count" field.
func (_u *SoraUsageStatUpdate) AddTodayImageCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddTodayImageCount(v)
return _u
}
// SetTodayVideoCount sets the "today_video_count" field.
func (_u *SoraUsageStatUpdate) SetTodayVideoCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetTodayVideoCount()
_u.mutation.SetTodayVideoCount(v)
return _u
}
// SetNillableTodayVideoCount sets the "today_video_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableTodayVideoCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetTodayVideoCount(*v)
}
return _u
}
// AddTodayVideoCount adds value to the "today_video_count" field.
func (_u *SoraUsageStatUpdate) AddTodayVideoCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddTodayVideoCount(v)
return _u
}
// SetTodayErrorCount sets the "today_error_count" field.
func (_u *SoraUsageStatUpdate) SetTodayErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetTodayErrorCount()
_u.mutation.SetTodayErrorCount(v)
return _u
}
// SetNillableTodayErrorCount sets the "today_error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableTodayErrorCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetTodayErrorCount(*v)
}
return _u
}
// AddTodayErrorCount adds value to the "today_error_count" field.
func (_u *SoraUsageStatUpdate) AddTodayErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddTodayErrorCount(v)
return _u
}
// SetTodayDate sets the "today_date" field.
func (_u *SoraUsageStatUpdate) SetTodayDate(v time.Time) *SoraUsageStatUpdate {
_u.mutation.SetTodayDate(v)
return _u
}
// SetNillableTodayDate sets the "today_date" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableTodayDate(v *time.Time) *SoraUsageStatUpdate {
if v != nil {
_u.SetTodayDate(*v)
}
return _u
}
// ClearTodayDate clears the value of the "today_date" field.
func (_u *SoraUsageStatUpdate) ClearTodayDate() *SoraUsageStatUpdate {
_u.mutation.ClearTodayDate()
return _u
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (_u *SoraUsageStatUpdate) SetConsecutiveErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.ResetConsecutiveErrorCount()
_u.mutation.SetConsecutiveErrorCount(v)
return _u
}
// SetNillableConsecutiveErrorCount sets the "consecutive_error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdate) SetNillableConsecutiveErrorCount(v *int) *SoraUsageStatUpdate {
if v != nil {
_u.SetConsecutiveErrorCount(*v)
}
return _u
}
// AddConsecutiveErrorCount adds value to the "consecutive_error_count" field.
func (_u *SoraUsageStatUpdate) AddConsecutiveErrorCount(v int) *SoraUsageStatUpdate {
_u.mutation.AddConsecutiveErrorCount(v)
return _u
}
// Mutation returns the SoraUsageStatMutation object of the builder.
func (_u *SoraUsageStatUpdate) Mutation() *SoraUsageStatMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraUsageStatUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraUsageStatUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraUsageStatUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraUsageStatUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *SoraUsageStatUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := sorausagestat.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
func (_u *SoraUsageStatUpdate) sqlSave(ctx context.Context) (_node int, err error) {
_spec := sqlgraph.NewUpdateSpec(sorausagestat.Table, sorausagestat.Columns, sqlgraph.NewFieldSpec(sorausagestat.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(sorausagestat.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(sorausagestat.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(sorausagestat.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.ImageCount(); ok {
_spec.SetField(sorausagestat.FieldImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedImageCount(); ok {
_spec.AddField(sorausagestat.FieldImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.VideoCount(); ok {
_spec.SetField(sorausagestat.FieldVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedVideoCount(); ok {
_spec.AddField(sorausagestat.FieldVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.ErrorCount(); ok {
_spec.SetField(sorausagestat.FieldErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedErrorCount(); ok {
_spec.AddField(sorausagestat.FieldErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.LastErrorAt(); ok {
_spec.SetField(sorausagestat.FieldLastErrorAt, field.TypeTime, value)
}
if _u.mutation.LastErrorAtCleared() {
_spec.ClearField(sorausagestat.FieldLastErrorAt, field.TypeTime)
}
if value, ok := _u.mutation.TodayImageCount(); ok {
_spec.SetField(sorausagestat.FieldTodayImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayImageCount(); ok {
_spec.AddField(sorausagestat.FieldTodayImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayVideoCount(); ok {
_spec.SetField(sorausagestat.FieldTodayVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayVideoCount(); ok {
_spec.AddField(sorausagestat.FieldTodayVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayErrorCount(); ok {
_spec.SetField(sorausagestat.FieldTodayErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayErrorCount(); ok {
_spec.AddField(sorausagestat.FieldTodayErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayDate(); ok {
_spec.SetField(sorausagestat.FieldTodayDate, field.TypeTime, value)
}
if _u.mutation.TodayDateCleared() {
_spec.ClearField(sorausagestat.FieldTodayDate, field.TypeTime)
}
if value, ok := _u.mutation.ConsecutiveErrorCount(); ok {
_spec.SetField(sorausagestat.FieldConsecutiveErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedConsecutiveErrorCount(); ok {
_spec.AddField(sorausagestat.FieldConsecutiveErrorCount, field.TypeInt, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{sorausagestat.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraUsageStatUpdateOne is the builder for updating a single SoraUsageStat entity.
type SoraUsageStatUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraUsageStatMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *SoraUsageStatUpdateOne) SetUpdatedAt(v time.Time) *SoraUsageStatUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraUsageStatUpdateOne) SetAccountID(v int64) *SoraUsageStatUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableAccountID(v *int64) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraUsageStatUpdateOne) AddAccountID(v int64) *SoraUsageStatUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetImageCount sets the "image_count" field.
func (_u *SoraUsageStatUpdateOne) SetImageCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetImageCount()
_u.mutation.SetImageCount(v)
return _u
}
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableImageCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetImageCount(*v)
}
return _u
}
// AddImageCount adds value to the "image_count" field.
func (_u *SoraUsageStatUpdateOne) AddImageCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddImageCount(v)
return _u
}
// SetVideoCount sets the "video_count" field.
func (_u *SoraUsageStatUpdateOne) SetVideoCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetVideoCount()
_u.mutation.SetVideoCount(v)
return _u
}
// SetNillableVideoCount sets the "video_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableVideoCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetVideoCount(*v)
}
return _u
}
// AddVideoCount adds value to the "video_count" field.
func (_u *SoraUsageStatUpdateOne) AddVideoCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddVideoCount(v)
return _u
}
// SetErrorCount sets the "error_count" field.
func (_u *SoraUsageStatUpdateOne) SetErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetErrorCount()
_u.mutation.SetErrorCount(v)
return _u
}
// SetNillableErrorCount sets the "error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableErrorCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetErrorCount(*v)
}
return _u
}
// AddErrorCount adds value to the "error_count" field.
func (_u *SoraUsageStatUpdateOne) AddErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddErrorCount(v)
return _u
}
// SetLastErrorAt sets the "last_error_at" field.
func (_u *SoraUsageStatUpdateOne) SetLastErrorAt(v time.Time) *SoraUsageStatUpdateOne {
_u.mutation.SetLastErrorAt(v)
return _u
}
// SetNillableLastErrorAt sets the "last_error_at" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableLastErrorAt(v *time.Time) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetLastErrorAt(*v)
}
return _u
}
// ClearLastErrorAt clears the value of the "last_error_at" field.
func (_u *SoraUsageStatUpdateOne) ClearLastErrorAt() *SoraUsageStatUpdateOne {
_u.mutation.ClearLastErrorAt()
return _u
}
// SetTodayImageCount sets the "today_image_count" field.
func (_u *SoraUsageStatUpdateOne) SetTodayImageCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetTodayImageCount()
_u.mutation.SetTodayImageCount(v)
return _u
}
// SetNillableTodayImageCount sets the "today_image_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableTodayImageCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetTodayImageCount(*v)
}
return _u
}
// AddTodayImageCount adds value to the "today_image_count" field.
func (_u *SoraUsageStatUpdateOne) AddTodayImageCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddTodayImageCount(v)
return _u
}
// SetTodayVideoCount sets the "today_video_count" field.
func (_u *SoraUsageStatUpdateOne) SetTodayVideoCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetTodayVideoCount()
_u.mutation.SetTodayVideoCount(v)
return _u
}
// SetNillableTodayVideoCount sets the "today_video_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableTodayVideoCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetTodayVideoCount(*v)
}
return _u
}
// AddTodayVideoCount adds value to the "today_video_count" field.
func (_u *SoraUsageStatUpdateOne) AddTodayVideoCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddTodayVideoCount(v)
return _u
}
// SetTodayErrorCount sets the "today_error_count" field.
func (_u *SoraUsageStatUpdateOne) SetTodayErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetTodayErrorCount()
_u.mutation.SetTodayErrorCount(v)
return _u
}
// SetNillableTodayErrorCount sets the "today_error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableTodayErrorCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetTodayErrorCount(*v)
}
return _u
}
// AddTodayErrorCount adds value to the "today_error_count" field.
func (_u *SoraUsageStatUpdateOne) AddTodayErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddTodayErrorCount(v)
return _u
}
// SetTodayDate sets the "today_date" field.
func (_u *SoraUsageStatUpdateOne) SetTodayDate(v time.Time) *SoraUsageStatUpdateOne {
_u.mutation.SetTodayDate(v)
return _u
}
// SetNillableTodayDate sets the "today_date" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableTodayDate(v *time.Time) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetTodayDate(*v)
}
return _u
}
// ClearTodayDate clears the value of the "today_date" field.
func (_u *SoraUsageStatUpdateOne) ClearTodayDate() *SoraUsageStatUpdateOne {
_u.mutation.ClearTodayDate()
return _u
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (_u *SoraUsageStatUpdateOne) SetConsecutiveErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.ResetConsecutiveErrorCount()
_u.mutation.SetConsecutiveErrorCount(v)
return _u
}
// SetNillableConsecutiveErrorCount sets the "consecutive_error_count" field if the given value is not nil.
func (_u *SoraUsageStatUpdateOne) SetNillableConsecutiveErrorCount(v *int) *SoraUsageStatUpdateOne {
if v != nil {
_u.SetConsecutiveErrorCount(*v)
}
return _u
}
// AddConsecutiveErrorCount adds value to the "consecutive_error_count" field.
func (_u *SoraUsageStatUpdateOne) AddConsecutiveErrorCount(v int) *SoraUsageStatUpdateOne {
_u.mutation.AddConsecutiveErrorCount(v)
return _u
}
// Mutation returns the SoraUsageStatMutation object of the builder.
func (_u *SoraUsageStatUpdateOne) Mutation() *SoraUsageStatMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraUsageStatUpdate builder.
func (_u *SoraUsageStatUpdateOne) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *SoraUsageStatUpdateOne) Select(field string, fields ...string) *SoraUsageStatUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraUsageStat entity.
func (_u *SoraUsageStatUpdateOne) Save(ctx context.Context) (*SoraUsageStat, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraUsageStatUpdateOne) SaveX(ctx context.Context) *SoraUsageStat {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraUsageStatUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraUsageStatUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *SoraUsageStatUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := sorausagestat.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
func (_u *SoraUsageStatUpdateOne) sqlSave(ctx context.Context) (_node *SoraUsageStat, err error) {
_spec := sqlgraph.NewUpdateSpec(sorausagestat.Table, sorausagestat.Columns, sqlgraph.NewFieldSpec(sorausagestat.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraUsageStat.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, sorausagestat.FieldID)
for _, f := range fields {
if !sorausagestat.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != sorausagestat.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(sorausagestat.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(sorausagestat.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(sorausagestat.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.ImageCount(); ok {
_spec.SetField(sorausagestat.FieldImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedImageCount(); ok {
_spec.AddField(sorausagestat.FieldImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.VideoCount(); ok {
_spec.SetField(sorausagestat.FieldVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedVideoCount(); ok {
_spec.AddField(sorausagestat.FieldVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.ErrorCount(); ok {
_spec.SetField(sorausagestat.FieldErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedErrorCount(); ok {
_spec.AddField(sorausagestat.FieldErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.LastErrorAt(); ok {
_spec.SetField(sorausagestat.FieldLastErrorAt, field.TypeTime, value)
}
if _u.mutation.LastErrorAtCleared() {
_spec.ClearField(sorausagestat.FieldLastErrorAt, field.TypeTime)
}
if value, ok := _u.mutation.TodayImageCount(); ok {
_spec.SetField(sorausagestat.FieldTodayImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayImageCount(); ok {
_spec.AddField(sorausagestat.FieldTodayImageCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayVideoCount(); ok {
_spec.SetField(sorausagestat.FieldTodayVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayVideoCount(); ok {
_spec.AddField(sorausagestat.FieldTodayVideoCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayErrorCount(); ok {
_spec.SetField(sorausagestat.FieldTodayErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedTodayErrorCount(); ok {
_spec.AddField(sorausagestat.FieldTodayErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.TodayDate(); ok {
_spec.SetField(sorausagestat.FieldTodayDate, field.TypeTime, value)
}
if _u.mutation.TodayDateCleared() {
_spec.ClearField(sorausagestat.FieldTodayDate, field.TypeTime)
}
if value, ok := _u.mutation.ConsecutiveErrorCount(); ok {
_spec.SetField(sorausagestat.FieldConsecutiveErrorCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedConsecutiveErrorCount(); ok {
_spec.AddField(sorausagestat.FieldConsecutiveErrorCount, field.TypeInt, value)
}
_node = &SoraUsageStat{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{sorausagestat.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}

View File

@@ -32,6 +32,14 @@ type Tx struct {
RedeemCode *RedeemCodeClient
// Setting is the client for interacting with the Setting builders.
Setting *SettingClient
// SoraAccount is the client for interacting with the SoraAccount builders.
SoraAccount *SoraAccountClient
// SoraCacheFile is the client for interacting with the SoraCacheFile builders.
SoraCacheFile *SoraCacheFileClient
// SoraTask is the client for interacting with the SoraTask builders.
SoraTask *SoraTaskClient
// SoraUsageStat is the client for interacting with the SoraUsageStat builders.
SoraUsageStat *SoraUsageStatClient
// UsageCleanupTask is the client for interacting with the UsageCleanupTask builders.
UsageCleanupTask *UsageCleanupTaskClient
// UsageLog is the client for interacting with the UsageLog builders.
@@ -186,6 +194,10 @@ func (tx *Tx) init() {
tx.Proxy = NewProxyClient(tx.config)
tx.RedeemCode = NewRedeemCodeClient(tx.config)
tx.Setting = NewSettingClient(tx.config)
tx.SoraAccount = NewSoraAccountClient(tx.config)
tx.SoraCacheFile = NewSoraCacheFileClient(tx.config)
tx.SoraTask = NewSoraTaskClient(tx.config)
tx.SoraUsageStat = NewSoraUsageStatClient(tx.config)
tx.UsageCleanupTask = NewUsageCleanupTaskClient(tx.config)
tx.UsageLog = NewUsageLogClient(tx.config)
tx.User = NewUserClient(tx.config)