|
@@ -1,1339 +0,0 @@
|
|
|
-// Code generated by ent, DO NOT EDIT.
|
|
|
-
|
|
|
-package ent
|
|
|
-
|
|
|
-import (
|
|
|
- "context"
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "time"
|
|
|
- "wechat-api/ent/compapijob"
|
|
|
- "wechat-api/ent/custom_types"
|
|
|
-
|
|
|
- "entgo.io/ent/dialect/sql"
|
|
|
- "entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
- "entgo.io/ent/schema/field"
|
|
|
-)
|
|
|
-
|
|
|
-// CompapiJobCreate is the builder for creating a CompapiJob entity.
|
|
|
-type CompapiJobCreate struct {
|
|
|
- config
|
|
|
- mutation *CompapiJobMutation
|
|
|
- hooks []Hook
|
|
|
- conflict []sql.ConflictOption
|
|
|
-}
|
|
|
-
|
|
|
-// SetCreatedAt sets the "created_at" field.
|
|
|
-func (cjc *CompapiJobCreate) SetCreatedAt(t time.Time) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetCreatedAt(t)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableCreatedAt(t *time.Time) *CompapiJobCreate {
|
|
|
- if t != nil {
|
|
|
- cjc.SetCreatedAt(*t)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetUpdatedAt sets the "updated_at" field.
|
|
|
-func (cjc *CompapiJobCreate) SetUpdatedAt(t time.Time) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetUpdatedAt(t)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableUpdatedAt(t *time.Time) *CompapiJobCreate {
|
|
|
- if t != nil {
|
|
|
- cjc.SetUpdatedAt(*t)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistAt sets the "dist_at" field.
|
|
|
-func (cjc *CompapiJobCreate) SetDistAt(t time.Time) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetDistAt(t)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableDistAt sets the "dist_at" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableDistAt(t *time.Time) *CompapiJobCreate {
|
|
|
- if t != nil {
|
|
|
- cjc.SetDistAt(*t)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistStatus sets the "dist_status" field.
|
|
|
-func (cjc *CompapiJobCreate) SetDistStatus(i int8) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetDistStatus(i)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableDistStatus sets the "dist_status" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableDistStatus(i *int8) *CompapiJobCreate {
|
|
|
- if i != nil {
|
|
|
- cjc.SetDistStatus(*i)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackStatus sets the "callback_status" field.
|
|
|
-func (cjc *CompapiJobCreate) SetCallbackStatus(i int8) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetCallbackStatus(i)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableCallbackStatus sets the "callback_status" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableCallbackStatus(i *int8) *CompapiJobCreate {
|
|
|
- if i != nil {
|
|
|
- cjc.SetCallbackStatus(*i)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackURL sets the "callback_url" field.
|
|
|
-func (cjc *CompapiJobCreate) SetCallbackURL(s string) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetCallbackURL(s)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetRequestJSON sets the "request_json" field.
|
|
|
-func (cjc *CompapiJobCreate) SetRequestJSON(ctd custom_types.OriginalData) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetRequestJSON(ctd)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetAuthToken sets the "auth_token" field.
|
|
|
-func (cjc *CompapiJobCreate) SetAuthToken(s string) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetAuthToken(s)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableAuthToken sets the "auth_token" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableAuthToken(s *string) *CompapiJobCreate {
|
|
|
- if s != nil {
|
|
|
- cjc.SetAuthToken(*s)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetEventType sets the "event_type" field.
|
|
|
-func (cjc *CompapiJobCreate) SetEventType(s string) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetEventType(s)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableEventType sets the "event_type" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableEventType(s *string) *CompapiJobCreate {
|
|
|
- if s != nil {
|
|
|
- cjc.SetEventType(*s)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetWorkidIdx sets the "workid_idx" field.
|
|
|
-func (cjc *CompapiJobCreate) SetWorkidIdx(i int8) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetWorkidIdx(i)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableWorkidIdx sets the "workid_idx" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableWorkidIdx(i *int8) *CompapiJobCreate {
|
|
|
- if i != nil {
|
|
|
- cjc.SetWorkidIdx(*i)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetChatID sets the "chat_id" field.
|
|
|
-func (cjc *CompapiJobCreate) SetChatID(s string) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetChatID(s)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableChatID sets the "chat_id" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableChatID(s *string) *CompapiJobCreate {
|
|
|
- if s != nil {
|
|
|
- cjc.SetChatID(*s)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetRetryCount sets the "retry_count" field.
|
|
|
-func (cjc *CompapiJobCreate) SetRetryCount(i int8) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetRetryCount(i)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
|
|
|
-func (cjc *CompapiJobCreate) SetNillableRetryCount(i *int8) *CompapiJobCreate {
|
|
|
- if i != nil {
|
|
|
- cjc.SetRetryCount(*i)
|
|
|
- }
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// SetID sets the "id" field.
|
|
|
-func (cjc *CompapiJobCreate) SetID(u uint64) *CompapiJobCreate {
|
|
|
- cjc.mutation.SetID(u)
|
|
|
- return cjc
|
|
|
-}
|
|
|
-
|
|
|
-// Mutation returns the CompapiJobMutation object of the builder.
|
|
|
-func (cjc *CompapiJobCreate) Mutation() *CompapiJobMutation {
|
|
|
- return cjc.mutation
|
|
|
-}
|
|
|
-
|
|
|
-// Save creates the CompapiJob in the database.
|
|
|
-func (cjc *CompapiJobCreate) Save(ctx context.Context) (*CompapiJob, error) {
|
|
|
- cjc.defaults()
|
|
|
- return withHooks(ctx, cjc.sqlSave, cjc.mutation, cjc.hooks)
|
|
|
-}
|
|
|
-
|
|
|
-// SaveX calls Save and panics if Save returns an error.
|
|
|
-func (cjc *CompapiJobCreate) SaveX(ctx context.Context) *CompapiJob {
|
|
|
- v, err := cjc.Save(ctx)
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
- return v
|
|
|
-}
|
|
|
-
|
|
|
-// Exec executes the query.
|
|
|
-func (cjc *CompapiJobCreate) Exec(ctx context.Context) error {
|
|
|
- _, err := cjc.Save(ctx)
|
|
|
- return err
|
|
|
-}
|
|
|
-
|
|
|
-// ExecX is like Exec, but panics if an error occurs.
|
|
|
-func (cjc *CompapiJobCreate) ExecX(ctx context.Context) {
|
|
|
- if err := cjc.Exec(ctx); err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// defaults sets the default values of the builder before save.
|
|
|
-func (cjc *CompapiJobCreate) defaults() {
|
|
|
- if _, ok := cjc.mutation.CreatedAt(); !ok {
|
|
|
- v := compapijob.DefaultCreatedAt()
|
|
|
- cjc.mutation.SetCreatedAt(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.UpdatedAt(); !ok {
|
|
|
- v := compapijob.DefaultUpdatedAt()
|
|
|
- cjc.mutation.SetUpdatedAt(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.DistStatus(); !ok {
|
|
|
- v := compapijob.DefaultDistStatus
|
|
|
- cjc.mutation.SetDistStatus(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.CallbackStatus(); !ok {
|
|
|
- v := compapijob.DefaultCallbackStatus
|
|
|
- cjc.mutation.SetCallbackStatus(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.AuthToken(); !ok {
|
|
|
- v := compapijob.DefaultAuthToken
|
|
|
- cjc.mutation.SetAuthToken(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.EventType(); !ok {
|
|
|
- v := compapijob.DefaultEventType
|
|
|
- cjc.mutation.SetEventType(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.WorkidIdx(); !ok {
|
|
|
- v := compapijob.DefaultWorkidIdx
|
|
|
- cjc.mutation.SetWorkidIdx(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.ChatID(); !ok {
|
|
|
- v := compapijob.DefaultChatID
|
|
|
- cjc.mutation.SetChatID(v)
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.RetryCount(); !ok {
|
|
|
- v := compapijob.DefaultRetryCount
|
|
|
- cjc.mutation.SetRetryCount(v)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// check runs all checks and user-defined validators on the builder.
|
|
|
-func (cjc *CompapiJobCreate) check() error {
|
|
|
- if _, ok := cjc.mutation.CreatedAt(); !ok {
|
|
|
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CompapiJob.created_at"`)}
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.UpdatedAt(); !ok {
|
|
|
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CompapiJob.updated_at"`)}
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.CallbackURL(); !ok {
|
|
|
- return &ValidationError{Name: "callback_url", err: errors.New(`ent: missing required field "CompapiJob.callback_url"`)}
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.RequestJSON(); !ok {
|
|
|
- return &ValidationError{Name: "request_json", err: errors.New(`ent: missing required field "CompapiJob.request_json"`)}
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.AuthToken(); !ok {
|
|
|
- return &ValidationError{Name: "auth_token", err: errors.New(`ent: missing required field "CompapiJob.auth_token"`)}
|
|
|
- }
|
|
|
- if _, ok := cjc.mutation.EventType(); !ok {
|
|
|
- return &ValidationError{Name: "event_type", err: errors.New(`ent: missing required field "CompapiJob.event_type"`)}
|
|
|
- }
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (cjc *CompapiJobCreate) sqlSave(ctx context.Context) (*CompapiJob, error) {
|
|
|
- if err := cjc.check(); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- _node, _spec := cjc.createSpec()
|
|
|
- if err := sqlgraph.CreateNode(ctx, cjc.driver, _spec); err != nil {
|
|
|
- if sqlgraph.IsConstraintError(err) {
|
|
|
- err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
- }
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- if _spec.ID.Value != _node.ID {
|
|
|
- id := _spec.ID.Value.(int64)
|
|
|
- _node.ID = uint64(id)
|
|
|
- }
|
|
|
- cjc.mutation.id = &_node.ID
|
|
|
- cjc.mutation.done = true
|
|
|
- return _node, nil
|
|
|
-}
|
|
|
-
|
|
|
-func (cjc *CompapiJobCreate) createSpec() (*CompapiJob, *sqlgraph.CreateSpec) {
|
|
|
- var (
|
|
|
- _node = &CompapiJob{config: cjc.config}
|
|
|
- _spec = sqlgraph.NewCreateSpec(compapijob.Table, sqlgraph.NewFieldSpec(compapijob.FieldID, field.TypeUint64))
|
|
|
- )
|
|
|
- _spec.OnConflict = cjc.conflict
|
|
|
- if id, ok := cjc.mutation.ID(); ok {
|
|
|
- _node.ID = id
|
|
|
- _spec.ID.Value = id
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.CreatedAt(); ok {
|
|
|
- _spec.SetField(compapijob.FieldCreatedAt, field.TypeTime, value)
|
|
|
- _node.CreatedAt = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.UpdatedAt(); ok {
|
|
|
- _spec.SetField(compapijob.FieldUpdatedAt, field.TypeTime, value)
|
|
|
- _node.UpdatedAt = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.DistAt(); ok {
|
|
|
- _spec.SetField(compapijob.FieldDistAt, field.TypeTime, value)
|
|
|
- _node.DistAt = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.DistStatus(); ok {
|
|
|
- _spec.SetField(compapijob.FieldDistStatus, field.TypeInt8, value)
|
|
|
- _node.DistStatus = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.CallbackStatus(); ok {
|
|
|
- _spec.SetField(compapijob.FieldCallbackStatus, field.TypeInt8, value)
|
|
|
- _node.CallbackStatus = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.CallbackURL(); ok {
|
|
|
- _spec.SetField(compapijob.FieldCallbackURL, field.TypeString, value)
|
|
|
- _node.CallbackURL = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.RequestJSON(); ok {
|
|
|
- _spec.SetField(compapijob.FieldRequestJSON, field.TypeJSON, value)
|
|
|
- _node.RequestJSON = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.AuthToken(); ok {
|
|
|
- _spec.SetField(compapijob.FieldAuthToken, field.TypeString, value)
|
|
|
- _node.AuthToken = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.EventType(); ok {
|
|
|
- _spec.SetField(compapijob.FieldEventType, field.TypeString, value)
|
|
|
- _node.EventType = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.WorkidIdx(); ok {
|
|
|
- _spec.SetField(compapijob.FieldWorkidIdx, field.TypeInt8, value)
|
|
|
- _node.WorkidIdx = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.ChatID(); ok {
|
|
|
- _spec.SetField(compapijob.FieldChatID, field.TypeString, value)
|
|
|
- _node.ChatID = value
|
|
|
- }
|
|
|
- if value, ok := cjc.mutation.RetryCount(); ok {
|
|
|
- _spec.SetField(compapijob.FieldRetryCount, field.TypeInt8, value)
|
|
|
- _node.RetryCount = value
|
|
|
- }
|
|
|
- return _node, _spec
|
|
|
-}
|
|
|
-
|
|
|
-// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
-// of the `INSERT` statement. For example:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// SetCreatedAt(v).
|
|
|
-// OnConflict(
|
|
|
-// // Update the row with the new values
|
|
|
-// // the was proposed for insertion.
|
|
|
-// sql.ResolveWithNewValues(),
|
|
|
-// ).
|
|
|
-// // Override some of the fields with custom
|
|
|
-// // update values.
|
|
|
-// Update(func(u *ent.CompapiJobUpsert) {
|
|
|
-// SetCreatedAt(v+v).
|
|
|
-// }).
|
|
|
-// Exec(ctx)
|
|
|
-func (cjc *CompapiJobCreate) OnConflict(opts ...sql.ConflictOption) *CompapiJobUpsertOne {
|
|
|
- cjc.conflict = opts
|
|
|
- return &CompapiJobUpsertOne{
|
|
|
- create: cjc,
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
-// as conflict target. Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
-// Exec(ctx)
|
|
|
-func (cjc *CompapiJobCreate) OnConflictColumns(columns ...string) *CompapiJobUpsertOne {
|
|
|
- cjc.conflict = append(cjc.conflict, sql.ConflictColumns(columns...))
|
|
|
- return &CompapiJobUpsertOne{
|
|
|
- create: cjc,
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-type (
|
|
|
- // CompapiJobUpsertOne is the builder for "upsert"-ing
|
|
|
- // one CompapiJob node.
|
|
|
- CompapiJobUpsertOne struct {
|
|
|
- create *CompapiJobCreate
|
|
|
- }
|
|
|
-
|
|
|
- // CompapiJobUpsert is the "OnConflict" setter.
|
|
|
- CompapiJobUpsert struct {
|
|
|
- *sql.UpdateSet
|
|
|
- }
|
|
|
-)
|
|
|
-
|
|
|
-// SetUpdatedAt sets the "updated_at" field.
|
|
|
-func (u *CompapiJobUpsert) SetUpdatedAt(v time.Time) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldUpdatedAt, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateUpdatedAt() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldUpdatedAt)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistAt sets the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsert) SetDistAt(v time.Time) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldDistAt, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistAt sets the "dist_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateDistAt() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldDistAt)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistAt clears the value of the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsert) ClearDistAt() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldDistAt)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistStatus sets the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsert) SetDistStatus(v int8) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldDistStatus, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistStatus sets the "dist_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateDistStatus() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldDistStatus)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// AddDistStatus adds v to the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsert) AddDistStatus(v int8) *CompapiJobUpsert {
|
|
|
- u.Add(compapijob.FieldDistStatus, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistStatus clears the value of the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsert) ClearDistStatus() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldDistStatus)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackStatus sets the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsert) SetCallbackStatus(v int8) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldCallbackStatus, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackStatus sets the "callback_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateCallbackStatus() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldCallbackStatus)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// AddCallbackStatus adds v to the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsert) AddCallbackStatus(v int8) *CompapiJobUpsert {
|
|
|
- u.Add(compapijob.FieldCallbackStatus, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearCallbackStatus clears the value of the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsert) ClearCallbackStatus() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldCallbackStatus)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackURL sets the "callback_url" field.
|
|
|
-func (u *CompapiJobUpsert) SetCallbackURL(v string) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldCallbackURL, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateCallbackURL() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldCallbackURL)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetRequestJSON sets the "request_json" field.
|
|
|
-func (u *CompapiJobUpsert) SetRequestJSON(v custom_types.OriginalData) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldRequestJSON, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRequestJSON sets the "request_json" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateRequestJSON() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldRequestJSON)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetAuthToken sets the "auth_token" field.
|
|
|
-func (u *CompapiJobUpsert) SetAuthToken(v string) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldAuthToken, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateAuthToken() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldAuthToken)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetEventType sets the "event_type" field.
|
|
|
-func (u *CompapiJobUpsert) SetEventType(v string) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldEventType, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateEventType sets the "event_type" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateEventType() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldEventType)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetWorkidIdx sets the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsert) SetWorkidIdx(v int8) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldWorkidIdx, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateWorkidIdx() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldWorkidIdx)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// AddWorkidIdx adds v to the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsert) AddWorkidIdx(v int8) *CompapiJobUpsert {
|
|
|
- u.Add(compapijob.FieldWorkidIdx, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearWorkidIdx clears the value of the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsert) ClearWorkidIdx() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldWorkidIdx)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetChatID sets the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsert) SetChatID(v string) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldChatID, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateChatID sets the "chat_id" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateChatID() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldChatID)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearChatID clears the value of the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsert) ClearChatID() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldChatID)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetRetryCount sets the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsert) SetRetryCount(v int8) *CompapiJobUpsert {
|
|
|
- u.Set(compapijob.FieldRetryCount, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsert) UpdateRetryCount() *CompapiJobUpsert {
|
|
|
- u.SetExcluded(compapijob.FieldRetryCount)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// AddRetryCount adds v to the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsert) AddRetryCount(v int8) *CompapiJobUpsert {
|
|
|
- u.Add(compapijob.FieldRetryCount, v)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// ClearRetryCount clears the value of the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsert) ClearRetryCount() *CompapiJobUpsert {
|
|
|
- u.SetNull(compapijob.FieldRetryCount)
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
|
|
|
-// Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(
|
|
|
-// sql.ResolveWithNewValues(),
|
|
|
-// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
-// u.SetIgnore(compapijob.FieldID)
|
|
|
-// }),
|
|
|
-// ).
|
|
|
-// Exec(ctx)
|
|
|
-func (u *CompapiJobUpsertOne) UpdateNewValues() *CompapiJobUpsertOne {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
|
- if _, exists := u.create.mutation.ID(); exists {
|
|
|
- s.SetIgnore(compapijob.FieldID)
|
|
|
- }
|
|
|
- if _, exists := u.create.mutation.CreatedAt(); exists {
|
|
|
- s.SetIgnore(compapijob.FieldCreatedAt)
|
|
|
- }
|
|
|
- }))
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// Ignore sets each column to itself in case of conflict.
|
|
|
-// Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(sql.ResolveWithIgnore()).
|
|
|
-// Exec(ctx)
|
|
|
-func (u *CompapiJobUpsertOne) Ignore() *CompapiJobUpsertOne {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
|
-// Supported only by SQLite and PostgreSQL.
|
|
|
-func (u *CompapiJobUpsertOne) DoNothing() *CompapiJobUpsertOne {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// Update allows overriding fields `UPDATE` values. See the CompapiJobCreate.OnConflict
|
|
|
-// documentation for more info.
|
|
|
-func (u *CompapiJobUpsertOne) Update(set func(*CompapiJobUpsert)) *CompapiJobUpsertOne {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
- set(&CompapiJobUpsert{UpdateSet: update})
|
|
|
- }))
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetUpdatedAt sets the "updated_at" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetUpdatedAt(v time.Time) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetUpdatedAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateUpdatedAt() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateUpdatedAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistAt sets the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetDistAt(v time.Time) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetDistAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistAt sets the "dist_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateDistAt() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateDistAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistAt clears the value of the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearDistAt() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearDistAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistStatus sets the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetDistStatus(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetDistStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddDistStatus adds v to the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) AddDistStatus(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddDistStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistStatus sets the "dist_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateDistStatus() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateDistStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistStatus clears the value of the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearDistStatus() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearDistStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackStatus sets the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetCallbackStatus(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetCallbackStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddCallbackStatus adds v to the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) AddCallbackStatus(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddCallbackStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackStatus sets the "callback_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateCallbackStatus() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateCallbackStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearCallbackStatus clears the value of the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearCallbackStatus() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearCallbackStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackURL sets the "callback_url" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetCallbackURL(v string) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetCallbackURL(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateCallbackURL() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateCallbackURL()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetRequestJSON sets the "request_json" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetRequestJSON(v custom_types.OriginalData) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetRequestJSON(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRequestJSON sets the "request_json" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateRequestJSON() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateRequestJSON()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetAuthToken sets the "auth_token" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetAuthToken(v string) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetAuthToken(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateAuthToken() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateAuthToken()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetEventType sets the "event_type" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetEventType(v string) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetEventType(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateEventType sets the "event_type" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateEventType() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateEventType()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetWorkidIdx sets the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetWorkidIdx(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetWorkidIdx(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddWorkidIdx adds v to the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertOne) AddWorkidIdx(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddWorkidIdx(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateWorkidIdx() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateWorkidIdx()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearWorkidIdx clears the value of the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearWorkidIdx() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearWorkidIdx()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetChatID sets the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetChatID(v string) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetChatID(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateChatID sets the "chat_id" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateChatID() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateChatID()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearChatID clears the value of the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearChatID() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearChatID()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetRetryCount sets the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertOne) SetRetryCount(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetRetryCount(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddRetryCount adds v to the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertOne) AddRetryCount(v int8) *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddRetryCount(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertOne) UpdateRetryCount() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateRetryCount()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearRetryCount clears the value of the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertOne) ClearRetryCount() *CompapiJobUpsertOne {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearRetryCount()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// Exec executes the query.
|
|
|
-func (u *CompapiJobUpsertOne) Exec(ctx context.Context) error {
|
|
|
- if len(u.create.conflict) == 0 {
|
|
|
- return errors.New("ent: missing options for CompapiJobCreate.OnConflict")
|
|
|
- }
|
|
|
- return u.create.Exec(ctx)
|
|
|
-}
|
|
|
-
|
|
|
-// ExecX is like Exec, but panics if an error occurs.
|
|
|
-func (u *CompapiJobUpsertOne) ExecX(ctx context.Context) {
|
|
|
- if err := u.create.Exec(ctx); err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// Exec executes the UPSERT query and returns the inserted/updated ID.
|
|
|
-func (u *CompapiJobUpsertOne) ID(ctx context.Context) (id uint64, err error) {
|
|
|
- node, err := u.create.Save(ctx)
|
|
|
- if err != nil {
|
|
|
- return id, err
|
|
|
- }
|
|
|
- return node.ID, nil
|
|
|
-}
|
|
|
-
|
|
|
-// IDX is like ID, but panics if an error occurs.
|
|
|
-func (u *CompapiJobUpsertOne) IDX(ctx context.Context) uint64 {
|
|
|
- id, err := u.ID(ctx)
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
- return id
|
|
|
-}
|
|
|
-
|
|
|
-// CompapiJobCreateBulk is the builder for creating many CompapiJob entities in bulk.
|
|
|
-type CompapiJobCreateBulk struct {
|
|
|
- config
|
|
|
- err error
|
|
|
- builders []*CompapiJobCreate
|
|
|
- conflict []sql.ConflictOption
|
|
|
-}
|
|
|
-
|
|
|
-// Save creates the CompapiJob entities in the database.
|
|
|
-func (cjcb *CompapiJobCreateBulk) Save(ctx context.Context) ([]*CompapiJob, error) {
|
|
|
- if cjcb.err != nil {
|
|
|
- return nil, cjcb.err
|
|
|
- }
|
|
|
- specs := make([]*sqlgraph.CreateSpec, len(cjcb.builders))
|
|
|
- nodes := make([]*CompapiJob, len(cjcb.builders))
|
|
|
- mutators := make([]Mutator, len(cjcb.builders))
|
|
|
- for i := range cjcb.builders {
|
|
|
- func(i int, root context.Context) {
|
|
|
- builder := cjcb.builders[i]
|
|
|
- builder.defaults()
|
|
|
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
- mutation, ok := m.(*CompapiJobMutation)
|
|
|
- if !ok {
|
|
|
- return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
|
- }
|
|
|
- if err := builder.check(); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- builder.mutation = mutation
|
|
|
- var err error
|
|
|
- nodes[i], specs[i] = builder.createSpec()
|
|
|
- if i < len(mutators)-1 {
|
|
|
- _, err = mutators[i+1].Mutate(root, cjcb.builders[i+1].mutation)
|
|
|
- } else {
|
|
|
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
|
- spec.OnConflict = cjcb.conflict
|
|
|
- // Invoke the actual operation on the latest mutation in the chain.
|
|
|
- if err = sqlgraph.BatchCreate(ctx, cjcb.driver, spec); err != nil {
|
|
|
- if sqlgraph.IsConstraintError(err) {
|
|
|
- err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- mutation.id = &nodes[i].ID
|
|
|
- if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
|
- id := specs[i].ID.Value.(int64)
|
|
|
- nodes[i].ID = uint64(id)
|
|
|
- }
|
|
|
- mutation.done = true
|
|
|
- return nodes[i], nil
|
|
|
- })
|
|
|
- for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
|
- mut = builder.hooks[i](mut)
|
|
|
- }
|
|
|
- mutators[i] = mut
|
|
|
- }(i, ctx)
|
|
|
- }
|
|
|
- if len(mutators) > 0 {
|
|
|
- if _, err := mutators[0].Mutate(ctx, cjcb.builders[0].mutation); err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- }
|
|
|
- return nodes, nil
|
|
|
-}
|
|
|
-
|
|
|
-// SaveX is like Save, but panics if an error occurs.
|
|
|
-func (cjcb *CompapiJobCreateBulk) SaveX(ctx context.Context) []*CompapiJob {
|
|
|
- v, err := cjcb.Save(ctx)
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
- return v
|
|
|
-}
|
|
|
-
|
|
|
-// Exec executes the query.
|
|
|
-func (cjcb *CompapiJobCreateBulk) Exec(ctx context.Context) error {
|
|
|
- _, err := cjcb.Save(ctx)
|
|
|
- return err
|
|
|
-}
|
|
|
-
|
|
|
-// ExecX is like Exec, but panics if an error occurs.
|
|
|
-func (cjcb *CompapiJobCreateBulk) ExecX(ctx context.Context) {
|
|
|
- if err := cjcb.Exec(ctx); err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
|
-// of the `INSERT` statement. For example:
|
|
|
-//
|
|
|
-// client.CompapiJob.CreateBulk(builders...).
|
|
|
-// OnConflict(
|
|
|
-// // Update the row with the new values
|
|
|
-// // the was proposed for insertion.
|
|
|
-// sql.ResolveWithNewValues(),
|
|
|
-// ).
|
|
|
-// // Override some of the fields with custom
|
|
|
-// // update values.
|
|
|
-// Update(func(u *ent.CompapiJobUpsert) {
|
|
|
-// SetCreatedAt(v+v).
|
|
|
-// }).
|
|
|
-// Exec(ctx)
|
|
|
-func (cjcb *CompapiJobCreateBulk) OnConflict(opts ...sql.ConflictOption) *CompapiJobUpsertBulk {
|
|
|
- cjcb.conflict = opts
|
|
|
- return &CompapiJobUpsertBulk{
|
|
|
- create: cjcb,
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// OnConflictColumns calls `OnConflict` and configures the columns
|
|
|
-// as conflict target. Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(sql.ConflictColumns(columns...)).
|
|
|
-// Exec(ctx)
|
|
|
-func (cjcb *CompapiJobCreateBulk) OnConflictColumns(columns ...string) *CompapiJobUpsertBulk {
|
|
|
- cjcb.conflict = append(cjcb.conflict, sql.ConflictColumns(columns...))
|
|
|
- return &CompapiJobUpsertBulk{
|
|
|
- create: cjcb,
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// CompapiJobUpsertBulk is the builder for "upsert"-ing
|
|
|
-// a bulk of CompapiJob nodes.
|
|
|
-type CompapiJobUpsertBulk struct {
|
|
|
- create *CompapiJobCreateBulk
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateNewValues updates the mutable fields using the new values that
|
|
|
-// were set on create. Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(
|
|
|
-// sql.ResolveWithNewValues(),
|
|
|
-// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
|
-// u.SetIgnore(compapijob.FieldID)
|
|
|
-// }),
|
|
|
-// ).
|
|
|
-// Exec(ctx)
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateNewValues() *CompapiJobUpsertBulk {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
|
|
- for _, b := range u.create.builders {
|
|
|
- if _, exists := b.mutation.ID(); exists {
|
|
|
- s.SetIgnore(compapijob.FieldID)
|
|
|
- }
|
|
|
- if _, exists := b.mutation.CreatedAt(); exists {
|
|
|
- s.SetIgnore(compapijob.FieldCreatedAt)
|
|
|
- }
|
|
|
- }
|
|
|
- }))
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// Ignore sets each column to itself in case of conflict.
|
|
|
-// Using this option is equivalent to using:
|
|
|
-//
|
|
|
-// client.CompapiJob.Create().
|
|
|
-// OnConflict(sql.ResolveWithIgnore()).
|
|
|
-// Exec(ctx)
|
|
|
-func (u *CompapiJobUpsertBulk) Ignore() *CompapiJobUpsertBulk {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// DoNothing configures the conflict_action to `DO NOTHING`.
|
|
|
-// Supported only by SQLite and PostgreSQL.
|
|
|
-func (u *CompapiJobUpsertBulk) DoNothing() *CompapiJobUpsertBulk {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// Update allows overriding fields `UPDATE` values. See the CompapiJobCreateBulk.OnConflict
|
|
|
-// documentation for more info.
|
|
|
-func (u *CompapiJobUpsertBulk) Update(set func(*CompapiJobUpsert)) *CompapiJobUpsertBulk {
|
|
|
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
|
- set(&CompapiJobUpsert{UpdateSet: update})
|
|
|
- }))
|
|
|
- return u
|
|
|
-}
|
|
|
-
|
|
|
-// SetUpdatedAt sets the "updated_at" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetUpdatedAt(v time.Time) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetUpdatedAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateUpdatedAt() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateUpdatedAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistAt sets the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetDistAt(v time.Time) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetDistAt(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistAt sets the "dist_at" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateDistAt() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateDistAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistAt clears the value of the "dist_at" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearDistAt() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearDistAt()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetDistStatus sets the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetDistStatus(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetDistStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddDistStatus adds v to the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) AddDistStatus(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddDistStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateDistStatus sets the "dist_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateDistStatus() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateDistStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearDistStatus clears the value of the "dist_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearDistStatus() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearDistStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackStatus sets the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetCallbackStatus(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetCallbackStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddCallbackStatus adds v to the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) AddCallbackStatus(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddCallbackStatus(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackStatus sets the "callback_status" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateCallbackStatus() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateCallbackStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearCallbackStatus clears the value of the "callback_status" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearCallbackStatus() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearCallbackStatus()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetCallbackURL sets the "callback_url" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetCallbackURL(v string) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetCallbackURL(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateCallbackURL() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateCallbackURL()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetRequestJSON sets the "request_json" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetRequestJSON(v custom_types.OriginalData) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetRequestJSON(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRequestJSON sets the "request_json" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateRequestJSON() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateRequestJSON()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetAuthToken sets the "auth_token" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetAuthToken(v string) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetAuthToken(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateAuthToken() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateAuthToken()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetEventType sets the "event_type" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetEventType(v string) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetEventType(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateEventType sets the "event_type" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateEventType() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateEventType()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetWorkidIdx sets the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetWorkidIdx(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetWorkidIdx(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddWorkidIdx adds v to the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertBulk) AddWorkidIdx(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddWorkidIdx(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateWorkidIdx() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateWorkidIdx()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearWorkidIdx clears the value of the "workid_idx" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearWorkidIdx() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearWorkidIdx()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetChatID sets the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetChatID(v string) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetChatID(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateChatID sets the "chat_id" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateChatID() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateChatID()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearChatID clears the value of the "chat_id" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearChatID() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearChatID()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// SetRetryCount sets the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertBulk) SetRetryCount(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.SetRetryCount(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// AddRetryCount adds v to the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertBulk) AddRetryCount(v int8) *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.AddRetryCount(v)
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
|
|
|
-func (u *CompapiJobUpsertBulk) UpdateRetryCount() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.UpdateRetryCount()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// ClearRetryCount clears the value of the "retry_count" field.
|
|
|
-func (u *CompapiJobUpsertBulk) ClearRetryCount() *CompapiJobUpsertBulk {
|
|
|
- return u.Update(func(s *CompapiJobUpsert) {
|
|
|
- s.ClearRetryCount()
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// Exec executes the query.
|
|
|
-func (u *CompapiJobUpsertBulk) Exec(ctx context.Context) error {
|
|
|
- if u.create.err != nil {
|
|
|
- return u.create.err
|
|
|
- }
|
|
|
- for i, b := range u.create.builders {
|
|
|
- if len(b.conflict) != 0 {
|
|
|
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CompapiJobCreateBulk instead", i)
|
|
|
- }
|
|
|
- }
|
|
|
- if len(u.create.conflict) == 0 {
|
|
|
- return errors.New("ent: missing options for CompapiJobCreateBulk.OnConflict")
|
|
|
- }
|
|
|
- return u.create.Exec(ctx)
|
|
|
-}
|
|
|
-
|
|
|
-// ExecX is like Exec, but panics if an error occurs.
|
|
|
-func (u *CompapiJobUpsertBulk) ExecX(ctx context.Context) {
|
|
|
- if err := u.create.Exec(ctx); err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
-}
|