[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
484
backend/ent/categorycontent_update.go
Normal file
484
backend/ent/categorycontent_update.go
Normal file
|
@ -0,0 +1,484 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"tss-rocks-be/ent/category"
|
||||
"tss-rocks-be/ent/categorycontent"
|
||||
"tss-rocks-be/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CategoryContentUpdate is the builder for updating CategoryContent entities.
|
||||
type CategoryContentUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CategoryContentMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategoryContentUpdate builder.
|
||||
func (ccu *CategoryContentUpdate) Where(ps ...predicate.CategoryContent) *CategoryContentUpdate {
|
||||
ccu.mutation.Where(ps...)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetLanguageCode sets the "language_code" field.
|
||||
func (ccu *CategoryContentUpdate) SetLanguageCode(cc categorycontent.LanguageCode) *CategoryContentUpdate {
|
||||
ccu.mutation.SetLanguageCode(cc)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetNillableLanguageCode sets the "language_code" field if the given value is not nil.
|
||||
func (ccu *CategoryContentUpdate) SetNillableLanguageCode(cc *categorycontent.LanguageCode) *CategoryContentUpdate {
|
||||
if cc != nil {
|
||||
ccu.SetLanguageCode(*cc)
|
||||
}
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ccu *CategoryContentUpdate) SetName(s string) *CategoryContentUpdate {
|
||||
ccu.mutation.SetName(s)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ccu *CategoryContentUpdate) SetNillableName(s *string) *CategoryContentUpdate {
|
||||
if s != nil {
|
||||
ccu.SetName(*s)
|
||||
}
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (ccu *CategoryContentUpdate) SetDescription(s string) *CategoryContentUpdate {
|
||||
ccu.mutation.SetDescription(s)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (ccu *CategoryContentUpdate) SetNillableDescription(s *string) *CategoryContentUpdate {
|
||||
if s != nil {
|
||||
ccu.SetDescription(*s)
|
||||
}
|
||||
return ccu
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (ccu *CategoryContentUpdate) ClearDescription() *CategoryContentUpdate {
|
||||
ccu.mutation.ClearDescription()
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (ccu *CategoryContentUpdate) SetSlug(s string) *CategoryContentUpdate {
|
||||
ccu.mutation.SetSlug(s)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (ccu *CategoryContentUpdate) SetNillableSlug(s *string) *CategoryContentUpdate {
|
||||
if s != nil {
|
||||
ccu.SetSlug(*s)
|
||||
}
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetCategoryID sets the "category" edge to the Category entity by ID.
|
||||
func (ccu *CategoryContentUpdate) SetCategoryID(id int) *CategoryContentUpdate {
|
||||
ccu.mutation.SetCategoryID(id)
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetNillableCategoryID sets the "category" edge to the Category entity by ID if the given value is not nil.
|
||||
func (ccu *CategoryContentUpdate) SetNillableCategoryID(id *int) *CategoryContentUpdate {
|
||||
if id != nil {
|
||||
ccu = ccu.SetCategoryID(*id)
|
||||
}
|
||||
return ccu
|
||||
}
|
||||
|
||||
// SetCategory sets the "category" edge to the Category entity.
|
||||
func (ccu *CategoryContentUpdate) SetCategory(c *Category) *CategoryContentUpdate {
|
||||
return ccu.SetCategoryID(c.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CategoryContentMutation object of the builder.
|
||||
func (ccu *CategoryContentUpdate) Mutation() *CategoryContentMutation {
|
||||
return ccu.mutation
|
||||
}
|
||||
|
||||
// ClearCategory clears the "category" edge to the Category entity.
|
||||
func (ccu *CategoryContentUpdate) ClearCategory() *CategoryContentUpdate {
|
||||
ccu.mutation.ClearCategory()
|
||||
return ccu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (ccu *CategoryContentUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ccu.sqlSave, ccu.mutation, ccu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ccu *CategoryContentUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := ccu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ccu *CategoryContentUpdate) Exec(ctx context.Context) error {
|
||||
_, err := ccu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ccu *CategoryContentUpdate) ExecX(ctx context.Context) {
|
||||
if err := ccu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ccu *CategoryContentUpdate) check() error {
|
||||
if v, ok := ccu.mutation.LanguageCode(); ok {
|
||||
if err := categorycontent.LanguageCodeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "language_code", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.language_code": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := ccu.mutation.Name(); ok {
|
||||
if err := categorycontent.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := ccu.mutation.Slug(); ok {
|
||||
if err := categorycontent.SlugValidator(v); err != nil {
|
||||
return &ValidationError{Name: "slug", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.slug": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ccu *CategoryContentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := ccu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(categorycontent.Table, categorycontent.Columns, sqlgraph.NewFieldSpec(categorycontent.FieldID, field.TypeInt))
|
||||
if ps := ccu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := ccu.mutation.LanguageCode(); ok {
|
||||
_spec.SetField(categorycontent.FieldLanguageCode, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := ccu.mutation.Name(); ok {
|
||||
_spec.SetField(categorycontent.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ccu.mutation.Description(); ok {
|
||||
_spec.SetField(categorycontent.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if ccu.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(categorycontent.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := ccu.mutation.Slug(); ok {
|
||||
_spec.SetField(categorycontent.FieldSlug, field.TypeString, value)
|
||||
}
|
||||
if ccu.mutation.CategoryCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorycontent.CategoryTable,
|
||||
Columns: []string{categorycontent.CategoryColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := ccu.mutation.CategoryIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorycontent.CategoryTable,
|
||||
Columns: []string{categorycontent.CategoryColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(category.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, ccu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{categorycontent.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
ccu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// CategoryContentUpdateOne is the builder for updating a single CategoryContent entity.
|
||||
type CategoryContentUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *CategoryContentMutation
|
||||
}
|
||||
|
||||
// SetLanguageCode sets the "language_code" field.
|
||||
func (ccuo *CategoryContentUpdateOne) SetLanguageCode(cc categorycontent.LanguageCode) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.SetLanguageCode(cc)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetNillableLanguageCode sets the "language_code" field if the given value is not nil.
|
||||
func (ccuo *CategoryContentUpdateOne) SetNillableLanguageCode(cc *categorycontent.LanguageCode) *CategoryContentUpdateOne {
|
||||
if cc != nil {
|
||||
ccuo.SetLanguageCode(*cc)
|
||||
}
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ccuo *CategoryContentUpdateOne) SetName(s string) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.SetName(s)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ccuo *CategoryContentUpdateOne) SetNillableName(s *string) *CategoryContentUpdateOne {
|
||||
if s != nil {
|
||||
ccuo.SetName(*s)
|
||||
}
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (ccuo *CategoryContentUpdateOne) SetDescription(s string) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.SetDescription(s)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (ccuo *CategoryContentUpdateOne) SetNillableDescription(s *string) *CategoryContentUpdateOne {
|
||||
if s != nil {
|
||||
ccuo.SetDescription(*s)
|
||||
}
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (ccuo *CategoryContentUpdateOne) ClearDescription() *CategoryContentUpdateOne {
|
||||
ccuo.mutation.ClearDescription()
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetSlug sets the "slug" field.
|
||||
func (ccuo *CategoryContentUpdateOne) SetSlug(s string) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.SetSlug(s)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetNillableSlug sets the "slug" field if the given value is not nil.
|
||||
func (ccuo *CategoryContentUpdateOne) SetNillableSlug(s *string) *CategoryContentUpdateOne {
|
||||
if s != nil {
|
||||
ccuo.SetSlug(*s)
|
||||
}
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetCategoryID sets the "category" edge to the Category entity by ID.
|
||||
func (ccuo *CategoryContentUpdateOne) SetCategoryID(id int) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.SetCategoryID(id)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetNillableCategoryID sets the "category" edge to the Category entity by ID if the given value is not nil.
|
||||
func (ccuo *CategoryContentUpdateOne) SetNillableCategoryID(id *int) *CategoryContentUpdateOne {
|
||||
if id != nil {
|
||||
ccuo = ccuo.SetCategoryID(*id)
|
||||
}
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// SetCategory sets the "category" edge to the Category entity.
|
||||
func (ccuo *CategoryContentUpdateOne) SetCategory(c *Category) *CategoryContentUpdateOne {
|
||||
return ccuo.SetCategoryID(c.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CategoryContentMutation object of the builder.
|
||||
func (ccuo *CategoryContentUpdateOne) Mutation() *CategoryContentMutation {
|
||||
return ccuo.mutation
|
||||
}
|
||||
|
||||
// ClearCategory clears the "category" edge to the Category entity.
|
||||
func (ccuo *CategoryContentUpdateOne) ClearCategory() *CategoryContentUpdateOne {
|
||||
ccuo.mutation.ClearCategory()
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CategoryContentUpdate builder.
|
||||
func (ccuo *CategoryContentUpdateOne) Where(ps ...predicate.CategoryContent) *CategoryContentUpdateOne {
|
||||
ccuo.mutation.Where(ps...)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (ccuo *CategoryContentUpdateOne) Select(field string, fields ...string) *CategoryContentUpdateOne {
|
||||
ccuo.fields = append([]string{field}, fields...)
|
||||
return ccuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated CategoryContent entity.
|
||||
func (ccuo *CategoryContentUpdateOne) Save(ctx context.Context) (*CategoryContent, error) {
|
||||
return withHooks(ctx, ccuo.sqlSave, ccuo.mutation, ccuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ccuo *CategoryContentUpdateOne) SaveX(ctx context.Context) *CategoryContent {
|
||||
node, err := ccuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (ccuo *CategoryContentUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := ccuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ccuo *CategoryContentUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := ccuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ccuo *CategoryContentUpdateOne) check() error {
|
||||
if v, ok := ccuo.mutation.LanguageCode(); ok {
|
||||
if err := categorycontent.LanguageCodeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "language_code", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.language_code": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := ccuo.mutation.Name(); ok {
|
||||
if err := categorycontent.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := ccuo.mutation.Slug(); ok {
|
||||
if err := categorycontent.SlugValidator(v); err != nil {
|
||||
return &ValidationError{Name: "slug", err: fmt.Errorf(`ent: validator failed for field "CategoryContent.slug": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ccuo *CategoryContentUpdateOne) sqlSave(ctx context.Context) (_node *CategoryContent, err error) {
|
||||
if err := ccuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(categorycontent.Table, categorycontent.Columns, sqlgraph.NewFieldSpec(categorycontent.FieldID, field.TypeInt))
|
||||
id, ok := ccuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CategoryContent.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := ccuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, categorycontent.FieldID)
|
||||
for _, f := range fields {
|
||||
if !categorycontent.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != categorycontent.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := ccuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := ccuo.mutation.LanguageCode(); ok {
|
||||
_spec.SetField(categorycontent.FieldLanguageCode, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := ccuo.mutation.Name(); ok {
|
||||
_spec.SetField(categorycontent.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ccuo.mutation.Description(); ok {
|
||||
_spec.SetField(categorycontent.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if ccuo.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(categorycontent.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := ccuo.mutation.Slug(); ok {
|
||||
_spec.SetField(categorycontent.FieldSlug, field.TypeString, value)
|
||||
}
|
||||
if ccuo.mutation.CategoryCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorycontent.CategoryTable,
|
||||
Columns: []string{categorycontent.CategoryColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := ccuo.mutation.CategoryIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: categorycontent.CategoryTable,
|
||||
Columns: []string{categorycontent.CategoryColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &CategoryContent{config: ccuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, ccuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{categorycontent.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
ccuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue