[feature] migrate to monorepo
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s

This commit is contained in:
CDN 2025-02-21 00:49:20 +08:00
commit 05ddc1f783
Signed by: CDN
GPG key ID: 0C656827F9F80080
267 changed files with 75165 additions and 0 deletions

629
backend/ent/media_update.go Normal file
View file

@ -0,0 +1,629 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"tss-rocks-be/ent/media"
"tss-rocks-be/ent/predicate"
"tss-rocks-be/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// MediaUpdate is the builder for updating Media entities.
type MediaUpdate struct {
config
hooks []Hook
mutation *MediaMutation
}
// Where appends a list predicates to the MediaUpdate builder.
func (mu *MediaUpdate) Where(ps ...predicate.Media) *MediaUpdate {
mu.mutation.Where(ps...)
return mu
}
// SetStorageID sets the "storage_id" field.
func (mu *MediaUpdate) SetStorageID(s string) *MediaUpdate {
mu.mutation.SetStorageID(s)
return mu
}
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableStorageID(s *string) *MediaUpdate {
if s != nil {
mu.SetStorageID(*s)
}
return mu
}
// SetOriginalName sets the "original_name" field.
func (mu *MediaUpdate) SetOriginalName(s string) *MediaUpdate {
mu.mutation.SetOriginalName(s)
return mu
}
// SetNillableOriginalName sets the "original_name" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableOriginalName(s *string) *MediaUpdate {
if s != nil {
mu.SetOriginalName(*s)
}
return mu
}
// SetMimeType sets the "mime_type" field.
func (mu *MediaUpdate) SetMimeType(s string) *MediaUpdate {
mu.mutation.SetMimeType(s)
return mu
}
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableMimeType(s *string) *MediaUpdate {
if s != nil {
mu.SetMimeType(*s)
}
return mu
}
// SetSize sets the "size" field.
func (mu *MediaUpdate) SetSize(i int64) *MediaUpdate {
mu.mutation.ResetSize()
mu.mutation.SetSize(i)
return mu
}
// SetNillableSize sets the "size" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableSize(i *int64) *MediaUpdate {
if i != nil {
mu.SetSize(*i)
}
return mu
}
// AddSize adds i to the "size" field.
func (mu *MediaUpdate) AddSize(i int64) *MediaUpdate {
mu.mutation.AddSize(i)
return mu
}
// SetURL sets the "url" field.
func (mu *MediaUpdate) SetURL(s string) *MediaUpdate {
mu.mutation.SetURL(s)
return mu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableURL(s *string) *MediaUpdate {
if s != nil {
mu.SetURL(*s)
}
return mu
}
// SetUpdatedAt sets the "updated_at" field.
func (mu *MediaUpdate) SetUpdatedAt(t time.Time) *MediaUpdate {
mu.mutation.SetUpdatedAt(t)
return mu
}
// SetCreatedBy sets the "created_by" field.
func (mu *MediaUpdate) SetCreatedBy(s string) *MediaUpdate {
mu.mutation.SetCreatedBy(s)
return mu
}
// SetNillableCreatedBy sets the "created_by" field if the given value is not nil.
func (mu *MediaUpdate) SetNillableCreatedBy(s *string) *MediaUpdate {
if s != nil {
mu.SetCreatedBy(*s)
}
return mu
}
// ClearCreatedBy clears the value of the "created_by" field.
func (mu *MediaUpdate) ClearCreatedBy() *MediaUpdate {
mu.mutation.ClearCreatedBy()
return mu
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (mu *MediaUpdate) SetOwnerID(id int) *MediaUpdate {
mu.mutation.SetOwnerID(id)
return mu
}
// SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil.
func (mu *MediaUpdate) SetNillableOwnerID(id *int) *MediaUpdate {
if id != nil {
mu = mu.SetOwnerID(*id)
}
return mu
}
// SetOwner sets the "owner" edge to the User entity.
func (mu *MediaUpdate) SetOwner(u *User) *MediaUpdate {
return mu.SetOwnerID(u.ID)
}
// Mutation returns the MediaMutation object of the builder.
func (mu *MediaUpdate) Mutation() *MediaMutation {
return mu.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (mu *MediaUpdate) ClearOwner() *MediaUpdate {
mu.mutation.ClearOwner()
return mu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MediaUpdate) Save(ctx context.Context) (int, error) {
mu.defaults()
return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (mu *MediaUpdate) SaveX(ctx context.Context) int {
affected, err := mu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (mu *MediaUpdate) Exec(ctx context.Context) error {
_, err := mu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (mu *MediaUpdate) ExecX(ctx context.Context) {
if err := mu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (mu *MediaUpdate) defaults() {
if _, ok := mu.mutation.UpdatedAt(); !ok {
v := media.UpdateDefaultUpdatedAt()
mu.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (mu *MediaUpdate) check() error {
if v, ok := mu.mutation.StorageID(); ok {
if err := media.StorageIDValidator(v); err != nil {
return &ValidationError{Name: "storage_id", err: fmt.Errorf(`ent: validator failed for field "Media.storage_id": %w`, err)}
}
}
if v, ok := mu.mutation.OriginalName(); ok {
if err := media.OriginalNameValidator(v); err != nil {
return &ValidationError{Name: "original_name", err: fmt.Errorf(`ent: validator failed for field "Media.original_name": %w`, err)}
}
}
if v, ok := mu.mutation.MimeType(); ok {
if err := media.MimeTypeValidator(v); err != nil {
return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "Media.mime_type": %w`, err)}
}
}
if v, ok := mu.mutation.Size(); ok {
if err := media.SizeValidator(v); err != nil {
return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "Media.size": %w`, err)}
}
}
if v, ok := mu.mutation.URL(); ok {
if err := media.URLValidator(v); err != nil {
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Media.url": %w`, err)}
}
}
return nil
}
func (mu *MediaUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := mu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(media.Table, media.Columns, sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt))
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := mu.mutation.StorageID(); ok {
_spec.SetField(media.FieldStorageID, field.TypeString, value)
}
if value, ok := mu.mutation.OriginalName(); ok {
_spec.SetField(media.FieldOriginalName, field.TypeString, value)
}
if value, ok := mu.mutation.MimeType(); ok {
_spec.SetField(media.FieldMimeType, field.TypeString, value)
}
if value, ok := mu.mutation.Size(); ok {
_spec.SetField(media.FieldSize, field.TypeInt64, value)
}
if value, ok := mu.mutation.AddedSize(); ok {
_spec.AddField(media.FieldSize, field.TypeInt64, value)
}
if value, ok := mu.mutation.URL(); ok {
_spec.SetField(media.FieldURL, field.TypeString, value)
}
if value, ok := mu.mutation.UpdatedAt(); ok {
_spec.SetField(media.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := mu.mutation.CreatedBy(); ok {
_spec.SetField(media.FieldCreatedBy, field.TypeString, value)
}
if mu.mutation.CreatedByCleared() {
_spec.ClearField(media.FieldCreatedBy, field.TypeString)
}
if mu.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: media.OwnerTable,
Columns: []string{media.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := mu.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: media.OwnerTable,
Columns: []string{media.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{media.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
mu.mutation.done = true
return n, nil
}
// MediaUpdateOne is the builder for updating a single Media entity.
type MediaUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MediaMutation
}
// SetStorageID sets the "storage_id" field.
func (muo *MediaUpdateOne) SetStorageID(s string) *MediaUpdateOne {
muo.mutation.SetStorageID(s)
return muo
}
// SetNillableStorageID sets the "storage_id" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableStorageID(s *string) *MediaUpdateOne {
if s != nil {
muo.SetStorageID(*s)
}
return muo
}
// SetOriginalName sets the "original_name" field.
func (muo *MediaUpdateOne) SetOriginalName(s string) *MediaUpdateOne {
muo.mutation.SetOriginalName(s)
return muo
}
// SetNillableOriginalName sets the "original_name" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableOriginalName(s *string) *MediaUpdateOne {
if s != nil {
muo.SetOriginalName(*s)
}
return muo
}
// SetMimeType sets the "mime_type" field.
func (muo *MediaUpdateOne) SetMimeType(s string) *MediaUpdateOne {
muo.mutation.SetMimeType(s)
return muo
}
// SetNillableMimeType sets the "mime_type" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableMimeType(s *string) *MediaUpdateOne {
if s != nil {
muo.SetMimeType(*s)
}
return muo
}
// SetSize sets the "size" field.
func (muo *MediaUpdateOne) SetSize(i int64) *MediaUpdateOne {
muo.mutation.ResetSize()
muo.mutation.SetSize(i)
return muo
}
// SetNillableSize sets the "size" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableSize(i *int64) *MediaUpdateOne {
if i != nil {
muo.SetSize(*i)
}
return muo
}
// AddSize adds i to the "size" field.
func (muo *MediaUpdateOne) AddSize(i int64) *MediaUpdateOne {
muo.mutation.AddSize(i)
return muo
}
// SetURL sets the "url" field.
func (muo *MediaUpdateOne) SetURL(s string) *MediaUpdateOne {
muo.mutation.SetURL(s)
return muo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableURL(s *string) *MediaUpdateOne {
if s != nil {
muo.SetURL(*s)
}
return muo
}
// SetUpdatedAt sets the "updated_at" field.
func (muo *MediaUpdateOne) SetUpdatedAt(t time.Time) *MediaUpdateOne {
muo.mutation.SetUpdatedAt(t)
return muo
}
// SetCreatedBy sets the "created_by" field.
func (muo *MediaUpdateOne) SetCreatedBy(s string) *MediaUpdateOne {
muo.mutation.SetCreatedBy(s)
return muo
}
// SetNillableCreatedBy sets the "created_by" field if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableCreatedBy(s *string) *MediaUpdateOne {
if s != nil {
muo.SetCreatedBy(*s)
}
return muo
}
// ClearCreatedBy clears the value of the "created_by" field.
func (muo *MediaUpdateOne) ClearCreatedBy() *MediaUpdateOne {
muo.mutation.ClearCreatedBy()
return muo
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (muo *MediaUpdateOne) SetOwnerID(id int) *MediaUpdateOne {
muo.mutation.SetOwnerID(id)
return muo
}
// SetNillableOwnerID sets the "owner" edge to the User entity by ID if the given value is not nil.
func (muo *MediaUpdateOne) SetNillableOwnerID(id *int) *MediaUpdateOne {
if id != nil {
muo = muo.SetOwnerID(*id)
}
return muo
}
// SetOwner sets the "owner" edge to the User entity.
func (muo *MediaUpdateOne) SetOwner(u *User) *MediaUpdateOne {
return muo.SetOwnerID(u.ID)
}
// Mutation returns the MediaMutation object of the builder.
func (muo *MediaUpdateOne) Mutation() *MediaMutation {
return muo.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (muo *MediaUpdateOne) ClearOwner() *MediaUpdateOne {
muo.mutation.ClearOwner()
return muo
}
// Where appends a list predicates to the MediaUpdate builder.
func (muo *MediaUpdateOne) Where(ps ...predicate.Media) *MediaUpdateOne {
muo.mutation.Where(ps...)
return muo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (muo *MediaUpdateOne) Select(field string, fields ...string) *MediaUpdateOne {
muo.fields = append([]string{field}, fields...)
return muo
}
// Save executes the query and returns the updated Media entity.
func (muo *MediaUpdateOne) Save(ctx context.Context) (*Media, error) {
muo.defaults()
return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (muo *MediaUpdateOne) SaveX(ctx context.Context) *Media {
node, err := muo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (muo *MediaUpdateOne) Exec(ctx context.Context) error {
_, err := muo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (muo *MediaUpdateOne) ExecX(ctx context.Context) {
if err := muo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (muo *MediaUpdateOne) defaults() {
if _, ok := muo.mutation.UpdatedAt(); !ok {
v := media.UpdateDefaultUpdatedAt()
muo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (muo *MediaUpdateOne) check() error {
if v, ok := muo.mutation.StorageID(); ok {
if err := media.StorageIDValidator(v); err != nil {
return &ValidationError{Name: "storage_id", err: fmt.Errorf(`ent: validator failed for field "Media.storage_id": %w`, err)}
}
}
if v, ok := muo.mutation.OriginalName(); ok {
if err := media.OriginalNameValidator(v); err != nil {
return &ValidationError{Name: "original_name", err: fmt.Errorf(`ent: validator failed for field "Media.original_name": %w`, err)}
}
}
if v, ok := muo.mutation.MimeType(); ok {
if err := media.MimeTypeValidator(v); err != nil {
return &ValidationError{Name: "mime_type", err: fmt.Errorf(`ent: validator failed for field "Media.mime_type": %w`, err)}
}
}
if v, ok := muo.mutation.Size(); ok {
if err := media.SizeValidator(v); err != nil {
return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "Media.size": %w`, err)}
}
}
if v, ok := muo.mutation.URL(); ok {
if err := media.URLValidator(v); err != nil {
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Media.url": %w`, err)}
}
}
return nil
}
func (muo *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error) {
if err := muo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(media.Table, media.Columns, sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt))
id, ok := muo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Media.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := muo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, media.FieldID)
for _, f := range fields {
if !media.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != media.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := muo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := muo.mutation.StorageID(); ok {
_spec.SetField(media.FieldStorageID, field.TypeString, value)
}
if value, ok := muo.mutation.OriginalName(); ok {
_spec.SetField(media.FieldOriginalName, field.TypeString, value)
}
if value, ok := muo.mutation.MimeType(); ok {
_spec.SetField(media.FieldMimeType, field.TypeString, value)
}
if value, ok := muo.mutation.Size(); ok {
_spec.SetField(media.FieldSize, field.TypeInt64, value)
}
if value, ok := muo.mutation.AddedSize(); ok {
_spec.AddField(media.FieldSize, field.TypeInt64, value)
}
if value, ok := muo.mutation.URL(); ok {
_spec.SetField(media.FieldURL, field.TypeString, value)
}
if value, ok := muo.mutation.UpdatedAt(); ok {
_spec.SetField(media.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := muo.mutation.CreatedBy(); ok {
_spec.SetField(media.FieldCreatedBy, field.TypeString, value)
}
if muo.mutation.CreatedByCleared() {
_spec.ClearField(media.FieldCreatedBy, field.TypeString)
}
if muo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: media.OwnerTable,
Columns: []string{media.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := muo.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: media.OwnerTable,
Columns: []string{media.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Media{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{media.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
muo.mutation.done = true
return _node, nil
}