429 lines
12 KiB
Go
429 lines
12 KiB
Go
// 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/FrankenBotDev/FrankenAPI/ent/predicate"
|
|
"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse"
|
|
)
|
|
|
|
// SupportResponseUpdate is the builder for updating SupportResponse entities.
|
|
type SupportResponseUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *SupportResponseMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the SupportResponseUpdate builder.
|
|
func (sru *SupportResponseUpdate) Where(ps ...predicate.SupportResponse) *SupportResponseUpdate {
|
|
sru.mutation.Where(ps...)
|
|
return sru
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (sru *SupportResponseUpdate) SetRefid(s string) *SupportResponseUpdate {
|
|
sru.mutation.SetRefid(s)
|
|
return sru
|
|
}
|
|
|
|
// SetWriter sets the "writer" field.
|
|
func (sru *SupportResponseUpdate) SetWriter(s string) *SupportResponseUpdate {
|
|
sru.mutation.SetWriter(s)
|
|
return sru
|
|
}
|
|
|
|
// SetMessage sets the "message" field.
|
|
func (sru *SupportResponseUpdate) SetMessage(s string) *SupportResponseUpdate {
|
|
sru.mutation.SetMessage(s)
|
|
return sru
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (sru *SupportResponseUpdate) SetType(s string) *SupportResponseUpdate {
|
|
sru.mutation.SetType(s)
|
|
return sru
|
|
}
|
|
|
|
// SetRtcchannel sets the "rtcchannel" field.
|
|
func (sru *SupportResponseUpdate) SetRtcchannel(s string) *SupportResponseUpdate {
|
|
sru.mutation.SetRtcchannel(s)
|
|
return sru
|
|
}
|
|
|
|
// SetIsread sets the "isread" field.
|
|
func (sru *SupportResponseUpdate) SetIsread(b bool) *SupportResponseUpdate {
|
|
sru.mutation.SetIsread(b)
|
|
return sru
|
|
}
|
|
|
|
// SetCreated sets the "created" field.
|
|
func (sru *SupportResponseUpdate) SetCreated(t time.Time) *SupportResponseUpdate {
|
|
sru.mutation.SetCreated(t)
|
|
return sru
|
|
}
|
|
|
|
// Mutation returns the SupportResponseMutation object of the builder.
|
|
func (sru *SupportResponseUpdate) Mutation() *SupportResponseMutation {
|
|
return sru.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (sru *SupportResponseUpdate) Save(ctx context.Context) (int, error) {
|
|
var (
|
|
err error
|
|
affected int
|
|
)
|
|
if len(sru.hooks) == 0 {
|
|
affected, err = sru.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*SupportResponseMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
sru.mutation = mutation
|
|
affected, err = sru.sqlSave(ctx)
|
|
mutation.done = true
|
|
return affected, err
|
|
})
|
|
for i := len(sru.hooks) - 1; i >= 0; i-- {
|
|
if sru.hooks[i] == nil {
|
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = sru.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, sru.mutation); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (sru *SupportResponseUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := sru.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (sru *SupportResponseUpdate) Exec(ctx context.Context) error {
|
|
_, err := sru.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sru *SupportResponseUpdate) ExecX(ctx context.Context) {
|
|
if err := sru.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (sru *SupportResponseUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: supportresponse.Table,
|
|
Columns: supportresponse.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: supportresponse.FieldID,
|
|
},
|
|
},
|
|
}
|
|
if ps := sru.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := sru.mutation.Refid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldRefid,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.Writer(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldWriter,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.Message(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldMessage,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.GetType(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldType,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.Rtcchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldRtcchannel,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.Isread(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: supportresponse.FieldIsread,
|
|
})
|
|
}
|
|
if value, ok := sru.mutation.Created(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeTime,
|
|
Value: value,
|
|
Column: supportresponse.FieldCreated,
|
|
})
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, sru.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{supportresponse.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
return n, nil
|
|
}
|
|
|
|
// SupportResponseUpdateOne is the builder for updating a single SupportResponse entity.
|
|
type SupportResponseUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *SupportResponseMutation
|
|
}
|
|
|
|
// SetRefid sets the "refid" field.
|
|
func (sruo *SupportResponseUpdateOne) SetRefid(s string) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetRefid(s)
|
|
return sruo
|
|
}
|
|
|
|
// SetWriter sets the "writer" field.
|
|
func (sruo *SupportResponseUpdateOne) SetWriter(s string) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetWriter(s)
|
|
return sruo
|
|
}
|
|
|
|
// SetMessage sets the "message" field.
|
|
func (sruo *SupportResponseUpdateOne) SetMessage(s string) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetMessage(s)
|
|
return sruo
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (sruo *SupportResponseUpdateOne) SetType(s string) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetType(s)
|
|
return sruo
|
|
}
|
|
|
|
// SetRtcchannel sets the "rtcchannel" field.
|
|
func (sruo *SupportResponseUpdateOne) SetRtcchannel(s string) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetRtcchannel(s)
|
|
return sruo
|
|
}
|
|
|
|
// SetIsread sets the "isread" field.
|
|
func (sruo *SupportResponseUpdateOne) SetIsread(b bool) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetIsread(b)
|
|
return sruo
|
|
}
|
|
|
|
// SetCreated sets the "created" field.
|
|
func (sruo *SupportResponseUpdateOne) SetCreated(t time.Time) *SupportResponseUpdateOne {
|
|
sruo.mutation.SetCreated(t)
|
|
return sruo
|
|
}
|
|
|
|
// Mutation returns the SupportResponseMutation object of the builder.
|
|
func (sruo *SupportResponseUpdateOne) Mutation() *SupportResponseMutation {
|
|
return sruo.mutation
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (sruo *SupportResponseUpdateOne) Select(field string, fields ...string) *SupportResponseUpdateOne {
|
|
sruo.fields = append([]string{field}, fields...)
|
|
return sruo
|
|
}
|
|
|
|
// Save executes the query and returns the updated SupportResponse entity.
|
|
func (sruo *SupportResponseUpdateOne) Save(ctx context.Context) (*SupportResponse, error) {
|
|
var (
|
|
err error
|
|
node *SupportResponse
|
|
)
|
|
if len(sruo.hooks) == 0 {
|
|
node, err = sruo.sqlSave(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*SupportResponseMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
sruo.mutation = mutation
|
|
node, err = sruo.sqlSave(ctx)
|
|
mutation.done = true
|
|
return node, err
|
|
})
|
|
for i := len(sruo.hooks) - 1; i >= 0; i-- {
|
|
if sruo.hooks[i] == nil {
|
|
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = sruo.hooks[i](mut)
|
|
}
|
|
v, err := mut.Mutate(ctx, sruo.mutation)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
nv, ok := v.(*SupportResponse)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected node type %T returned from SupportResponseMutation", v)
|
|
}
|
|
node = nv
|
|
}
|
|
return node, err
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (sruo *SupportResponseUpdateOne) SaveX(ctx context.Context) *SupportResponse {
|
|
node, err := sruo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (sruo *SupportResponseUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := sruo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (sruo *SupportResponseUpdateOne) ExecX(ctx context.Context) {
|
|
if err := sruo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (sruo *SupportResponseUpdateOne) sqlSave(ctx context.Context) (_node *SupportResponse, err error) {
|
|
_spec := &sqlgraph.UpdateSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: supportresponse.Table,
|
|
Columns: supportresponse.Columns,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeInt,
|
|
Column: supportresponse.FieldID,
|
|
},
|
|
},
|
|
}
|
|
id, ok := sruo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SupportResponse.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := sruo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, supportresponse.FieldID)
|
|
for _, f := range fields {
|
|
if !supportresponse.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != supportresponse.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := sruo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := sruo.mutation.Refid(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldRefid,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.Writer(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldWriter,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.Message(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldMessage,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.GetType(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldType,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.Rtcchannel(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeString,
|
|
Value: value,
|
|
Column: supportresponse.FieldRtcchannel,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.Isread(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeBool,
|
|
Value: value,
|
|
Column: supportresponse.FieldIsread,
|
|
})
|
|
}
|
|
if value, ok := sruo.mutation.Created(); ok {
|
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
|
Type: field.TypeTime,
|
|
Value: value,
|
|
Column: supportresponse.FieldCreated,
|
|
})
|
|
}
|
|
_node = &SupportResponse{config: sruo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, sruo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{supportresponse.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
return _node, nil
|
|
}
|