- 新增 SyncFailure 实体:MES/WMS 两端 schema 源 + ent 生成码(create/delete/query/update 及子包) - ent 框架文件全量重生成:client/ent/hook/migrate/mutation/predicate/runtime/tx - 清理旧代码生成入口:删除 schema/gen.go 与 schema/tools/generate.go - 同步失败页面调整:MES/WMS SyncFailure.vue 接入新实体,MES 产品工艺页同步调整 - 主程序入口注册新实体:bj_power_mes.go / bj_power_wms.go,工作站 main.go 同步调整 - 更新文档:WMS README、案例、问题记录;刷新 MES/WMS 前端构建产物
660 lines
20 KiB
Go
660 lines
20 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/predicate"
|
|
"bj_power_mes/ent/syncfailure"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// SyncFailureUpdate is the builder for updating SyncFailure entities.
|
|
type SyncFailureUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *SyncFailureMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the SyncFailureUpdate builder.
|
|
func (_u *SyncFailureUpdate) Where(ps ...predicate.SyncFailure) *SyncFailureUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetDirection sets the "direction" field.
|
|
func (_u *SyncFailureUpdate) SetDirection(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetDirection(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDirection sets the "direction" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableDirection(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetDirection(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBizType sets the "biz_type" field.
|
|
func (_u *SyncFailureUpdate) SetBizType(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetBizType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizType sets the "biz_type" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableBizType(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetBizType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBizKey sets the "biz_key" field.
|
|
func (_u *SyncFailureUpdate) SetBizKey(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetBizKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizKey sets the "biz_key" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableBizKey(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetBizKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEndpoint sets the "endpoint" field.
|
|
func (_u *SyncFailureUpdate) SetEndpoint(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetEndpoint(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEndpoint sets the "endpoint" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableEndpoint(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetEndpoint(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPayloadJSON sets the "payload_json" field.
|
|
func (_u *SyncFailureUpdate) SetPayloadJSON(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetPayloadJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePayloadJSON sets the "payload_json" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillablePayloadJSON(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetPayloadJSON(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMsg sets the "error_msg" field.
|
|
func (_u *SyncFailureUpdate) SetErrorMsg(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetErrorMsg(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMsg sets the "error_msg" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableErrorMsg(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetErrorMsg(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIdempotencyKey sets the "idempotency_key" field.
|
|
func (_u *SyncFailureUpdate) SetIdempotencyKey(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetIdempotencyKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIdempotencyKey sets the "idempotency_key" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableIdempotencyKey(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetIdempotencyKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *SyncFailureUpdate) SetStatus(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableStatus(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRetryCount sets the "retry_count" field.
|
|
func (_u *SyncFailureUpdate) SetRetryCount(v int32) *SyncFailureUpdate {
|
|
_u.mutation.ResetRetryCount()
|
|
_u.mutation.SetRetryCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableRetryCount(v *int32) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetRetryCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddRetryCount adds value to the "retry_count" field.
|
|
func (_u *SyncFailureUpdate) AddRetryCount(v int32) *SyncFailureUpdate {
|
|
_u.mutation.AddRetryCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *SyncFailureUpdate) SetCreatedAt(v int64) *SyncFailureUpdate {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableCreatedAt(v *int64) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *SyncFailureUpdate) AddCreatedAt(v int64) *SyncFailureUpdate {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLastErrorAt sets the "last_error_at" field.
|
|
func (_u *SyncFailureUpdate) SetLastErrorAt(v int64) *SyncFailureUpdate {
|
|
_u.mutation.ResetLastErrorAt()
|
|
_u.mutation.SetLastErrorAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLastErrorAt sets the "last_error_at" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableLastErrorAt(v *int64) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetLastErrorAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLastErrorAt adds value to the "last_error_at" field.
|
|
func (_u *SyncFailureUpdate) AddLastErrorAt(v int64) *SyncFailureUpdate {
|
|
_u.mutation.AddLastErrorAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHandledBy sets the "handled_by" field.
|
|
func (_u *SyncFailureUpdate) SetHandledBy(v string) *SyncFailureUpdate {
|
|
_u.mutation.SetHandledBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHandledBy sets the "handled_by" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdate) SetNillableHandledBy(v *string) *SyncFailureUpdate {
|
|
if v != nil {
|
|
_u.SetHandledBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the SyncFailureMutation object of the builder.
|
|
func (_u *SyncFailureUpdate) Mutation() *SyncFailureMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *SyncFailureUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *SyncFailureUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *SyncFailureUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *SyncFailureUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *SyncFailureUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SyncFailureUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *SyncFailureUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(syncfailure.Table, syncfailure.Columns, sqlgraph.NewFieldSpec(syncfailure.FieldID, field.TypeInt))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.Direction(); ok {
|
|
_spec.SetField(syncfailure.FieldDirection, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BizType(); ok {
|
|
_spec.SetField(syncfailure.FieldBizType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BizKey(); ok {
|
|
_spec.SetField(syncfailure.FieldBizKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Endpoint(); ok {
|
|
_spec.SetField(syncfailure.FieldEndpoint, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.PayloadJSON(); ok {
|
|
_spec.SetField(syncfailure.FieldPayloadJSON, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMsg(); ok {
|
|
_spec.SetField(syncfailure.FieldErrorMsg, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.IdempotencyKey(); ok {
|
|
_spec.SetField(syncfailure.FieldIdempotencyKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(syncfailure.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RetryCount(); ok {
|
|
_spec.SetField(syncfailure.FieldRetryCount, field.TypeInt32, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedRetryCount(); ok {
|
|
_spec.AddField(syncfailure.FieldRetryCount, field.TypeInt32, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(syncfailure.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(syncfailure.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.LastErrorAt(); ok {
|
|
_spec.SetField(syncfailure.FieldLastErrorAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLastErrorAt(); ok {
|
|
_spec.AddField(syncfailure.FieldLastErrorAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.HandledBy(); ok {
|
|
_spec.SetField(syncfailure.FieldHandledBy, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{syncfailure.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// SyncFailureUpdateOne is the builder for updating a single SyncFailure entity.
|
|
type SyncFailureUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *SyncFailureMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetDirection sets the "direction" field.
|
|
func (_u *SyncFailureUpdateOne) SetDirection(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetDirection(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDirection sets the "direction" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableDirection(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetDirection(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBizType sets the "biz_type" field.
|
|
func (_u *SyncFailureUpdateOne) SetBizType(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetBizType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizType sets the "biz_type" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableBizType(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetBizType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetBizKey sets the "biz_key" field.
|
|
func (_u *SyncFailureUpdateOne) SetBizKey(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetBizKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBizKey sets the "biz_key" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableBizKey(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetBizKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetEndpoint sets the "endpoint" field.
|
|
func (_u *SyncFailureUpdateOne) SetEndpoint(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetEndpoint(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEndpoint sets the "endpoint" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableEndpoint(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetEndpoint(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetPayloadJSON sets the "payload_json" field.
|
|
func (_u *SyncFailureUpdateOne) SetPayloadJSON(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetPayloadJSON(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePayloadJSON sets the "payload_json" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillablePayloadJSON(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetPayloadJSON(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetErrorMsg sets the "error_msg" field.
|
|
func (_u *SyncFailureUpdateOne) SetErrorMsg(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetErrorMsg(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableErrorMsg sets the "error_msg" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableErrorMsg(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetErrorMsg(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIdempotencyKey sets the "idempotency_key" field.
|
|
func (_u *SyncFailureUpdateOne) SetIdempotencyKey(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetIdempotencyKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIdempotencyKey sets the "idempotency_key" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableIdempotencyKey(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetIdempotencyKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *SyncFailureUpdateOne) SetStatus(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableStatus(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRetryCount sets the "retry_count" field.
|
|
func (_u *SyncFailureUpdateOne) SetRetryCount(v int32) *SyncFailureUpdateOne {
|
|
_u.mutation.ResetRetryCount()
|
|
_u.mutation.SetRetryCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableRetryCount(v *int32) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetRetryCount(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddRetryCount adds value to the "retry_count" field.
|
|
func (_u *SyncFailureUpdateOne) AddRetryCount(v int32) *SyncFailureUpdateOne {
|
|
_u.mutation.AddRetryCount(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_u *SyncFailureUpdateOne) SetCreatedAt(v int64) *SyncFailureUpdateOne {
|
|
_u.mutation.ResetCreatedAt()
|
|
_u.mutation.SetCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableCreatedAt(v *int64) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreatedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddCreatedAt adds value to the "created_at" field.
|
|
func (_u *SyncFailureUpdateOne) AddCreatedAt(v int64) *SyncFailureUpdateOne {
|
|
_u.mutation.AddCreatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLastErrorAt sets the "last_error_at" field.
|
|
func (_u *SyncFailureUpdateOne) SetLastErrorAt(v int64) *SyncFailureUpdateOne {
|
|
_u.mutation.ResetLastErrorAt()
|
|
_u.mutation.SetLastErrorAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLastErrorAt sets the "last_error_at" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableLastErrorAt(v *int64) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetLastErrorAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLastErrorAt adds value to the "last_error_at" field.
|
|
func (_u *SyncFailureUpdateOne) AddLastErrorAt(v int64) *SyncFailureUpdateOne {
|
|
_u.mutation.AddLastErrorAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHandledBy sets the "handled_by" field.
|
|
func (_u *SyncFailureUpdateOne) SetHandledBy(v string) *SyncFailureUpdateOne {
|
|
_u.mutation.SetHandledBy(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHandledBy sets the "handled_by" field if the given value is not nil.
|
|
func (_u *SyncFailureUpdateOne) SetNillableHandledBy(v *string) *SyncFailureUpdateOne {
|
|
if v != nil {
|
|
_u.SetHandledBy(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the SyncFailureMutation object of the builder.
|
|
func (_u *SyncFailureUpdateOne) Mutation() *SyncFailureMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the SyncFailureUpdate builder.
|
|
func (_u *SyncFailureUpdateOne) Where(ps ...predicate.SyncFailure) *SyncFailureUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *SyncFailureUpdateOne) Select(field string, fields ...string) *SyncFailureUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated SyncFailure entity.
|
|
func (_u *SyncFailureUpdateOne) Save(ctx context.Context) (*SyncFailure, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *SyncFailureUpdateOne) SaveX(ctx context.Context) *SyncFailure {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *SyncFailureUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *SyncFailureUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *SyncFailureUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SyncFailureUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *SyncFailureUpdateOne) sqlSave(ctx context.Context) (_node *SyncFailure, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(syncfailure.Table, syncfailure.Columns, sqlgraph.NewFieldSpec(syncfailure.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SyncFailure.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, syncfailure.FieldID)
|
|
for _, f := range fields {
|
|
if !syncfailure.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != syncfailure.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.Direction(); ok {
|
|
_spec.SetField(syncfailure.FieldDirection, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BizType(); ok {
|
|
_spec.SetField(syncfailure.FieldBizType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.BizKey(); ok {
|
|
_spec.SetField(syncfailure.FieldBizKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Endpoint(); ok {
|
|
_spec.SetField(syncfailure.FieldEndpoint, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.PayloadJSON(); ok {
|
|
_spec.SetField(syncfailure.FieldPayloadJSON, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ErrorMsg(); ok {
|
|
_spec.SetField(syncfailure.FieldErrorMsg, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.IdempotencyKey(); ok {
|
|
_spec.SetField(syncfailure.FieldIdempotencyKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(syncfailure.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RetryCount(); ok {
|
|
_spec.SetField(syncfailure.FieldRetryCount, field.TypeInt32, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedRetryCount(); ok {
|
|
_spec.AddField(syncfailure.FieldRetryCount, field.TypeInt32, value)
|
|
}
|
|
if value, ok := _u.mutation.CreatedAt(); ok {
|
|
_spec.SetField(syncfailure.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedCreatedAt(); ok {
|
|
_spec.AddField(syncfailure.FieldCreatedAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.LastErrorAt(); ok {
|
|
_spec.SetField(syncfailure.FieldLastErrorAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLastErrorAt(); ok {
|
|
_spec.AddField(syncfailure.FieldLastErrorAt, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.HandledBy(); ok {
|
|
_spec.SetField(syncfailure.FieldHandledBy, field.TypeString, value)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &SyncFailure{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{syncfailure.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|