feat: 添加争议微服务,支持订单争议流程
This commit is contained in:
@@ -0,0 +1,959 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"juwan-backend/app/dispute/rpc/internal/models/disputes"
|
||||
"juwan-backend/app/dispute/rpc/internal/models/predicate"
|
||||
"juwan-backend/pkg/types"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DisputesUpdate is the builder for updating Disputes entities.
|
||||
type DisputesUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *DisputesMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DisputesUpdate builder.
|
||||
func (_u *DisputesUpdate) Where(ps ...predicate.Disputes) *DisputesUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOrderID sets the "order_id" field.
|
||||
func (_u *DisputesUpdate) SetOrderID(v int64) *DisputesUpdate {
|
||||
_u.mutation.ResetOrderID()
|
||||
_u.mutation.SetOrderID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderID sets the "order_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableOrderID(v *int64) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetOrderID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddOrderID adds value to the "order_id" field.
|
||||
func (_u *DisputesUpdate) AddOrderID(v int64) *DisputesUpdate {
|
||||
_u.mutation.AddOrderID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetInitiatorID sets the "initiator_id" field.
|
||||
func (_u *DisputesUpdate) SetInitiatorID(v int64) *DisputesUpdate {
|
||||
_u.mutation.ResetInitiatorID()
|
||||
_u.mutation.SetInitiatorID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableInitiatorID sets the "initiator_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableInitiatorID(v *int64) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetInitiatorID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddInitiatorID adds value to the "initiator_id" field.
|
||||
func (_u *DisputesUpdate) AddInitiatorID(v int64) *DisputesUpdate {
|
||||
_u.mutation.AddInitiatorID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetInitiatorName sets the "initiator_name" field.
|
||||
func (_u *DisputesUpdate) SetInitiatorName(v string) *DisputesUpdate {
|
||||
_u.mutation.SetInitiatorName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableInitiatorName sets the "initiator_name" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableInitiatorName(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetInitiatorName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentID sets the "respondent_id" field.
|
||||
func (_u *DisputesUpdate) SetRespondentID(v int64) *DisputesUpdate {
|
||||
_u.mutation.ResetRespondentID()
|
||||
_u.mutation.SetRespondentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentID sets the "respondent_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableRespondentID(v *int64) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetRespondentID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRespondentID adds value to the "respondent_id" field.
|
||||
func (_u *DisputesUpdate) AddRespondentID(v int64) *DisputesUpdate {
|
||||
_u.mutation.AddRespondentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetReason sets the "reason" field.
|
||||
func (_u *DisputesUpdate) SetReason(v string) *DisputesUpdate {
|
||||
_u.mutation.SetReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableReason sets the "reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableReason(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEvidence sets the "evidence" field.
|
||||
func (_u *DisputesUpdate) SetEvidence(v types.TextArray) *DisputesUpdate {
|
||||
_u.mutation.SetEvidence(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEvidence sets the "evidence" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableEvidence(v *types.TextArray) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetEvidence(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEvidence clears the value of the "evidence" field.
|
||||
func (_u *DisputesUpdate) ClearEvidence() *DisputesUpdate {
|
||||
_u.mutation.ClearEvidence()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *DisputesUpdate) SetStatus(v string) *DisputesUpdate {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableStatus(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResult sets the "result" field.
|
||||
func (_u *DisputesUpdate) SetResult(v string) *DisputesUpdate {
|
||||
_u.mutation.SetResult(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResult sets the "result" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableResult(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetResult(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResult clears the value of the "result" field.
|
||||
func (_u *DisputesUpdate) ClearResult() *DisputesUpdate {
|
||||
_u.mutation.ClearResult()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentReason sets the "respondent_reason" field.
|
||||
func (_u *DisputesUpdate) SetRespondentReason(v string) *DisputesUpdate {
|
||||
_u.mutation.SetRespondentReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentReason sets the "respondent_reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableRespondentReason(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetRespondentReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRespondentReason clears the value of the "respondent_reason" field.
|
||||
func (_u *DisputesUpdate) ClearRespondentReason() *DisputesUpdate {
|
||||
_u.mutation.ClearRespondentReason()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentEvidence sets the "respondent_evidence" field.
|
||||
func (_u *DisputesUpdate) SetRespondentEvidence(v types.TextArray) *DisputesUpdate {
|
||||
_u.mutation.SetRespondentEvidence(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentEvidence sets the "respondent_evidence" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableRespondentEvidence(v *types.TextArray) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetRespondentEvidence(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRespondentEvidence clears the value of the "respondent_evidence" field.
|
||||
func (_u *DisputesUpdate) ClearRespondentEvidence() *DisputesUpdate {
|
||||
_u.mutation.ClearRespondentEvidence()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAppealReason sets the "appeal_reason" field.
|
||||
func (_u *DisputesUpdate) SetAppealReason(v string) *DisputesUpdate {
|
||||
_u.mutation.SetAppealReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAppealReason sets the "appeal_reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableAppealReason(v *string) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetAppealReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearAppealReason clears the value of the "appeal_reason" field.
|
||||
func (_u *DisputesUpdate) ClearAppealReason() *DisputesUpdate {
|
||||
_u.mutation.ClearAppealReason()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAppealedAt sets the "appealed_at" field.
|
||||
func (_u *DisputesUpdate) SetAppealedAt(v time.Time) *DisputesUpdate {
|
||||
_u.mutation.SetAppealedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAppealedAt sets the "appealed_at" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableAppealedAt(v *time.Time) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetAppealedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearAppealedAt clears the value of the "appealed_at" field.
|
||||
func (_u *DisputesUpdate) ClearAppealedAt() *DisputesUpdate {
|
||||
_u.mutation.ClearAppealedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResolvedBy sets the "resolved_by" field.
|
||||
func (_u *DisputesUpdate) SetResolvedBy(v int64) *DisputesUpdate {
|
||||
_u.mutation.ResetResolvedBy()
|
||||
_u.mutation.SetResolvedBy(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResolvedBy sets the "resolved_by" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableResolvedBy(v *int64) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetResolvedBy(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddResolvedBy adds value to the "resolved_by" field.
|
||||
func (_u *DisputesUpdate) AddResolvedBy(v int64) *DisputesUpdate {
|
||||
_u.mutation.AddResolvedBy(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResolvedBy clears the value of the "resolved_by" field.
|
||||
func (_u *DisputesUpdate) ClearResolvedBy() *DisputesUpdate {
|
||||
_u.mutation.ClearResolvedBy()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResolvedAt sets the "resolved_at" field.
|
||||
func (_u *DisputesUpdate) SetResolvedAt(v time.Time) *DisputesUpdate {
|
||||
_u.mutation.SetResolvedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResolvedAt sets the "resolved_at" field if the given value is not nil.
|
||||
func (_u *DisputesUpdate) SetNillableResolvedAt(v *time.Time) *DisputesUpdate {
|
||||
if v != nil {
|
||||
_u.SetResolvedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResolvedAt clears the value of the "resolved_at" field.
|
||||
func (_u *DisputesUpdate) ClearResolvedAt() *DisputesUpdate {
|
||||
_u.mutation.ClearResolvedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *DisputesUpdate) SetUpdatedAt(v time.Time) *DisputesUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the DisputesMutation object of the builder.
|
||||
func (_u *DisputesUpdate) Mutation() *DisputesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *DisputesUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *DisputesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *DisputesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *DisputesUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *DisputesUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := disputes.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *DisputesUpdate) check() error {
|
||||
if v, ok := _u.mutation.InitiatorName(); ok {
|
||||
if err := disputes.InitiatorNameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "initiator_name", err: fmt.Errorf(`models: validator failed for field "Disputes.initiator_name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Status(); ok {
|
||||
if err := disputes.StatusValidator(v); err != nil {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`models: validator failed for field "Disputes.status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Result(); ok {
|
||||
if err := disputes.ResultValidator(v); err != nil {
|
||||
return &ValidationError{Name: "result", err: fmt.Errorf(`models: validator failed for field "Disputes.result": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *DisputesUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(disputes.Table, disputes.Columns, sqlgraph.NewFieldSpec(disputes.FieldID, field.TypeInt64))
|
||||
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.OrderID(); ok {
|
||||
_spec.SetField(disputes.FieldOrderID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedOrderID(); ok {
|
||||
_spec.AddField(disputes.FieldOrderID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.InitiatorID(); ok {
|
||||
_spec.SetField(disputes.FieldInitiatorID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedInitiatorID(); ok {
|
||||
_spec.AddField(disputes.FieldInitiatorID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.InitiatorName(); ok {
|
||||
_spec.SetField(disputes.FieldInitiatorName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentID(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedRespondentID(); ok {
|
||||
_spec.AddField(disputes.FieldRespondentID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Reason(); ok {
|
||||
_spec.SetField(disputes.FieldReason, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Evidence(); ok {
|
||||
_spec.SetField(disputes.FieldEvidence, field.TypeOther, value)
|
||||
}
|
||||
if _u.mutation.EvidenceCleared() {
|
||||
_spec.ClearField(disputes.FieldEvidence, field.TypeOther)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(disputes.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Result(); ok {
|
||||
_spec.SetField(disputes.FieldResult, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ResultCleared() {
|
||||
_spec.ClearField(disputes.FieldResult, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentReason(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentReason, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RespondentReasonCleared() {
|
||||
_spec.ClearField(disputes.FieldRespondentReason, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentEvidence(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentEvidence, field.TypeOther, value)
|
||||
}
|
||||
if _u.mutation.RespondentEvidenceCleared() {
|
||||
_spec.ClearField(disputes.FieldRespondentEvidence, field.TypeOther)
|
||||
}
|
||||
if value, ok := _u.mutation.AppealReason(); ok {
|
||||
_spec.SetField(disputes.FieldAppealReason, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.AppealReasonCleared() {
|
||||
_spec.ClearField(disputes.FieldAppealReason, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.AppealedAt(); ok {
|
||||
_spec.SetField(disputes.FieldAppealedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.AppealedAtCleared() {
|
||||
_spec.ClearField(disputes.FieldAppealedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.ResolvedBy(); ok {
|
||||
_spec.SetField(disputes.FieldResolvedBy, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedResolvedBy(); ok {
|
||||
_spec.AddField(disputes.FieldResolvedBy, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.ResolvedByCleared() {
|
||||
_spec.ClearField(disputes.FieldResolvedBy, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.ResolvedAt(); ok {
|
||||
_spec.SetField(disputes.FieldResolvedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ResolvedAtCleared() {
|
||||
_spec.ClearField(disputes.FieldResolvedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(disputes.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{disputes.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// DisputesUpdateOne is the builder for updating a single Disputes entity.
|
||||
type DisputesUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *DisputesMutation
|
||||
}
|
||||
|
||||
// SetOrderID sets the "order_id" field.
|
||||
func (_u *DisputesUpdateOne) SetOrderID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.ResetOrderID()
|
||||
_u.mutation.SetOrderID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOrderID sets the "order_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableOrderID(v *int64) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetOrderID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddOrderID adds value to the "order_id" field.
|
||||
func (_u *DisputesUpdateOne) AddOrderID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.AddOrderID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetInitiatorID sets the "initiator_id" field.
|
||||
func (_u *DisputesUpdateOne) SetInitiatorID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.ResetInitiatorID()
|
||||
_u.mutation.SetInitiatorID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableInitiatorID sets the "initiator_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableInitiatorID(v *int64) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetInitiatorID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddInitiatorID adds value to the "initiator_id" field.
|
||||
func (_u *DisputesUpdateOne) AddInitiatorID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.AddInitiatorID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetInitiatorName sets the "initiator_name" field.
|
||||
func (_u *DisputesUpdateOne) SetInitiatorName(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetInitiatorName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableInitiatorName sets the "initiator_name" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableInitiatorName(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetInitiatorName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentID sets the "respondent_id" field.
|
||||
func (_u *DisputesUpdateOne) SetRespondentID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.ResetRespondentID()
|
||||
_u.mutation.SetRespondentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentID sets the "respondent_id" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableRespondentID(v *int64) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRespondentID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRespondentID adds value to the "respondent_id" field.
|
||||
func (_u *DisputesUpdateOne) AddRespondentID(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.AddRespondentID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetReason sets the "reason" field.
|
||||
func (_u *DisputesUpdateOne) SetReason(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableReason sets the "reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableReason(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEvidence sets the "evidence" field.
|
||||
func (_u *DisputesUpdateOne) SetEvidence(v types.TextArray) *DisputesUpdateOne {
|
||||
_u.mutation.SetEvidence(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEvidence sets the "evidence" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableEvidence(v *types.TextArray) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEvidence(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEvidence clears the value of the "evidence" field.
|
||||
func (_u *DisputesUpdateOne) ClearEvidence() *DisputesUpdateOne {
|
||||
_u.mutation.ClearEvidence()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *DisputesUpdateOne) SetStatus(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetStatus(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableStatus(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStatus(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResult sets the "result" field.
|
||||
func (_u *DisputesUpdateOne) SetResult(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetResult(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResult sets the "result" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableResult(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetResult(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResult clears the value of the "result" field.
|
||||
func (_u *DisputesUpdateOne) ClearResult() *DisputesUpdateOne {
|
||||
_u.mutation.ClearResult()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentReason sets the "respondent_reason" field.
|
||||
func (_u *DisputesUpdateOne) SetRespondentReason(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetRespondentReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentReason sets the "respondent_reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableRespondentReason(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRespondentReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRespondentReason clears the value of the "respondent_reason" field.
|
||||
func (_u *DisputesUpdateOne) ClearRespondentReason() *DisputesUpdateOne {
|
||||
_u.mutation.ClearRespondentReason()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRespondentEvidence sets the "respondent_evidence" field.
|
||||
func (_u *DisputesUpdateOne) SetRespondentEvidence(v types.TextArray) *DisputesUpdateOne {
|
||||
_u.mutation.SetRespondentEvidence(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableRespondentEvidence sets the "respondent_evidence" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableRespondentEvidence(v *types.TextArray) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRespondentEvidence(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearRespondentEvidence clears the value of the "respondent_evidence" field.
|
||||
func (_u *DisputesUpdateOne) ClearRespondentEvidence() *DisputesUpdateOne {
|
||||
_u.mutation.ClearRespondentEvidence()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAppealReason sets the "appeal_reason" field.
|
||||
func (_u *DisputesUpdateOne) SetAppealReason(v string) *DisputesUpdateOne {
|
||||
_u.mutation.SetAppealReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAppealReason sets the "appeal_reason" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableAppealReason(v *string) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetAppealReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearAppealReason clears the value of the "appeal_reason" field.
|
||||
func (_u *DisputesUpdateOne) ClearAppealReason() *DisputesUpdateOne {
|
||||
_u.mutation.ClearAppealReason()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAppealedAt sets the "appealed_at" field.
|
||||
func (_u *DisputesUpdateOne) SetAppealedAt(v time.Time) *DisputesUpdateOne {
|
||||
_u.mutation.SetAppealedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAppealedAt sets the "appealed_at" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableAppealedAt(v *time.Time) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetAppealedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearAppealedAt clears the value of the "appealed_at" field.
|
||||
func (_u *DisputesUpdateOne) ClearAppealedAt() *DisputesUpdateOne {
|
||||
_u.mutation.ClearAppealedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResolvedBy sets the "resolved_by" field.
|
||||
func (_u *DisputesUpdateOne) SetResolvedBy(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.ResetResolvedBy()
|
||||
_u.mutation.SetResolvedBy(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResolvedBy sets the "resolved_by" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableResolvedBy(v *int64) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetResolvedBy(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddResolvedBy adds value to the "resolved_by" field.
|
||||
func (_u *DisputesUpdateOne) AddResolvedBy(v int64) *DisputesUpdateOne {
|
||||
_u.mutation.AddResolvedBy(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResolvedBy clears the value of the "resolved_by" field.
|
||||
func (_u *DisputesUpdateOne) ClearResolvedBy() *DisputesUpdateOne {
|
||||
_u.mutation.ClearResolvedBy()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResolvedAt sets the "resolved_at" field.
|
||||
func (_u *DisputesUpdateOne) SetResolvedAt(v time.Time) *DisputesUpdateOne {
|
||||
_u.mutation.SetResolvedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResolvedAt sets the "resolved_at" field if the given value is not nil.
|
||||
func (_u *DisputesUpdateOne) SetNillableResolvedAt(v *time.Time) *DisputesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetResolvedAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResolvedAt clears the value of the "resolved_at" field.
|
||||
func (_u *DisputesUpdateOne) ClearResolvedAt() *DisputesUpdateOne {
|
||||
_u.mutation.ClearResolvedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *DisputesUpdateOne) SetUpdatedAt(v time.Time) *DisputesUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the DisputesMutation object of the builder.
|
||||
func (_u *DisputesUpdateOne) Mutation() *DisputesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DisputesUpdate builder.
|
||||
func (_u *DisputesUpdateOne) Where(ps ...predicate.Disputes) *DisputesUpdateOne {
|
||||
_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 *DisputesUpdateOne) Select(field string, fields ...string) *DisputesUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Disputes entity.
|
||||
func (_u *DisputesUpdateOne) Save(ctx context.Context) (*Disputes, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *DisputesUpdateOne) SaveX(ctx context.Context) *Disputes {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *DisputesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *DisputesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *DisputesUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := disputes.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *DisputesUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.InitiatorName(); ok {
|
||||
if err := disputes.InitiatorNameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "initiator_name", err: fmt.Errorf(`models: validator failed for field "Disputes.initiator_name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Status(); ok {
|
||||
if err := disputes.StatusValidator(v); err != nil {
|
||||
return &ValidationError{Name: "status", err: fmt.Errorf(`models: validator failed for field "Disputes.status": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Result(); ok {
|
||||
if err := disputes.ResultValidator(v); err != nil {
|
||||
return &ValidationError{Name: "result", err: fmt.Errorf(`models: validator failed for field "Disputes.result": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *DisputesUpdateOne) sqlSave(ctx context.Context) (_node *Disputes, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(disputes.Table, disputes.Columns, sqlgraph.NewFieldSpec(disputes.FieldID, field.TypeInt64))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`models: missing "Disputes.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, disputes.FieldID)
|
||||
for _, f := range fields {
|
||||
if !disputes.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("models: invalid field %q for query", f)}
|
||||
}
|
||||
if f != disputes.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.OrderID(); ok {
|
||||
_spec.SetField(disputes.FieldOrderID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedOrderID(); ok {
|
||||
_spec.AddField(disputes.FieldOrderID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.InitiatorID(); ok {
|
||||
_spec.SetField(disputes.FieldInitiatorID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedInitiatorID(); ok {
|
||||
_spec.AddField(disputes.FieldInitiatorID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.InitiatorName(); ok {
|
||||
_spec.SetField(disputes.FieldInitiatorName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentID(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedRespondentID(); ok {
|
||||
_spec.AddField(disputes.FieldRespondentID, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Reason(); ok {
|
||||
_spec.SetField(disputes.FieldReason, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Evidence(); ok {
|
||||
_spec.SetField(disputes.FieldEvidence, field.TypeOther, value)
|
||||
}
|
||||
if _u.mutation.EvidenceCleared() {
|
||||
_spec.ClearField(disputes.FieldEvidence, field.TypeOther)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(disputes.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Result(); ok {
|
||||
_spec.SetField(disputes.FieldResult, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ResultCleared() {
|
||||
_spec.ClearField(disputes.FieldResult, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentReason(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentReason, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.RespondentReasonCleared() {
|
||||
_spec.ClearField(disputes.FieldRespondentReason, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.RespondentEvidence(); ok {
|
||||
_spec.SetField(disputes.FieldRespondentEvidence, field.TypeOther, value)
|
||||
}
|
||||
if _u.mutation.RespondentEvidenceCleared() {
|
||||
_spec.ClearField(disputes.FieldRespondentEvidence, field.TypeOther)
|
||||
}
|
||||
if value, ok := _u.mutation.AppealReason(); ok {
|
||||
_spec.SetField(disputes.FieldAppealReason, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.AppealReasonCleared() {
|
||||
_spec.ClearField(disputes.FieldAppealReason, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.AppealedAt(); ok {
|
||||
_spec.SetField(disputes.FieldAppealedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.AppealedAtCleared() {
|
||||
_spec.ClearField(disputes.FieldAppealedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.ResolvedBy(); ok {
|
||||
_spec.SetField(disputes.FieldResolvedBy, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedResolvedBy(); ok {
|
||||
_spec.AddField(disputes.FieldResolvedBy, field.TypeInt64, value)
|
||||
}
|
||||
if _u.mutation.ResolvedByCleared() {
|
||||
_spec.ClearField(disputes.FieldResolvedBy, field.TypeInt64)
|
||||
}
|
||||
if value, ok := _u.mutation.ResolvedAt(); ok {
|
||||
_spec.SetField(disputes.FieldResolvedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.ResolvedAtCleared() {
|
||||
_spec.ClearField(disputes.FieldResolvedAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(disputes.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
_node = &Disputes{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{disputes.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
Reference in New Issue
Block a user