From 82b3d4446ac769ee2c1a58f749c89771b0f18791 Mon Sep 17 00:00:00 2001 From: huanglei19951029 <81128461+huanglei19951029@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:32:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(ent):=20=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E6=97=A5=E5=BF=97=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E5=8F=8A=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增支付通知日志实体定义文件 (paynotifylog.go) - 新增支付通知日志创建构建器 (paynotifylog_create.go) - 新增支付通知日志删除构建器 (paynotifylog_delete.go) - 新增支付通知日志查询构建器 (paynotifylog_query.go) - 新增支付通知日 --- rpc/ent/paynotifylog.go | 223 +++++ rpc/ent/paynotifylog/paynotifylog.go | 152 +++ rpc/ent/paynotifylog/where.go | 569 +++++++++++ rpc/ent/paynotifylog_create.go | 400 ++++++++ rpc/ent/paynotifylog_delete.go | 88 ++ rpc/ent/paynotifylog_query.go | 606 ++++++++++++ rpc/ent/paynotifylog_update.go | 625 ++++++++++++ rpc/ent/paynotifytask.go | 324 ++++++ rpc/ent/paynotifytask/paynotifytask.go | 253 +++++ rpc/ent/paynotifytask/where.go | 870 +++++++++++++++++ rpc/ent/paynotifytask_create.go | 547 +++++++++++ rpc/ent/paynotifytask_delete.go | 88 ++ rpc/ent/paynotifytask_query.go | 756 ++++++++++++++ rpc/ent/paynotifytask_update.go | 1207 +++++++++++++++++++++++ rpc/ent/payrefund.go | 363 +++++++ rpc/ent/payrefund/payrefund.go | 267 +++++ rpc/ent/payrefund/where.go | 1247 ++++++++++++++++++++++++ rpc/ent/payrefund_create.go | 604 ++++++++++++ rpc/ent/payrefund_delete.go | 88 ++ rpc/ent/payrefund_query.go | 681 +++++++++++++ rpc/ent/payrefund_update.go | 1194 +++++++++++++++++++++++ 21 files changed, 11152 insertions(+) create mode 100644 rpc/ent/paynotifylog.go create mode 100644 rpc/ent/paynotifylog/paynotifylog.go create mode 100644 rpc/ent/paynotifylog/where.go create mode 100644 rpc/ent/paynotifylog_create.go create mode 100644 rpc/ent/paynotifylog_delete.go create mode 100644 rpc/ent/paynotifylog_query.go create mode 100644 rpc/ent/paynotifylog_update.go create mode 100644 rpc/ent/paynotifytask.go create mode 100644 rpc/ent/paynotifytask/paynotifytask.go create mode 100644 rpc/ent/paynotifytask/where.go create mode 100644 rpc/ent/paynotifytask_create.go create mode 100644 rpc/ent/paynotifytask_delete.go create mode 100644 rpc/ent/paynotifytask_query.go create mode 100644 rpc/ent/paynotifytask_update.go create mode 100644 rpc/ent/payrefund.go create mode 100644 rpc/ent/payrefund/payrefund.go create mode 100644 rpc/ent/payrefund/where.go create mode 100644 rpc/ent/payrefund_create.go create mode 100644 rpc/ent/payrefund_delete.go create mode 100644 rpc/ent/payrefund_query.go create mode 100644 rpc/ent/payrefund_update.go diff --git a/rpc/ent/paynotifylog.go b/rpc/ent/paynotifylog.go new file mode 100644 index 0000000..f8627d4 --- /dev/null +++ b/rpc/ent/paynotifylog.go @@ -0,0 +1,223 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayNotifyLog Table | 异步通知日志表 +type PayNotifyLog struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 任务ID | 任务ID + TaskID uint64 `json:"task_id,omitempty"` + // 通知次数 | 通知次数 + NotifyCount uint32 `json:"notify_count,omitempty"` + // 响应内容 | 响应内容 + Response string `json:"response,omitempty"` + // 通知状态 | 通知状态 + NotifyStatus string `json:"notify_status,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayNotifyLogQuery when eager-loading is set. + Edges PayNotifyLogEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayNotifyLogEdges holds the relations/edges for other nodes in the graph. +type PayNotifyLogEdges struct { + // Task holds the value of the task edge. + Task *PayNotifyTask `json:"task,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// TaskOrErr returns the Task value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayNotifyLogEdges) TaskOrErr() (*PayNotifyTask, error) { + if e.Task != nil { + return e.Task, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: paynotifytask.Label} + } + return nil, &NotLoadedError{edge: "task"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayNotifyLog) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case paynotifylog.FieldID, paynotifylog.FieldStatus, paynotifylog.FieldTenantID, paynotifylog.FieldTaskID, paynotifylog.FieldNotifyCount: + values[i] = new(sql.NullInt64) + case paynotifylog.FieldResponse, paynotifylog.FieldNotifyStatus: + values[i] = new(sql.NullString) + case paynotifylog.FieldCreatedAt, paynotifylog.FieldUpdatedAt, paynotifylog.FieldDeletedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PayNotifyLog fields. +func (_m *PayNotifyLog) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case paynotifylog.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case paynotifylog.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case paynotifylog.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case paynotifylog.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case paynotifylog.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case paynotifylog.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case paynotifylog.FieldTaskID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field task_id", values[i]) + } else if value.Valid { + _m.TaskID = uint64(value.Int64) + } + case paynotifylog.FieldNotifyCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field notify_count", values[i]) + } else if value.Valid { + _m.NotifyCount = uint32(value.Int64) + } + case paynotifylog.FieldResponse: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field response", values[i]) + } else if value.Valid { + _m.Response = value.String + } + case paynotifylog.FieldNotifyStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notify_status", values[i]) + } else if value.Valid { + _m.NotifyStatus = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayNotifyLog. +// This includes values selected through modifiers, order, etc. +func (_m *PayNotifyLog) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryTask queries the "task" edge of the PayNotifyLog entity. +func (_m *PayNotifyLog) QueryTask() *PayNotifyTaskQuery { + return NewPayNotifyLogClient(_m.config).QueryTask(_m) +} + +// Update returns a builder for updating this PayNotifyLog. +// Note that you need to call PayNotifyLog.Unwrap() before calling this method if this PayNotifyLog +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayNotifyLog) Update() *PayNotifyLogUpdateOne { + return NewPayNotifyLogClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayNotifyLog entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *PayNotifyLog) Unwrap() *PayNotifyLog { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayNotifyLog is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayNotifyLog) String() string { + var builder strings.Builder + builder.WriteString("PayNotifyLog(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("task_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TaskID)) + builder.WriteString(", ") + builder.WriteString("notify_count=") + builder.WriteString(fmt.Sprintf("%v", _m.NotifyCount)) + builder.WriteString(", ") + builder.WriteString("response=") + builder.WriteString(_m.Response) + builder.WriteString(", ") + builder.WriteString("notify_status=") + builder.WriteString(_m.NotifyStatus) + builder.WriteByte(')') + return builder.String() +} + +// PayNotifyLogs is a parsable slice of PayNotifyLog. +type PayNotifyLogs []*PayNotifyLog diff --git a/rpc/ent/paynotifylog/paynotifylog.go b/rpc/ent/paynotifylog/paynotifylog.go new file mode 100644 index 0000000..909f614 --- /dev/null +++ b/rpc/ent/paynotifylog/paynotifylog.go @@ -0,0 +1,152 @@ +// Code generated by ent, DO NOT EDIT. + +package paynotifylog + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the paynotifylog type in the database. + Label = "pay_notify_log" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldTaskID holds the string denoting the task_id field in the database. + FieldTaskID = "task_id" + // FieldNotifyCount holds the string denoting the notify_count field in the database. + FieldNotifyCount = "notify_count" + // FieldResponse holds the string denoting the response field in the database. + FieldResponse = "response" + // FieldNotifyStatus holds the string denoting the notify_status field in the database. + FieldNotifyStatus = "notify_status" + // EdgeTask holds the string denoting the task edge name in mutations. + EdgeTask = "task" + // Table holds the table name of the paynotifylog in the database. + Table = "pay_notify_log" + // TaskTable is the table that holds the task relation/edge. + TaskTable = "pay_notify_log" + // TaskInverseTable is the table name for the PayNotifyTask entity. + // It exists in this package in order to avoid circular dependency with the "paynotifytask" package. + TaskInverseTable = "pay_notify_task" + // TaskColumn is the table column denoting the task relation/edge. + TaskColumn = "task_id" +) + +// Columns holds all SQL columns for paynotifylog fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldTaskID, + FieldNotifyCount, + FieldResponse, + FieldNotifyStatus, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultNotifyCount holds the default value on creation for the "notify_count" field. + DefaultNotifyCount uint32 +) + +// OrderOption defines the ordering options for the PayNotifyLog queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByTaskID orders the results by the task_id field. +func ByTaskID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTaskID, opts...).ToFunc() +} + +// ByNotifyCount orders the results by the notify_count field. +func ByNotifyCount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyCount, opts...).ToFunc() +} + +// ByResponse orders the results by the response field. +func ByResponse(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResponse, opts...).ToFunc() +} + +// ByNotifyStatus orders the results by the notify_status field. +func ByNotifyStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyStatus, opts...).ToFunc() +} + +// ByTaskField orders the results by task field. +func ByTaskField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTaskStep(), sql.OrderByField(field, opts...)) + } +} +func newTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TaskTable, TaskColumn), + ) +} diff --git a/rpc/ent/paynotifylog/where.go b/rpc/ent/paynotifylog/where.go new file mode 100644 index 0000000..58aa699 --- /dev/null +++ b/rpc/ent/paynotifylog/where.go @@ -0,0 +1,569 @@ +// Code generated by ent, DO NOT EDIT. + +package paynotifylog + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldDeletedAt, v)) +} + +// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ. +func TaskID(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldTaskID, v)) +} + +// NotifyCount applies equality check predicate on the "notify_count" field. It's identical to NotifyCountEQ. +func NotifyCount(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldNotifyCount, v)) +} + +// Response applies equality check predicate on the "response" field. It's identical to ResponseEQ. +func Response(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldResponse, v)) +} + +// NotifyStatus applies equality check predicate on the "notify_status" field. It's identical to NotifyStatusEQ. +func NotifyStatus(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldNotifyStatus, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotNull(FieldDeletedAt)) +} + +// TaskIDEQ applies the EQ predicate on the "task_id" field. +func TaskIDEQ(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldTaskID, v)) +} + +// TaskIDNEQ applies the NEQ predicate on the "task_id" field. +func TaskIDNEQ(v uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldTaskID, v)) +} + +// TaskIDIn applies the In predicate on the "task_id" field. +func TaskIDIn(vs ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldTaskID, vs...)) +} + +// TaskIDNotIn applies the NotIn predicate on the "task_id" field. +func TaskIDNotIn(vs ...uint64) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldTaskID, vs...)) +} + +// NotifyCountEQ applies the EQ predicate on the "notify_count" field. +func NotifyCountEQ(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldNotifyCount, v)) +} + +// NotifyCountNEQ applies the NEQ predicate on the "notify_count" field. +func NotifyCountNEQ(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldNotifyCount, v)) +} + +// NotifyCountIn applies the In predicate on the "notify_count" field. +func NotifyCountIn(vs ...uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldNotifyCount, vs...)) +} + +// NotifyCountNotIn applies the NotIn predicate on the "notify_count" field. +func NotifyCountNotIn(vs ...uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldNotifyCount, vs...)) +} + +// NotifyCountGT applies the GT predicate on the "notify_count" field. +func NotifyCountGT(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldNotifyCount, v)) +} + +// NotifyCountGTE applies the GTE predicate on the "notify_count" field. +func NotifyCountGTE(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldNotifyCount, v)) +} + +// NotifyCountLT applies the LT predicate on the "notify_count" field. +func NotifyCountLT(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldNotifyCount, v)) +} + +// NotifyCountLTE applies the LTE predicate on the "notify_count" field. +func NotifyCountLTE(v uint32) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldNotifyCount, v)) +} + +// ResponseEQ applies the EQ predicate on the "response" field. +func ResponseEQ(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldResponse, v)) +} + +// ResponseNEQ applies the NEQ predicate on the "response" field. +func ResponseNEQ(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldResponse, v)) +} + +// ResponseIn applies the In predicate on the "response" field. +func ResponseIn(vs ...string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldResponse, vs...)) +} + +// ResponseNotIn applies the NotIn predicate on the "response" field. +func ResponseNotIn(vs ...string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldResponse, vs...)) +} + +// ResponseGT applies the GT predicate on the "response" field. +func ResponseGT(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldResponse, v)) +} + +// ResponseGTE applies the GTE predicate on the "response" field. +func ResponseGTE(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldResponse, v)) +} + +// ResponseLT applies the LT predicate on the "response" field. +func ResponseLT(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldResponse, v)) +} + +// ResponseLTE applies the LTE predicate on the "response" field. +func ResponseLTE(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldResponse, v)) +} + +// ResponseContains applies the Contains predicate on the "response" field. +func ResponseContains(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldContains(FieldResponse, v)) +} + +// ResponseHasPrefix applies the HasPrefix predicate on the "response" field. +func ResponseHasPrefix(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldHasPrefix(FieldResponse, v)) +} + +// ResponseHasSuffix applies the HasSuffix predicate on the "response" field. +func ResponseHasSuffix(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldHasSuffix(FieldResponse, v)) +} + +// ResponseIsNil applies the IsNil predicate on the "response" field. +func ResponseIsNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIsNull(FieldResponse)) +} + +// ResponseNotNil applies the NotNil predicate on the "response" field. +func ResponseNotNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotNull(FieldResponse)) +} + +// ResponseEqualFold applies the EqualFold predicate on the "response" field. +func ResponseEqualFold(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEqualFold(FieldResponse, v)) +} + +// ResponseContainsFold applies the ContainsFold predicate on the "response" field. +func ResponseContainsFold(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldContainsFold(FieldResponse, v)) +} + +// NotifyStatusEQ applies the EQ predicate on the "notify_status" field. +func NotifyStatusEQ(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEQ(FieldNotifyStatus, v)) +} + +// NotifyStatusNEQ applies the NEQ predicate on the "notify_status" field. +func NotifyStatusNEQ(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNEQ(FieldNotifyStatus, v)) +} + +// NotifyStatusIn applies the In predicate on the "notify_status" field. +func NotifyStatusIn(vs ...string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIn(FieldNotifyStatus, vs...)) +} + +// NotifyStatusNotIn applies the NotIn predicate on the "notify_status" field. +func NotifyStatusNotIn(vs ...string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotIn(FieldNotifyStatus, vs...)) +} + +// NotifyStatusGT applies the GT predicate on the "notify_status" field. +func NotifyStatusGT(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGT(FieldNotifyStatus, v)) +} + +// NotifyStatusGTE applies the GTE predicate on the "notify_status" field. +func NotifyStatusGTE(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldGTE(FieldNotifyStatus, v)) +} + +// NotifyStatusLT applies the LT predicate on the "notify_status" field. +func NotifyStatusLT(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLT(FieldNotifyStatus, v)) +} + +// NotifyStatusLTE applies the LTE predicate on the "notify_status" field. +func NotifyStatusLTE(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldLTE(FieldNotifyStatus, v)) +} + +// NotifyStatusContains applies the Contains predicate on the "notify_status" field. +func NotifyStatusContains(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldContains(FieldNotifyStatus, v)) +} + +// NotifyStatusHasPrefix applies the HasPrefix predicate on the "notify_status" field. +func NotifyStatusHasPrefix(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldHasPrefix(FieldNotifyStatus, v)) +} + +// NotifyStatusHasSuffix applies the HasSuffix predicate on the "notify_status" field. +func NotifyStatusHasSuffix(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldHasSuffix(FieldNotifyStatus, v)) +} + +// NotifyStatusIsNil applies the IsNil predicate on the "notify_status" field. +func NotifyStatusIsNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldIsNull(FieldNotifyStatus)) +} + +// NotifyStatusNotNil applies the NotNil predicate on the "notify_status" field. +func NotifyStatusNotNil() predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldNotNull(FieldNotifyStatus)) +} + +// NotifyStatusEqualFold applies the EqualFold predicate on the "notify_status" field. +func NotifyStatusEqualFold(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldEqualFold(FieldNotifyStatus, v)) +} + +// NotifyStatusContainsFold applies the ContainsFold predicate on the "notify_status" field. +func NotifyStatusContainsFold(v string) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.FieldContainsFold(FieldNotifyStatus, v)) +} + +// HasTask applies the HasEdge predicate on the "task" edge. +func HasTask() predicate.PayNotifyLog { + return predicate.PayNotifyLog(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TaskTable, TaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates). +func HasTaskWith(preds ...predicate.PayNotifyTask) predicate.PayNotifyLog { + return predicate.PayNotifyLog(func(s *sql.Selector) { + step := newTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayNotifyLog) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayNotifyLog) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayNotifyLog) predicate.PayNotifyLog { + return predicate.PayNotifyLog(sql.NotPredicates(p)) +} diff --git a/rpc/ent/paynotifylog_create.go b/rpc/ent/paynotifylog_create.go new file mode 100644 index 0000000..273d082 --- /dev/null +++ b/rpc/ent/paynotifylog_create.go @@ -0,0 +1,400 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyLogCreate is the builder for creating a PayNotifyLog entity. +type PayNotifyLogCreate struct { + config + mutation *PayNotifyLogMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayNotifyLogCreate) SetCreatedAt(v time.Time) *PayNotifyLogCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableCreatedAt(v *time.Time) *PayNotifyLogCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayNotifyLogCreate) SetUpdatedAt(v time.Time) *PayNotifyLogCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableUpdatedAt(v *time.Time) *PayNotifyLogCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayNotifyLogCreate) SetStatus(v uint8) *PayNotifyLogCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableStatus(v *uint8) *PayNotifyLogCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayNotifyLogCreate) SetTenantID(v uint64) *PayNotifyLogCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableTenantID(v *uint64) *PayNotifyLogCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayNotifyLogCreate) SetDeletedAt(v time.Time) *PayNotifyLogCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableDeletedAt(v *time.Time) *PayNotifyLogCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetTaskID sets the "task_id" field. +func (_c *PayNotifyLogCreate) SetTaskID(v uint64) *PayNotifyLogCreate { + _c.mutation.SetTaskID(v) + return _c +} + +// SetNotifyCount sets the "notify_count" field. +func (_c *PayNotifyLogCreate) SetNotifyCount(v uint32) *PayNotifyLogCreate { + _c.mutation.SetNotifyCount(v) + return _c +} + +// SetNillableNotifyCount sets the "notify_count" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableNotifyCount(v *uint32) *PayNotifyLogCreate { + if v != nil { + _c.SetNotifyCount(*v) + } + return _c +} + +// SetResponse sets the "response" field. +func (_c *PayNotifyLogCreate) SetResponse(v string) *PayNotifyLogCreate { + _c.mutation.SetResponse(v) + return _c +} + +// SetNillableResponse sets the "response" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableResponse(v *string) *PayNotifyLogCreate { + if v != nil { + _c.SetResponse(*v) + } + return _c +} + +// SetNotifyStatus sets the "notify_status" field. +func (_c *PayNotifyLogCreate) SetNotifyStatus(v string) *PayNotifyLogCreate { + _c.mutation.SetNotifyStatus(v) + return _c +} + +// SetNillableNotifyStatus sets the "notify_status" field if the given value is not nil. +func (_c *PayNotifyLogCreate) SetNillableNotifyStatus(v *string) *PayNotifyLogCreate { + if v != nil { + _c.SetNotifyStatus(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayNotifyLogCreate) SetID(v uint64) *PayNotifyLogCreate { + _c.mutation.SetID(v) + return _c +} + +// SetTask sets the "task" edge to the PayNotifyTask entity. +func (_c *PayNotifyLogCreate) SetTask(v *PayNotifyTask) *PayNotifyLogCreate { + return _c.SetTaskID(v.ID) +} + +// Mutation returns the PayNotifyLogMutation object of the builder. +func (_c *PayNotifyLogCreate) Mutation() *PayNotifyLogMutation { + return _c.mutation +} + +// Save creates the PayNotifyLog in the database. +func (_c *PayNotifyLogCreate) Save(ctx context.Context) (*PayNotifyLog, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayNotifyLogCreate) SaveX(ctx context.Context) *PayNotifyLog { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayNotifyLogCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayNotifyLogCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayNotifyLogCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := paynotifylog.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := paynotifylog.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := paynotifylog.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := paynotifylog.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.NotifyCount(); !ok { + v := paynotifylog.DefaultNotifyCount + _c.mutation.SetNotifyCount(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayNotifyLogCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayNotifyLog.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayNotifyLog.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayNotifyLog.tenant_id"`)} + } + if _, ok := _c.mutation.TaskID(); !ok { + return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "PayNotifyLog.task_id"`)} + } + if _, ok := _c.mutation.NotifyCount(); !ok { + return &ValidationError{Name: "notify_count", err: errors.New(`ent: missing required field "PayNotifyLog.notify_count"`)} + } + if len(_c.mutation.TaskIDs()) == 0 { + return &ValidationError{Name: "task", err: errors.New(`ent: missing required edge "PayNotifyLog.task"`)} + } + return nil +} + +func (_c *PayNotifyLogCreate) sqlSave(ctx context.Context) (*PayNotifyLog, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.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) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayNotifyLogCreate) createSpec() (*PayNotifyLog, *sqlgraph.CreateSpec) { + var ( + _node = &PayNotifyLog{config: _c.config} + _spec = sqlgraph.NewCreateSpec(paynotifylog.Table, sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(paynotifylog.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(paynotifylog.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(paynotifylog.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(paynotifylog.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(paynotifylog.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.NotifyCount(); ok { + _spec.SetField(paynotifylog.FieldNotifyCount, field.TypeUint32, value) + _node.NotifyCount = value + } + if value, ok := _c.mutation.Response(); ok { + _spec.SetField(paynotifylog.FieldResponse, field.TypeString, value) + _node.Response = value + } + if value, ok := _c.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifylog.FieldNotifyStatus, field.TypeString, value) + _node.NotifyStatus = value + } + if nodes := _c.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifylog.TaskTable, + Columns: []string{paynotifylog.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.TaskID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayNotifyLogCreateBulk is the builder for creating many PayNotifyLog entities in bulk. +type PayNotifyLogCreateBulk struct { + config + err error + builders []*PayNotifyLogCreate +} + +// Save creates the PayNotifyLog entities in the database. +func (_c *PayNotifyLogCreateBulk) Save(ctx context.Context) ([]*PayNotifyLog, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayNotifyLog, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayNotifyLogMutation) + 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, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.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, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayNotifyLogCreateBulk) SaveX(ctx context.Context) []*PayNotifyLog { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayNotifyLogCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayNotifyLogCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paynotifylog_delete.go b/rpc/ent/paynotifylog_delete.go new file mode 100644 index 0000000..a9e0c77 --- /dev/null +++ b/rpc/ent/paynotifylog_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyLogDelete is the builder for deleting a PayNotifyLog entity. +type PayNotifyLogDelete struct { + config + hooks []Hook + mutation *PayNotifyLogMutation +} + +// Where appends a list predicates to the PayNotifyLogDelete builder. +func (_d *PayNotifyLogDelete) Where(ps ...predicate.PayNotifyLog) *PayNotifyLogDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayNotifyLogDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayNotifyLogDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayNotifyLogDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(paynotifylog.Table, sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// PayNotifyLogDeleteOne is the builder for deleting a single PayNotifyLog entity. +type PayNotifyLogDeleteOne struct { + _d *PayNotifyLogDelete +} + +// Where appends a list predicates to the PayNotifyLogDelete builder. +func (_d *PayNotifyLogDeleteOne) Where(ps ...predicate.PayNotifyLog) *PayNotifyLogDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayNotifyLogDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{paynotifylog.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayNotifyLogDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paynotifylog_query.go b/rpc/ent/paynotifylog_query.go new file mode 100644 index 0000000..9057f1b --- /dev/null +++ b/rpc/ent/paynotifylog_query.go @@ -0,0 +1,606 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyLogQuery is the builder for querying PayNotifyLog entities. +type PayNotifyLogQuery struct { + config + ctx *QueryContext + order []paynotifylog.OrderOption + inters []Interceptor + predicates []predicate.PayNotifyLog + withTask *PayNotifyTaskQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayNotifyLogQuery builder. +func (_q *PayNotifyLogQuery) Where(ps ...predicate.PayNotifyLog) *PayNotifyLogQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayNotifyLogQuery) Limit(limit int) *PayNotifyLogQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayNotifyLogQuery) Offset(offset int) *PayNotifyLogQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *PayNotifyLogQuery) Unique(unique bool) *PayNotifyLogQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayNotifyLogQuery) Order(o ...paynotifylog.OrderOption) *PayNotifyLogQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryTask chains the current query on the "task" edge. +func (_q *PayNotifyLogQuery) QueryTask() *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paynotifylog.Table, paynotifylog.FieldID, selector), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifylog.TaskTable, paynotifylog.TaskColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayNotifyLog entity from the query. +// Returns a *NotFoundError when no PayNotifyLog was found. +func (_q *PayNotifyLogQuery) First(ctx context.Context) (*PayNotifyLog, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{paynotifylog.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayNotifyLogQuery) FirstX(ctx context.Context) *PayNotifyLog { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayNotifyLog ID from the query. +// Returns a *NotFoundError when no PayNotifyLog ID was found. +func (_q *PayNotifyLogQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{paynotifylog.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayNotifyLogQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayNotifyLog entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayNotifyLog entity is found. +// Returns a *NotFoundError when no PayNotifyLog entities are found. +func (_q *PayNotifyLogQuery) Only(ctx context.Context) (*PayNotifyLog, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{paynotifylog.Label} + default: + return nil, &NotSingularError{paynotifylog.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayNotifyLogQuery) OnlyX(ctx context.Context) *PayNotifyLog { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayNotifyLog ID in the query. +// Returns a *NotSingularError when more than one PayNotifyLog ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayNotifyLogQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{paynotifylog.Label} + default: + err = &NotSingularError{paynotifylog.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayNotifyLogQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayNotifyLogs. +func (_q *PayNotifyLogQuery) All(ctx context.Context) ([]*PayNotifyLog, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayNotifyLog, *PayNotifyLogQuery]() + return withInterceptors[[]*PayNotifyLog](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayNotifyLogQuery) AllX(ctx context.Context) []*PayNotifyLog { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayNotifyLog IDs. +func (_q *PayNotifyLogQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(paynotifylog.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayNotifyLogQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayNotifyLogQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*PayNotifyLogQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayNotifyLogQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *PayNotifyLogQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *PayNotifyLogQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayNotifyLogQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *PayNotifyLogQuery) Clone() *PayNotifyLogQuery { + if _q == nil { + return nil + } + return &PayNotifyLogQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]paynotifylog.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayNotifyLog{}, _q.predicates...), + withTask: _q.withTask.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithTask tells the query-builder to eager-load the nodes that are connected to +// the "task" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayNotifyLogQuery) WithTask(opts ...func(*PayNotifyTaskQuery)) *PayNotifyLogQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withTask = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayNotifyLog.Query(). +// GroupBy(paynotifylog.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayNotifyLogQuery) GroupBy(field string, fields ...string) *PayNotifyLogGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayNotifyLogGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = paynotifylog.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayNotifyLog.Query(). +// Select(paynotifylog.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayNotifyLogQuery) Select(fields ...string) *PayNotifyLogSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayNotifyLogSelect{PayNotifyLogQuery: _q} + sbuild.label = paynotifylog.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayNotifyLogSelect configured with the given aggregations. +func (_q *PayNotifyLogQuery) Aggregate(fns ...AggregateFunc) *PayNotifyLogSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayNotifyLogQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !paynotifylog.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *PayNotifyLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayNotifyLog, error) { + var ( + nodes = []*PayNotifyLog{} + _spec = _q.querySpec() + loadedTypes = [1]bool{ + _q.withTask != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayNotifyLog).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayNotifyLog{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withTask; query != nil { + if err := _q.loadTask(ctx, query, nodes, nil, + func(n *PayNotifyLog, e *PayNotifyTask) { n.Edges.Task = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayNotifyLogQuery) loadTask(ctx context.Context, query *PayNotifyTaskQuery, nodes []*PayNotifyLog, init func(*PayNotifyLog), assign func(*PayNotifyLog, *PayNotifyTask)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayNotifyLog) + for i := range nodes { + fk := nodes[i].TaskID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(paynotifytask.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "task_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *PayNotifyLogQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *PayNotifyLogQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(paynotifylog.Table, paynotifylog.Columns, sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, paynotifylog.FieldID) + for i := range fields { + if fields[i] != paynotifylog.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withTask != nil { + _spec.Node.AddColumnOnce(paynotifylog.FieldTaskID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *PayNotifyLogQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(paynotifylog.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = paynotifylog.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// PayNotifyLogGroupBy is the group-by builder for PayNotifyLog entities. +type PayNotifyLogGroupBy struct { + selector + build *PayNotifyLogQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayNotifyLogGroupBy) Aggregate(fns ...AggregateFunc) *PayNotifyLogGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayNotifyLogGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayNotifyLogQuery, *PayNotifyLogGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayNotifyLogGroupBy) sqlScan(ctx context.Context, root *PayNotifyLogQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PayNotifyLogSelect is the builder for selecting fields of PayNotifyLog entities. +type PayNotifyLogSelect struct { + *PayNotifyLogQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayNotifyLogSelect) Aggregate(fns ...AggregateFunc) *PayNotifyLogSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayNotifyLogSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayNotifyLogQuery, *PayNotifyLogSelect](ctx, _s.PayNotifyLogQuery, _s, _s.inters, v) +} + +func (_s *PayNotifyLogSelect) sqlScan(ctx context.Context, root *PayNotifyLogQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/paynotifylog_update.go b/rpc/ent/paynotifylog_update.go new file mode 100644 index 0000000..f4c29b0 --- /dev/null +++ b/rpc/ent/paynotifylog_update.go @@ -0,0 +1,625 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyLogUpdate is the builder for updating PayNotifyLog entities. +type PayNotifyLogUpdate struct { + config + hooks []Hook + mutation *PayNotifyLogMutation +} + +// Where appends a list predicates to the PayNotifyLogUpdate builder. +func (_u *PayNotifyLogUpdate) Where(ps ...predicate.PayNotifyLog) *PayNotifyLogUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayNotifyLogUpdate) SetUpdatedAt(v time.Time) *PayNotifyLogUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayNotifyLogUpdate) SetStatus(v uint8) *PayNotifyLogUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableStatus(v *uint8) *PayNotifyLogUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayNotifyLogUpdate) AddStatus(v int8) *PayNotifyLogUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayNotifyLogUpdate) ClearStatus() *PayNotifyLogUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayNotifyLogUpdate) SetDeletedAt(v time.Time) *PayNotifyLogUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableDeletedAt(v *time.Time) *PayNotifyLogUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayNotifyLogUpdate) ClearDeletedAt() *PayNotifyLogUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetTaskID sets the "task_id" field. +func (_u *PayNotifyLogUpdate) SetTaskID(v uint64) *PayNotifyLogUpdate { + _u.mutation.SetTaskID(v) + return _u +} + +// SetNillableTaskID sets the "task_id" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableTaskID(v *uint64) *PayNotifyLogUpdate { + if v != nil { + _u.SetTaskID(*v) + } + return _u +} + +// SetNotifyCount sets the "notify_count" field. +func (_u *PayNotifyLogUpdate) SetNotifyCount(v uint32) *PayNotifyLogUpdate { + _u.mutation.ResetNotifyCount() + _u.mutation.SetNotifyCount(v) + return _u +} + +// SetNillableNotifyCount sets the "notify_count" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableNotifyCount(v *uint32) *PayNotifyLogUpdate { + if v != nil { + _u.SetNotifyCount(*v) + } + return _u +} + +// AddNotifyCount adds value to the "notify_count" field. +func (_u *PayNotifyLogUpdate) AddNotifyCount(v int32) *PayNotifyLogUpdate { + _u.mutation.AddNotifyCount(v) + return _u +} + +// SetResponse sets the "response" field. +func (_u *PayNotifyLogUpdate) SetResponse(v string) *PayNotifyLogUpdate { + _u.mutation.SetResponse(v) + return _u +} + +// SetNillableResponse sets the "response" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableResponse(v *string) *PayNotifyLogUpdate { + if v != nil { + _u.SetResponse(*v) + } + return _u +} + +// ClearResponse clears the value of the "response" field. +func (_u *PayNotifyLogUpdate) ClearResponse() *PayNotifyLogUpdate { + _u.mutation.ClearResponse() + return _u +} + +// SetNotifyStatus sets the "notify_status" field. +func (_u *PayNotifyLogUpdate) SetNotifyStatus(v string) *PayNotifyLogUpdate { + _u.mutation.SetNotifyStatus(v) + return _u +} + +// SetNillableNotifyStatus sets the "notify_status" field if the given value is not nil. +func (_u *PayNotifyLogUpdate) SetNillableNotifyStatus(v *string) *PayNotifyLogUpdate { + if v != nil { + _u.SetNotifyStatus(*v) + } + return _u +} + +// ClearNotifyStatus clears the value of the "notify_status" field. +func (_u *PayNotifyLogUpdate) ClearNotifyStatus() *PayNotifyLogUpdate { + _u.mutation.ClearNotifyStatus() + return _u +} + +// SetTask sets the "task" edge to the PayNotifyTask entity. +func (_u *PayNotifyLogUpdate) SetTask(v *PayNotifyTask) *PayNotifyLogUpdate { + return _u.SetTaskID(v.ID) +} + +// Mutation returns the PayNotifyLogMutation object of the builder. +func (_u *PayNotifyLogUpdate) Mutation() *PayNotifyLogMutation { + return _u.mutation +} + +// ClearTask clears the "task" edge to the PayNotifyTask entity. +func (_u *PayNotifyLogUpdate) ClearTask() *PayNotifyLogUpdate { + _u.mutation.ClearTask() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayNotifyLogUpdate) 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 *PayNotifyLogUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayNotifyLogUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayNotifyLogUpdate) 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 *PayNotifyLogUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paynotifylog.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayNotifyLogUpdate) check() error { + if _u.mutation.TaskCleared() && len(_u.mutation.TaskIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyLog.task"`) + } + return nil +} + +func (_u *PayNotifyLogUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paynotifylog.Table, paynotifylog.Columns, sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(paynotifylog.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paynotifylog.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paynotifylog.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paynotifylog.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paynotifylog.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paynotifylog.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.NotifyCount(); ok { + _spec.SetField(paynotifylog.FieldNotifyCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedNotifyCount(); ok { + _spec.AddField(paynotifylog.FieldNotifyCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.Response(); ok { + _spec.SetField(paynotifylog.FieldResponse, field.TypeString, value) + } + if _u.mutation.ResponseCleared() { + _spec.ClearField(paynotifylog.FieldResponse, field.TypeString) + } + if value, ok := _u.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifylog.FieldNotifyStatus, field.TypeString, value) + } + if _u.mutation.NotifyStatusCleared() { + _spec.ClearField(paynotifylog.FieldNotifyStatus, field.TypeString) + } + if _u.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifylog.TaskTable, + Columns: []string{paynotifylog.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifylog.TaskTable, + Columns: []string{paynotifylog.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{paynotifylog.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayNotifyLogUpdateOne is the builder for updating a single PayNotifyLog entity. +type PayNotifyLogUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayNotifyLogMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayNotifyLogUpdateOne) SetUpdatedAt(v time.Time) *PayNotifyLogUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayNotifyLogUpdateOne) SetStatus(v uint8) *PayNotifyLogUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableStatus(v *uint8) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayNotifyLogUpdateOne) AddStatus(v int8) *PayNotifyLogUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayNotifyLogUpdateOne) ClearStatus() *PayNotifyLogUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayNotifyLogUpdateOne) SetDeletedAt(v time.Time) *PayNotifyLogUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableDeletedAt(v *time.Time) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayNotifyLogUpdateOne) ClearDeletedAt() *PayNotifyLogUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetTaskID sets the "task_id" field. +func (_u *PayNotifyLogUpdateOne) SetTaskID(v uint64) *PayNotifyLogUpdateOne { + _u.mutation.SetTaskID(v) + return _u +} + +// SetNillableTaskID sets the "task_id" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableTaskID(v *uint64) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetTaskID(*v) + } + return _u +} + +// SetNotifyCount sets the "notify_count" field. +func (_u *PayNotifyLogUpdateOne) SetNotifyCount(v uint32) *PayNotifyLogUpdateOne { + _u.mutation.ResetNotifyCount() + _u.mutation.SetNotifyCount(v) + return _u +} + +// SetNillableNotifyCount sets the "notify_count" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableNotifyCount(v *uint32) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetNotifyCount(*v) + } + return _u +} + +// AddNotifyCount adds value to the "notify_count" field. +func (_u *PayNotifyLogUpdateOne) AddNotifyCount(v int32) *PayNotifyLogUpdateOne { + _u.mutation.AddNotifyCount(v) + return _u +} + +// SetResponse sets the "response" field. +func (_u *PayNotifyLogUpdateOne) SetResponse(v string) *PayNotifyLogUpdateOne { + _u.mutation.SetResponse(v) + return _u +} + +// SetNillableResponse sets the "response" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableResponse(v *string) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetResponse(*v) + } + return _u +} + +// ClearResponse clears the value of the "response" field. +func (_u *PayNotifyLogUpdateOne) ClearResponse() *PayNotifyLogUpdateOne { + _u.mutation.ClearResponse() + return _u +} + +// SetNotifyStatus sets the "notify_status" field. +func (_u *PayNotifyLogUpdateOne) SetNotifyStatus(v string) *PayNotifyLogUpdateOne { + _u.mutation.SetNotifyStatus(v) + return _u +} + +// SetNillableNotifyStatus sets the "notify_status" field if the given value is not nil. +func (_u *PayNotifyLogUpdateOne) SetNillableNotifyStatus(v *string) *PayNotifyLogUpdateOne { + if v != nil { + _u.SetNotifyStatus(*v) + } + return _u +} + +// ClearNotifyStatus clears the value of the "notify_status" field. +func (_u *PayNotifyLogUpdateOne) ClearNotifyStatus() *PayNotifyLogUpdateOne { + _u.mutation.ClearNotifyStatus() + return _u +} + +// SetTask sets the "task" edge to the PayNotifyTask entity. +func (_u *PayNotifyLogUpdateOne) SetTask(v *PayNotifyTask) *PayNotifyLogUpdateOne { + return _u.SetTaskID(v.ID) +} + +// Mutation returns the PayNotifyLogMutation object of the builder. +func (_u *PayNotifyLogUpdateOne) Mutation() *PayNotifyLogMutation { + return _u.mutation +} + +// ClearTask clears the "task" edge to the PayNotifyTask entity. +func (_u *PayNotifyLogUpdateOne) ClearTask() *PayNotifyLogUpdateOne { + _u.mutation.ClearTask() + return _u +} + +// Where appends a list predicates to the PayNotifyLogUpdate builder. +func (_u *PayNotifyLogUpdateOne) Where(ps ...predicate.PayNotifyLog) *PayNotifyLogUpdateOne { + _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 *PayNotifyLogUpdateOne) Select(field string, fields ...string) *PayNotifyLogUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayNotifyLog entity. +func (_u *PayNotifyLogUpdateOne) Save(ctx context.Context) (*PayNotifyLog, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayNotifyLogUpdateOne) SaveX(ctx context.Context) *PayNotifyLog { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayNotifyLogUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayNotifyLogUpdateOne) 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 *PayNotifyLogUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paynotifylog.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayNotifyLogUpdateOne) check() error { + if _u.mutation.TaskCleared() && len(_u.mutation.TaskIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyLog.task"`) + } + return nil +} + +func (_u *PayNotifyLogUpdateOne) sqlSave(ctx context.Context) (_node *PayNotifyLog, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paynotifylog.Table, paynotifylog.Columns, sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayNotifyLog.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, paynotifylog.FieldID) + for _, f := range fields { + if !paynotifylog.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != paynotifylog.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.UpdatedAt(); ok { + _spec.SetField(paynotifylog.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paynotifylog.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paynotifylog.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paynotifylog.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paynotifylog.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paynotifylog.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.NotifyCount(); ok { + _spec.SetField(paynotifylog.FieldNotifyCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedNotifyCount(); ok { + _spec.AddField(paynotifylog.FieldNotifyCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.Response(); ok { + _spec.SetField(paynotifylog.FieldResponse, field.TypeString, value) + } + if _u.mutation.ResponseCleared() { + _spec.ClearField(paynotifylog.FieldResponse, field.TypeString) + } + if value, ok := _u.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifylog.FieldNotifyStatus, field.TypeString, value) + } + if _u.mutation.NotifyStatusCleared() { + _spec.ClearField(paynotifylog.FieldNotifyStatus, field.TypeString) + } + if _u.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifylog.TaskTable, + Columns: []string{paynotifylog.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifylog.TaskTable, + Columns: []string{paynotifylog.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayNotifyLog{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{paynotifylog.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/paynotifytask.go b/rpc/ent/paynotifytask.go new file mode 100644 index 0000000..5760649 --- /dev/null +++ b/rpc/ent/paynotifytask.go @@ -0,0 +1,324 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayNotifyTask Table | 异步通知任务表 +type PayNotifyTask struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 通知类型 + Type uint8 `json:"type,omitempty"` + // 数据 ID + DataID uint64 `json:"data_id,omitempty"` + // 订单 ID + OrderID uint64 `json:"order_id,omitempty"` + // 应用 ID + AppID uint64 `json:"app_id,omitempty"` + // 通知状态 + NotifyStatus uint8 `json:"notify_status,omitempty"` + // 下次通知时间 + NextNotifyTime time.Time `json:"next_notify_time,omitempty"` + // 最后一次执行时间 + LastExecuteTime time.Time `json:"last_execute_time,omitempty"` + // 重试次数 + RetryCount uint32 `json:"retry_count,omitempty"` + // 最大重试次数 + MaxRetryCount uint32 `json:"max_retry_count,omitempty"` + // 通知地址 + NotifyURL string `json:"notify_url,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayNotifyTaskQuery when eager-loading is set. + Edges PayNotifyTaskEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayNotifyTaskEdges holds the relations/edges for other nodes in the graph. +type PayNotifyTaskEdges struct { + // App holds the value of the app edge. + App *App `json:"app,omitempty"` + // Order holds the value of the order edge. + Order *PayOrder `json:"order,omitempty"` + // NotifyLog holds the value of the notify_log edge. + NotifyLog []*PayNotifyLog `json:"notify_log,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [3]bool +} + +// AppOrErr returns the App value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayNotifyTaskEdges) AppOrErr() (*App, error) { + if e.App != nil { + return e.App, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: app.Label} + } + return nil, &NotLoadedError{edge: "app"} +} + +// OrderOrErr returns the Order value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayNotifyTaskEdges) OrderOrErr() (*PayOrder, error) { + if e.Order != nil { + return e.Order, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: payorder.Label} + } + return nil, &NotLoadedError{edge: "order"} +} + +// NotifyLogOrErr returns the NotifyLog value or an error if the edge +// was not loaded in eager-loading. +func (e PayNotifyTaskEdges) NotifyLogOrErr() ([]*PayNotifyLog, error) { + if e.loadedTypes[2] { + return e.NotifyLog, nil + } + return nil, &NotLoadedError{edge: "notify_log"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayNotifyTask) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case paynotifytask.FieldID, paynotifytask.FieldStatus, paynotifytask.FieldTenantID, paynotifytask.FieldType, paynotifytask.FieldDataID, paynotifytask.FieldOrderID, paynotifytask.FieldAppID, paynotifytask.FieldNotifyStatus, paynotifytask.FieldRetryCount, paynotifytask.FieldMaxRetryCount: + values[i] = new(sql.NullInt64) + case paynotifytask.FieldNotifyURL: + values[i] = new(sql.NullString) + case paynotifytask.FieldCreatedAt, paynotifytask.FieldUpdatedAt, paynotifytask.FieldDeletedAt, paynotifytask.FieldNextNotifyTime, paynotifytask.FieldLastExecuteTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PayNotifyTask fields. +func (_m *PayNotifyTask) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case paynotifytask.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case paynotifytask.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case paynotifytask.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case paynotifytask.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case paynotifytask.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case paynotifytask.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case paynotifytask.FieldType: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = uint8(value.Int64) + } + case paynotifytask.FieldDataID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field data_id", values[i]) + } else if value.Valid { + _m.DataID = uint64(value.Int64) + } + case paynotifytask.FieldOrderID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field order_id", values[i]) + } else if value.Valid { + _m.OrderID = uint64(value.Int64) + } + case paynotifytask.FieldAppID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field app_id", values[i]) + } else if value.Valid { + _m.AppID = uint64(value.Int64) + } + case paynotifytask.FieldNotifyStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field notify_status", values[i]) + } else if value.Valid { + _m.NotifyStatus = uint8(value.Int64) + } + case paynotifytask.FieldNextNotifyTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field next_notify_time", values[i]) + } else if value.Valid { + _m.NextNotifyTime = value.Time + } + case paynotifytask.FieldLastExecuteTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_execute_time", values[i]) + } else if value.Valid { + _m.LastExecuteTime = value.Time + } + case paynotifytask.FieldRetryCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field retry_count", values[i]) + } else if value.Valid { + _m.RetryCount = uint32(value.Int64) + } + case paynotifytask.FieldMaxRetryCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field max_retry_count", values[i]) + } else if value.Valid { + _m.MaxRetryCount = uint32(value.Int64) + } + case paynotifytask.FieldNotifyURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notify_url", values[i]) + } else if value.Valid { + _m.NotifyURL = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayNotifyTask. +// This includes values selected through modifiers, order, etc. +func (_m *PayNotifyTask) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryApp queries the "app" edge of the PayNotifyTask entity. +func (_m *PayNotifyTask) QueryApp() *AppQuery { + return NewPayNotifyTaskClient(_m.config).QueryApp(_m) +} + +// QueryOrder queries the "order" edge of the PayNotifyTask entity. +func (_m *PayNotifyTask) QueryOrder() *PayOrderQuery { + return NewPayNotifyTaskClient(_m.config).QueryOrder(_m) +} + +// QueryNotifyLog queries the "notify_log" edge of the PayNotifyTask entity. +func (_m *PayNotifyTask) QueryNotifyLog() *PayNotifyLogQuery { + return NewPayNotifyTaskClient(_m.config).QueryNotifyLog(_m) +} + +// Update returns a builder for updating this PayNotifyTask. +// Note that you need to call PayNotifyTask.Unwrap() before calling this method if this PayNotifyTask +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayNotifyTask) Update() *PayNotifyTaskUpdateOne { + return NewPayNotifyTaskClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayNotifyTask entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *PayNotifyTask) Unwrap() *PayNotifyTask { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayNotifyTask is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayNotifyTask) String() string { + var builder strings.Builder + builder.WriteString("PayNotifyTask(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", _m.Type)) + builder.WriteString(", ") + builder.WriteString("data_id=") + builder.WriteString(fmt.Sprintf("%v", _m.DataID)) + builder.WriteString(", ") + builder.WriteString("order_id=") + builder.WriteString(fmt.Sprintf("%v", _m.OrderID)) + builder.WriteString(", ") + builder.WriteString("app_id=") + builder.WriteString(fmt.Sprintf("%v", _m.AppID)) + builder.WriteString(", ") + builder.WriteString("notify_status=") + builder.WriteString(fmt.Sprintf("%v", _m.NotifyStatus)) + builder.WriteString(", ") + builder.WriteString("next_notify_time=") + builder.WriteString(_m.NextNotifyTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_execute_time=") + builder.WriteString(_m.LastExecuteTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("retry_count=") + builder.WriteString(fmt.Sprintf("%v", _m.RetryCount)) + builder.WriteString(", ") + builder.WriteString("max_retry_count=") + builder.WriteString(fmt.Sprintf("%v", _m.MaxRetryCount)) + builder.WriteString(", ") + builder.WriteString("notify_url=") + builder.WriteString(_m.NotifyURL) + builder.WriteByte(')') + return builder.String() +} + +// PayNotifyTasks is a parsable slice of PayNotifyTask. +type PayNotifyTasks []*PayNotifyTask diff --git a/rpc/ent/paynotifytask/paynotifytask.go b/rpc/ent/paynotifytask/paynotifytask.go new file mode 100644 index 0000000..e6d09ce --- /dev/null +++ b/rpc/ent/paynotifytask/paynotifytask.go @@ -0,0 +1,253 @@ +// Code generated by ent, DO NOT EDIT. + +package paynotifytask + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the paynotifytask type in the database. + Label = "pay_notify_task" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldDataID holds the string denoting the data_id field in the database. + FieldDataID = "data_id" + // FieldOrderID holds the string denoting the order_id field in the database. + FieldOrderID = "order_id" + // FieldAppID holds the string denoting the app_id field in the database. + FieldAppID = "app_id" + // FieldNotifyStatus holds the string denoting the notify_status field in the database. + FieldNotifyStatus = "notify_status" + // FieldNextNotifyTime holds the string denoting the next_notify_time field in the database. + FieldNextNotifyTime = "next_notify_time" + // FieldLastExecuteTime holds the string denoting the last_execute_time field in the database. + FieldLastExecuteTime = "last_execute_time" + // FieldRetryCount holds the string denoting the retry_count field in the database. + FieldRetryCount = "retry_count" + // FieldMaxRetryCount holds the string denoting the max_retry_count field in the database. + FieldMaxRetryCount = "max_retry_count" + // FieldNotifyURL holds the string denoting the notify_url field in the database. + FieldNotifyURL = "notify_url" + // EdgeApp holds the string denoting the app edge name in mutations. + EdgeApp = "app" + // EdgeOrder holds the string denoting the order edge name in mutations. + EdgeOrder = "order" + // EdgeNotifyLog holds the string denoting the notify_log edge name in mutations. + EdgeNotifyLog = "notify_log" + // Table holds the table name of the paynotifytask in the database. + Table = "pay_notify_task" + // AppTable is the table that holds the app relation/edge. + AppTable = "pay_notify_task" + // AppInverseTable is the table name for the App entity. + // It exists in this package in order to avoid circular dependency with the "app" package. + AppInverseTable = "pay_app" + // AppColumn is the table column denoting the app relation/edge. + AppColumn = "app_id" + // OrderTable is the table that holds the order relation/edge. + OrderTable = "pay_notify_task" + // OrderInverseTable is the table name for the PayOrder entity. + // It exists in this package in order to avoid circular dependency with the "payorder" package. + OrderInverseTable = "pay_order" + // OrderColumn is the table column denoting the order relation/edge. + OrderColumn = "order_id" + // NotifyLogTable is the table that holds the notify_log relation/edge. + NotifyLogTable = "pay_notify_log" + // NotifyLogInverseTable is the table name for the PayNotifyLog entity. + // It exists in this package in order to avoid circular dependency with the "paynotifylog" package. + NotifyLogInverseTable = "pay_notify_log" + // NotifyLogColumn is the table column denoting the notify_log relation/edge. + NotifyLogColumn = "task_id" +) + +// Columns holds all SQL columns for paynotifytask fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldType, + FieldDataID, + FieldOrderID, + FieldAppID, + FieldNotifyStatus, + FieldNextNotifyTime, + FieldLastExecuteTime, + FieldRetryCount, + FieldMaxRetryCount, + FieldNotifyURL, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultType holds the default value on creation for the "type" field. + DefaultType uint8 +) + +// OrderOption defines the ordering options for the PayNotifyTask queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByDataID orders the results by the data_id field. +func ByDataID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDataID, opts...).ToFunc() +} + +// ByOrderID orders the results by the order_id field. +func ByOrderID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderID, opts...).ToFunc() +} + +// ByAppID orders the results by the app_id field. +func ByAppID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAppID, opts...).ToFunc() +} + +// ByNotifyStatus orders the results by the notify_status field. +func ByNotifyStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyStatus, opts...).ToFunc() +} + +// ByNextNotifyTime orders the results by the next_notify_time field. +func ByNextNotifyTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNextNotifyTime, opts...).ToFunc() +} + +// ByLastExecuteTime orders the results by the last_execute_time field. +func ByLastExecuteTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastExecuteTime, opts...).ToFunc() +} + +// ByRetryCount orders the results by the retry_count field. +func ByRetryCount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRetryCount, opts...).ToFunc() +} + +// ByMaxRetryCount orders the results by the max_retry_count field. +func ByMaxRetryCount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMaxRetryCount, opts...).ToFunc() +} + +// ByNotifyURL orders the results by the notify_url field. +func ByNotifyURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyURL, opts...).ToFunc() +} + +// ByAppField orders the results by app field. +func ByAppField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAppStep(), sql.OrderByField(field, opts...)) + } +} + +// ByOrderField orders the results by order field. +func ByOrderField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrderStep(), sql.OrderByField(field, opts...)) + } +} + +// ByNotifyLogCount orders the results by notify_log count. +func ByNotifyLogCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNotifyLogStep(), opts...) + } +} + +// ByNotifyLog orders the results by notify_log terms. +func ByNotifyLog(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNotifyLogStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, AppTable, AppColumn), + ) +} +func newOrderStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrderInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) +} +func newNotifyLogStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NotifyLogInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyLogTable, NotifyLogColumn), + ) +} diff --git a/rpc/ent/paynotifytask/where.go b/rpc/ent/paynotifytask/where.go new file mode 100644 index 0000000..86f0601 --- /dev/null +++ b/rpc/ent/paynotifytask/where.go @@ -0,0 +1,870 @@ +// Code generated by ent, DO NOT EDIT. + +package paynotifytask + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldType, v)) +} + +// DataID applies equality check predicate on the "data_id" field. It's identical to DataIDEQ. +func DataID(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldDataID, v)) +} + +// OrderID applies equality check predicate on the "order_id" field. It's identical to OrderIDEQ. +func OrderID(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldOrderID, v)) +} + +// AppID applies equality check predicate on the "app_id" field. It's identical to AppIDEQ. +func AppID(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldAppID, v)) +} + +// NotifyStatus applies equality check predicate on the "notify_status" field. It's identical to NotifyStatusEQ. +func NotifyStatus(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNotifyStatus, v)) +} + +// NextNotifyTime applies equality check predicate on the "next_notify_time" field. It's identical to NextNotifyTimeEQ. +func NextNotifyTime(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNextNotifyTime, v)) +} + +// LastExecuteTime applies equality check predicate on the "last_execute_time" field. It's identical to LastExecuteTimeEQ. +func LastExecuteTime(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldLastExecuteTime, v)) +} + +// RetryCount applies equality check predicate on the "retry_count" field. It's identical to RetryCountEQ. +func RetryCount(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldRetryCount, v)) +} + +// MaxRetryCount applies equality check predicate on the "max_retry_count" field. It's identical to MaxRetryCountEQ. +func MaxRetryCount(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldMaxRetryCount, v)) +} + +// NotifyURL applies equality check predicate on the "notify_url" field. It's identical to NotifyURLEQ. +func NotifyURL(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNotifyURL, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldDeletedAt)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldType, v)) +} + +// DataIDEQ applies the EQ predicate on the "data_id" field. +func DataIDEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldDataID, v)) +} + +// DataIDNEQ applies the NEQ predicate on the "data_id" field. +func DataIDNEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldDataID, v)) +} + +// DataIDIn applies the In predicate on the "data_id" field. +func DataIDIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldDataID, vs...)) +} + +// DataIDNotIn applies the NotIn predicate on the "data_id" field. +func DataIDNotIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldDataID, vs...)) +} + +// DataIDGT applies the GT predicate on the "data_id" field. +func DataIDGT(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldDataID, v)) +} + +// DataIDGTE applies the GTE predicate on the "data_id" field. +func DataIDGTE(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldDataID, v)) +} + +// DataIDLT applies the LT predicate on the "data_id" field. +func DataIDLT(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldDataID, v)) +} + +// DataIDLTE applies the LTE predicate on the "data_id" field. +func DataIDLTE(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldDataID, v)) +} + +// OrderIDEQ applies the EQ predicate on the "order_id" field. +func OrderIDEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldOrderID, v)) +} + +// OrderIDNEQ applies the NEQ predicate on the "order_id" field. +func OrderIDNEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldOrderID, v)) +} + +// OrderIDIn applies the In predicate on the "order_id" field. +func OrderIDIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldOrderID, vs...)) +} + +// OrderIDNotIn applies the NotIn predicate on the "order_id" field. +func OrderIDNotIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldOrderID, vs...)) +} + +// AppIDEQ applies the EQ predicate on the "app_id" field. +func AppIDEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldAppID, v)) +} + +// AppIDNEQ applies the NEQ predicate on the "app_id" field. +func AppIDNEQ(v uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldAppID, v)) +} + +// AppIDIn applies the In predicate on the "app_id" field. +func AppIDIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldAppID, vs...)) +} + +// AppIDNotIn applies the NotIn predicate on the "app_id" field. +func AppIDNotIn(vs ...uint64) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldAppID, vs...)) +} + +// NotifyStatusEQ applies the EQ predicate on the "notify_status" field. +func NotifyStatusEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNotifyStatus, v)) +} + +// NotifyStatusNEQ applies the NEQ predicate on the "notify_status" field. +func NotifyStatusNEQ(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldNotifyStatus, v)) +} + +// NotifyStatusIn applies the In predicate on the "notify_status" field. +func NotifyStatusIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldNotifyStatus, vs...)) +} + +// NotifyStatusNotIn applies the NotIn predicate on the "notify_status" field. +func NotifyStatusNotIn(vs ...uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldNotifyStatus, vs...)) +} + +// NotifyStatusGT applies the GT predicate on the "notify_status" field. +func NotifyStatusGT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldNotifyStatus, v)) +} + +// NotifyStatusGTE applies the GTE predicate on the "notify_status" field. +func NotifyStatusGTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldNotifyStatus, v)) +} + +// NotifyStatusLT applies the LT predicate on the "notify_status" field. +func NotifyStatusLT(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldNotifyStatus, v)) +} + +// NotifyStatusLTE applies the LTE predicate on the "notify_status" field. +func NotifyStatusLTE(v uint8) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldNotifyStatus, v)) +} + +// NextNotifyTimeEQ applies the EQ predicate on the "next_notify_time" field. +func NextNotifyTimeEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeNEQ applies the NEQ predicate on the "next_notify_time" field. +func NextNotifyTimeNEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeIn applies the In predicate on the "next_notify_time" field. +func NextNotifyTimeIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldNextNotifyTime, vs...)) +} + +// NextNotifyTimeNotIn applies the NotIn predicate on the "next_notify_time" field. +func NextNotifyTimeNotIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldNextNotifyTime, vs...)) +} + +// NextNotifyTimeGT applies the GT predicate on the "next_notify_time" field. +func NextNotifyTimeGT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeGTE applies the GTE predicate on the "next_notify_time" field. +func NextNotifyTimeGTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeLT applies the LT predicate on the "next_notify_time" field. +func NextNotifyTimeLT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeLTE applies the LTE predicate on the "next_notify_time" field. +func NextNotifyTimeLTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldNextNotifyTime, v)) +} + +// NextNotifyTimeIsNil applies the IsNil predicate on the "next_notify_time" field. +func NextNotifyTimeIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldNextNotifyTime)) +} + +// NextNotifyTimeNotNil applies the NotNil predicate on the "next_notify_time" field. +func NextNotifyTimeNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldNextNotifyTime)) +} + +// LastExecuteTimeEQ applies the EQ predicate on the "last_execute_time" field. +func LastExecuteTimeEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeNEQ applies the NEQ predicate on the "last_execute_time" field. +func LastExecuteTimeNEQ(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeIn applies the In predicate on the "last_execute_time" field. +func LastExecuteTimeIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldLastExecuteTime, vs...)) +} + +// LastExecuteTimeNotIn applies the NotIn predicate on the "last_execute_time" field. +func LastExecuteTimeNotIn(vs ...time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldLastExecuteTime, vs...)) +} + +// LastExecuteTimeGT applies the GT predicate on the "last_execute_time" field. +func LastExecuteTimeGT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeGTE applies the GTE predicate on the "last_execute_time" field. +func LastExecuteTimeGTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeLT applies the LT predicate on the "last_execute_time" field. +func LastExecuteTimeLT(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeLTE applies the LTE predicate on the "last_execute_time" field. +func LastExecuteTimeLTE(v time.Time) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldLastExecuteTime, v)) +} + +// LastExecuteTimeIsNil applies the IsNil predicate on the "last_execute_time" field. +func LastExecuteTimeIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldLastExecuteTime)) +} + +// LastExecuteTimeNotNil applies the NotNil predicate on the "last_execute_time" field. +func LastExecuteTimeNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldLastExecuteTime)) +} + +// RetryCountEQ applies the EQ predicate on the "retry_count" field. +func RetryCountEQ(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldRetryCount, v)) +} + +// RetryCountNEQ applies the NEQ predicate on the "retry_count" field. +func RetryCountNEQ(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldRetryCount, v)) +} + +// RetryCountIn applies the In predicate on the "retry_count" field. +func RetryCountIn(vs ...uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldRetryCount, vs...)) +} + +// RetryCountNotIn applies the NotIn predicate on the "retry_count" field. +func RetryCountNotIn(vs ...uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldRetryCount, vs...)) +} + +// RetryCountGT applies the GT predicate on the "retry_count" field. +func RetryCountGT(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldRetryCount, v)) +} + +// RetryCountGTE applies the GTE predicate on the "retry_count" field. +func RetryCountGTE(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldRetryCount, v)) +} + +// RetryCountLT applies the LT predicate on the "retry_count" field. +func RetryCountLT(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldRetryCount, v)) +} + +// RetryCountLTE applies the LTE predicate on the "retry_count" field. +func RetryCountLTE(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldRetryCount, v)) +} + +// RetryCountIsNil applies the IsNil predicate on the "retry_count" field. +func RetryCountIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldRetryCount)) +} + +// RetryCountNotNil applies the NotNil predicate on the "retry_count" field. +func RetryCountNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldRetryCount)) +} + +// MaxRetryCountEQ applies the EQ predicate on the "max_retry_count" field. +func MaxRetryCountEQ(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldMaxRetryCount, v)) +} + +// MaxRetryCountNEQ applies the NEQ predicate on the "max_retry_count" field. +func MaxRetryCountNEQ(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldMaxRetryCount, v)) +} + +// MaxRetryCountIn applies the In predicate on the "max_retry_count" field. +func MaxRetryCountIn(vs ...uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldMaxRetryCount, vs...)) +} + +// MaxRetryCountNotIn applies the NotIn predicate on the "max_retry_count" field. +func MaxRetryCountNotIn(vs ...uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldMaxRetryCount, vs...)) +} + +// MaxRetryCountGT applies the GT predicate on the "max_retry_count" field. +func MaxRetryCountGT(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldMaxRetryCount, v)) +} + +// MaxRetryCountGTE applies the GTE predicate on the "max_retry_count" field. +func MaxRetryCountGTE(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldMaxRetryCount, v)) +} + +// MaxRetryCountLT applies the LT predicate on the "max_retry_count" field. +func MaxRetryCountLT(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldMaxRetryCount, v)) +} + +// MaxRetryCountLTE applies the LTE predicate on the "max_retry_count" field. +func MaxRetryCountLTE(v uint32) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldMaxRetryCount, v)) +} + +// MaxRetryCountIsNil applies the IsNil predicate on the "max_retry_count" field. +func MaxRetryCountIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldMaxRetryCount)) +} + +// MaxRetryCountNotNil applies the NotNil predicate on the "max_retry_count" field. +func MaxRetryCountNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldMaxRetryCount)) +} + +// NotifyURLEQ applies the EQ predicate on the "notify_url" field. +func NotifyURLEQ(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEQ(FieldNotifyURL, v)) +} + +// NotifyURLNEQ applies the NEQ predicate on the "notify_url" field. +func NotifyURLNEQ(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNEQ(FieldNotifyURL, v)) +} + +// NotifyURLIn applies the In predicate on the "notify_url" field. +func NotifyURLIn(vs ...string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIn(FieldNotifyURL, vs...)) +} + +// NotifyURLNotIn applies the NotIn predicate on the "notify_url" field. +func NotifyURLNotIn(vs ...string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotIn(FieldNotifyURL, vs...)) +} + +// NotifyURLGT applies the GT predicate on the "notify_url" field. +func NotifyURLGT(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGT(FieldNotifyURL, v)) +} + +// NotifyURLGTE applies the GTE predicate on the "notify_url" field. +func NotifyURLGTE(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldGTE(FieldNotifyURL, v)) +} + +// NotifyURLLT applies the LT predicate on the "notify_url" field. +func NotifyURLLT(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLT(FieldNotifyURL, v)) +} + +// NotifyURLLTE applies the LTE predicate on the "notify_url" field. +func NotifyURLLTE(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldLTE(FieldNotifyURL, v)) +} + +// NotifyURLContains applies the Contains predicate on the "notify_url" field. +func NotifyURLContains(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldContains(FieldNotifyURL, v)) +} + +// NotifyURLHasPrefix applies the HasPrefix predicate on the "notify_url" field. +func NotifyURLHasPrefix(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldHasPrefix(FieldNotifyURL, v)) +} + +// NotifyURLHasSuffix applies the HasSuffix predicate on the "notify_url" field. +func NotifyURLHasSuffix(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldHasSuffix(FieldNotifyURL, v)) +} + +// NotifyURLIsNil applies the IsNil predicate on the "notify_url" field. +func NotifyURLIsNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldIsNull(FieldNotifyURL)) +} + +// NotifyURLNotNil applies the NotNil predicate on the "notify_url" field. +func NotifyURLNotNil() predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldNotNull(FieldNotifyURL)) +} + +// NotifyURLEqualFold applies the EqualFold predicate on the "notify_url" field. +func NotifyURLEqualFold(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldEqualFold(FieldNotifyURL, v)) +} + +// NotifyURLContainsFold applies the ContainsFold predicate on the "notify_url" field. +func NotifyURLContainsFold(v string) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.FieldContainsFold(FieldNotifyURL, v)) +} + +// HasApp applies the HasEdge predicate on the "app" edge. +func HasApp() predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, AppTable, AppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAppWith applies the HasEdge predicate on the "app" edge with a given conditions (other predicates). +func HasAppWith(preds ...predicate.App) predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := newAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasOrder applies the HasEdge predicate on the "order" edge. +func HasOrder() predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrderWith applies the HasEdge predicate on the "order" edge with a given conditions (other predicates). +func HasOrderWith(preds ...predicate.PayOrder) predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := newOrderStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasNotifyLog applies the HasEdge predicate on the "notify_log" edge. +func HasNotifyLog() predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyLogTable, NotifyLogColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNotifyLogWith applies the HasEdge predicate on the "notify_log" edge with a given conditions (other predicates). +func HasNotifyLogWith(preds ...predicate.PayNotifyLog) predicate.PayNotifyTask { + return predicate.PayNotifyTask(func(s *sql.Selector) { + step := newNotifyLogStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayNotifyTask) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayNotifyTask) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayNotifyTask) predicate.PayNotifyTask { + return predicate.PayNotifyTask(sql.NotPredicates(p)) +} diff --git a/rpc/ent/paynotifytask_create.go b/rpc/ent/paynotifytask_create.go new file mode 100644 index 0000000..bf69a3d --- /dev/null +++ b/rpc/ent/paynotifytask_create.go @@ -0,0 +1,547 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyTaskCreate is the builder for creating a PayNotifyTask entity. +type PayNotifyTaskCreate struct { + config + mutation *PayNotifyTaskMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayNotifyTaskCreate) SetCreatedAt(v time.Time) *PayNotifyTaskCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableCreatedAt(v *time.Time) *PayNotifyTaskCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayNotifyTaskCreate) SetUpdatedAt(v time.Time) *PayNotifyTaskCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableUpdatedAt(v *time.Time) *PayNotifyTaskCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayNotifyTaskCreate) SetStatus(v uint8) *PayNotifyTaskCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableStatus(v *uint8) *PayNotifyTaskCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayNotifyTaskCreate) SetTenantID(v uint64) *PayNotifyTaskCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableTenantID(v *uint64) *PayNotifyTaskCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayNotifyTaskCreate) SetDeletedAt(v time.Time) *PayNotifyTaskCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableDeletedAt(v *time.Time) *PayNotifyTaskCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetType sets the "type" field. +func (_c *PayNotifyTaskCreate) SetType(v uint8) *PayNotifyTaskCreate { + _c.mutation.SetType(v) + return _c +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableType(v *uint8) *PayNotifyTaskCreate { + if v != nil { + _c.SetType(*v) + } + return _c +} + +// SetDataID sets the "data_id" field. +func (_c *PayNotifyTaskCreate) SetDataID(v uint64) *PayNotifyTaskCreate { + _c.mutation.SetDataID(v) + return _c +} + +// SetOrderID sets the "order_id" field. +func (_c *PayNotifyTaskCreate) SetOrderID(v uint64) *PayNotifyTaskCreate { + _c.mutation.SetOrderID(v) + return _c +} + +// SetAppID sets the "app_id" field. +func (_c *PayNotifyTaskCreate) SetAppID(v uint64) *PayNotifyTaskCreate { + _c.mutation.SetAppID(v) + return _c +} + +// SetNotifyStatus sets the "notify_status" field. +func (_c *PayNotifyTaskCreate) SetNotifyStatus(v uint8) *PayNotifyTaskCreate { + _c.mutation.SetNotifyStatus(v) + return _c +} + +// SetNextNotifyTime sets the "next_notify_time" field. +func (_c *PayNotifyTaskCreate) SetNextNotifyTime(v time.Time) *PayNotifyTaskCreate { + _c.mutation.SetNextNotifyTime(v) + return _c +} + +// SetNillableNextNotifyTime sets the "next_notify_time" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableNextNotifyTime(v *time.Time) *PayNotifyTaskCreate { + if v != nil { + _c.SetNextNotifyTime(*v) + } + return _c +} + +// SetLastExecuteTime sets the "last_execute_time" field. +func (_c *PayNotifyTaskCreate) SetLastExecuteTime(v time.Time) *PayNotifyTaskCreate { + _c.mutation.SetLastExecuteTime(v) + return _c +} + +// SetNillableLastExecuteTime sets the "last_execute_time" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableLastExecuteTime(v *time.Time) *PayNotifyTaskCreate { + if v != nil { + _c.SetLastExecuteTime(*v) + } + return _c +} + +// SetRetryCount sets the "retry_count" field. +func (_c *PayNotifyTaskCreate) SetRetryCount(v uint32) *PayNotifyTaskCreate { + _c.mutation.SetRetryCount(v) + return _c +} + +// SetNillableRetryCount sets the "retry_count" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableRetryCount(v *uint32) *PayNotifyTaskCreate { + if v != nil { + _c.SetRetryCount(*v) + } + return _c +} + +// SetMaxRetryCount sets the "max_retry_count" field. +func (_c *PayNotifyTaskCreate) SetMaxRetryCount(v uint32) *PayNotifyTaskCreate { + _c.mutation.SetMaxRetryCount(v) + return _c +} + +// SetNillableMaxRetryCount sets the "max_retry_count" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableMaxRetryCount(v *uint32) *PayNotifyTaskCreate { + if v != nil { + _c.SetMaxRetryCount(*v) + } + return _c +} + +// SetNotifyURL sets the "notify_url" field. +func (_c *PayNotifyTaskCreate) SetNotifyURL(v string) *PayNotifyTaskCreate { + _c.mutation.SetNotifyURL(v) + return _c +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_c *PayNotifyTaskCreate) SetNillableNotifyURL(v *string) *PayNotifyTaskCreate { + if v != nil { + _c.SetNotifyURL(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayNotifyTaskCreate) SetID(v uint64) *PayNotifyTaskCreate { + _c.mutation.SetID(v) + return _c +} + +// SetApp sets the "app" edge to the App entity. +func (_c *PayNotifyTaskCreate) SetApp(v *App) *PayNotifyTaskCreate { + return _c.SetAppID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_c *PayNotifyTaskCreate) SetOrder(v *PayOrder) *PayNotifyTaskCreate { + return _c.SetOrderID(v.ID) +} + +// AddNotifyLogIDs adds the "notify_log" edge to the PayNotifyLog entity by IDs. +func (_c *PayNotifyTaskCreate) AddNotifyLogIDs(ids ...uint64) *PayNotifyTaskCreate { + _c.mutation.AddNotifyLogIDs(ids...) + return _c +} + +// AddNotifyLog adds the "notify_log" edges to the PayNotifyLog entity. +func (_c *PayNotifyTaskCreate) AddNotifyLog(v ...*PayNotifyLog) *PayNotifyTaskCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddNotifyLogIDs(ids...) +} + +// Mutation returns the PayNotifyTaskMutation object of the builder. +func (_c *PayNotifyTaskCreate) Mutation() *PayNotifyTaskMutation { + return _c.mutation +} + +// Save creates the PayNotifyTask in the database. +func (_c *PayNotifyTaskCreate) Save(ctx context.Context) (*PayNotifyTask, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayNotifyTaskCreate) SaveX(ctx context.Context) *PayNotifyTask { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayNotifyTaskCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayNotifyTaskCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayNotifyTaskCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := paynotifytask.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := paynotifytask.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := paynotifytask.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := paynotifytask.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.GetType(); !ok { + v := paynotifytask.DefaultType + _c.mutation.SetType(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayNotifyTaskCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayNotifyTask.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayNotifyTask.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayNotifyTask.tenant_id"`)} + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "PayNotifyTask.type"`)} + } + if _, ok := _c.mutation.DataID(); !ok { + return &ValidationError{Name: "data_id", err: errors.New(`ent: missing required field "PayNotifyTask.data_id"`)} + } + if _, ok := _c.mutation.OrderID(); !ok { + return &ValidationError{Name: "order_id", err: errors.New(`ent: missing required field "PayNotifyTask.order_id"`)} + } + if _, ok := _c.mutation.AppID(); !ok { + return &ValidationError{Name: "app_id", err: errors.New(`ent: missing required field "PayNotifyTask.app_id"`)} + } + if _, ok := _c.mutation.NotifyStatus(); !ok { + return &ValidationError{Name: "notify_status", err: errors.New(`ent: missing required field "PayNotifyTask.notify_status"`)} + } + if len(_c.mutation.AppIDs()) == 0 { + return &ValidationError{Name: "app", err: errors.New(`ent: missing required edge "PayNotifyTask.app"`)} + } + if len(_c.mutation.OrderIDs()) == 0 { + return &ValidationError{Name: "order", err: errors.New(`ent: missing required edge "PayNotifyTask.order"`)} + } + return nil +} + +func (_c *PayNotifyTaskCreate) sqlSave(ctx context.Context) (*PayNotifyTask, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.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) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayNotifyTaskCreate) createSpec() (*PayNotifyTask, *sqlgraph.CreateSpec) { + var ( + _node = &PayNotifyTask{config: _c.config} + _spec = sqlgraph.NewCreateSpec(paynotifytask.Table, sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(paynotifytask.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(paynotifytask.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(paynotifytask.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(paynotifytask.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(paynotifytask.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(paynotifytask.FieldType, field.TypeUint8, value) + _node.Type = value + } + if value, ok := _c.mutation.DataID(); ok { + _spec.SetField(paynotifytask.FieldDataID, field.TypeUint64, value) + _node.DataID = value + } + if value, ok := _c.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifytask.FieldNotifyStatus, field.TypeUint8, value) + _node.NotifyStatus = value + } + if value, ok := _c.mutation.NextNotifyTime(); ok { + _spec.SetField(paynotifytask.FieldNextNotifyTime, field.TypeTime, value) + _node.NextNotifyTime = value + } + if value, ok := _c.mutation.LastExecuteTime(); ok { + _spec.SetField(paynotifytask.FieldLastExecuteTime, field.TypeTime, value) + _node.LastExecuteTime = value + } + if value, ok := _c.mutation.RetryCount(); ok { + _spec.SetField(paynotifytask.FieldRetryCount, field.TypeUint32, value) + _node.RetryCount = value + } + if value, ok := _c.mutation.MaxRetryCount(); ok { + _spec.SetField(paynotifytask.FieldMaxRetryCount, field.TypeUint32, value) + _node.MaxRetryCount = value + } + if value, ok := _c.mutation.NotifyURL(); ok { + _spec.SetField(paynotifytask.FieldNotifyURL, field.TypeString, value) + _node.NotifyURL = value + } + if nodes := _c.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.AppTable, + Columns: []string{paynotifytask.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.AppID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.OrderTable, + Columns: []string{paynotifytask.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.OrderID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.NotifyLogIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayNotifyTaskCreateBulk is the builder for creating many PayNotifyTask entities in bulk. +type PayNotifyTaskCreateBulk struct { + config + err error + builders []*PayNotifyTaskCreate +} + +// Save creates the PayNotifyTask entities in the database. +func (_c *PayNotifyTaskCreateBulk) Save(ctx context.Context) ([]*PayNotifyTask, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayNotifyTask, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayNotifyTaskMutation) + 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, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.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, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayNotifyTaskCreateBulk) SaveX(ctx context.Context) []*PayNotifyTask { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayNotifyTaskCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayNotifyTaskCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paynotifytask_delete.go b/rpc/ent/paynotifytask_delete.go new file mode 100644 index 0000000..bc61410 --- /dev/null +++ b/rpc/ent/paynotifytask_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyTaskDelete is the builder for deleting a PayNotifyTask entity. +type PayNotifyTaskDelete struct { + config + hooks []Hook + mutation *PayNotifyTaskMutation +} + +// Where appends a list predicates to the PayNotifyTaskDelete builder. +func (_d *PayNotifyTaskDelete) Where(ps ...predicate.PayNotifyTask) *PayNotifyTaskDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayNotifyTaskDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayNotifyTaskDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayNotifyTaskDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(paynotifytask.Table, sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// PayNotifyTaskDeleteOne is the builder for deleting a single PayNotifyTask entity. +type PayNotifyTaskDeleteOne struct { + _d *PayNotifyTaskDelete +} + +// Where appends a list predicates to the PayNotifyTaskDelete builder. +func (_d *PayNotifyTaskDeleteOne) Where(ps ...predicate.PayNotifyTask) *PayNotifyTaskDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayNotifyTaskDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{paynotifytask.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayNotifyTaskDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paynotifytask_query.go b/rpc/ent/paynotifytask_query.go new file mode 100644 index 0000000..019eed6 --- /dev/null +++ b/rpc/ent/paynotifytask_query.go @@ -0,0 +1,756 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyTaskQuery is the builder for querying PayNotifyTask entities. +type PayNotifyTaskQuery struct { + config + ctx *QueryContext + order []paynotifytask.OrderOption + inters []Interceptor + predicates []predicate.PayNotifyTask + withApp *AppQuery + withOrder *PayOrderQuery + withNotifyLog *PayNotifyLogQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayNotifyTaskQuery builder. +func (_q *PayNotifyTaskQuery) Where(ps ...predicate.PayNotifyTask) *PayNotifyTaskQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayNotifyTaskQuery) Limit(limit int) *PayNotifyTaskQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayNotifyTaskQuery) Offset(offset int) *PayNotifyTaskQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *PayNotifyTaskQuery) Unique(unique bool) *PayNotifyTaskQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayNotifyTaskQuery) Order(o ...paynotifytask.OrderOption) *PayNotifyTaskQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryApp chains the current query on the "app" edge. +func (_q *PayNotifyTaskQuery) QueryApp() *AppQuery { + query := (&AppClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, selector), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.AppTable, paynotifytask.AppColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryOrder chains the current query on the "order" edge. +func (_q *PayNotifyTaskQuery) QueryOrder() *PayOrderQuery { + query := (&PayOrderClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, selector), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.OrderTable, paynotifytask.OrderColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryNotifyLog chains the current query on the "notify_log" edge. +func (_q *PayNotifyTaskQuery) QueryNotifyLog() *PayNotifyLogQuery { + query := (&PayNotifyLogClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, selector), + sqlgraph.To(paynotifylog.Table, paynotifylog.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paynotifytask.NotifyLogTable, paynotifytask.NotifyLogColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayNotifyTask entity from the query. +// Returns a *NotFoundError when no PayNotifyTask was found. +func (_q *PayNotifyTaskQuery) First(ctx context.Context) (*PayNotifyTask, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{paynotifytask.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) FirstX(ctx context.Context) *PayNotifyTask { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayNotifyTask ID from the query. +// Returns a *NotFoundError when no PayNotifyTask ID was found. +func (_q *PayNotifyTaskQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{paynotifytask.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayNotifyTask entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayNotifyTask entity is found. +// Returns a *NotFoundError when no PayNotifyTask entities are found. +func (_q *PayNotifyTaskQuery) Only(ctx context.Context) (*PayNotifyTask, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{paynotifytask.Label} + default: + return nil, &NotSingularError{paynotifytask.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) OnlyX(ctx context.Context) *PayNotifyTask { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayNotifyTask ID in the query. +// Returns a *NotSingularError when more than one PayNotifyTask ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayNotifyTaskQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{paynotifytask.Label} + default: + err = &NotSingularError{paynotifytask.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayNotifyTasks. +func (_q *PayNotifyTaskQuery) All(ctx context.Context) ([]*PayNotifyTask, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayNotifyTask, *PayNotifyTaskQuery]() + return withInterceptors[[]*PayNotifyTask](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) AllX(ctx context.Context) []*PayNotifyTask { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayNotifyTask IDs. +func (_q *PayNotifyTaskQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(paynotifytask.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayNotifyTaskQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*PayNotifyTaskQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *PayNotifyTaskQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *PayNotifyTaskQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayNotifyTaskQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *PayNotifyTaskQuery) Clone() *PayNotifyTaskQuery { + if _q == nil { + return nil + } + return &PayNotifyTaskQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]paynotifytask.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayNotifyTask{}, _q.predicates...), + withApp: _q.withApp.Clone(), + withOrder: _q.withOrder.Clone(), + withNotifyLog: _q.withNotifyLog.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithApp tells the query-builder to eager-load the nodes that are connected to +// the "app" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayNotifyTaskQuery) WithApp(opts ...func(*AppQuery)) *PayNotifyTaskQuery { + query := (&AppClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withApp = query + return _q +} + +// WithOrder tells the query-builder to eager-load the nodes that are connected to +// the "order" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayNotifyTaskQuery) WithOrder(opts ...func(*PayOrderQuery)) *PayNotifyTaskQuery { + query := (&PayOrderClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrder = query + return _q +} + +// WithNotifyLog tells the query-builder to eager-load the nodes that are connected to +// the "notify_log" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayNotifyTaskQuery) WithNotifyLog(opts ...func(*PayNotifyLogQuery)) *PayNotifyTaskQuery { + query := (&PayNotifyLogClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withNotifyLog = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayNotifyTask.Query(). +// GroupBy(paynotifytask.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayNotifyTaskQuery) GroupBy(field string, fields ...string) *PayNotifyTaskGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayNotifyTaskGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = paynotifytask.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayNotifyTask.Query(). +// Select(paynotifytask.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayNotifyTaskQuery) Select(fields ...string) *PayNotifyTaskSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayNotifyTaskSelect{PayNotifyTaskQuery: _q} + sbuild.label = paynotifytask.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayNotifyTaskSelect configured with the given aggregations. +func (_q *PayNotifyTaskQuery) Aggregate(fns ...AggregateFunc) *PayNotifyTaskSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayNotifyTaskQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !paynotifytask.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *PayNotifyTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayNotifyTask, error) { + var ( + nodes = []*PayNotifyTask{} + _spec = _q.querySpec() + loadedTypes = [3]bool{ + _q.withApp != nil, + _q.withOrder != nil, + _q.withNotifyLog != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayNotifyTask).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayNotifyTask{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withApp; query != nil { + if err := _q.loadApp(ctx, query, nodes, nil, + func(n *PayNotifyTask, e *App) { n.Edges.App = e }); err != nil { + return nil, err + } + } + if query := _q.withOrder; query != nil { + if err := _q.loadOrder(ctx, query, nodes, nil, + func(n *PayNotifyTask, e *PayOrder) { n.Edges.Order = e }); err != nil { + return nil, err + } + } + if query := _q.withNotifyLog; query != nil { + if err := _q.loadNotifyLog(ctx, query, nodes, + func(n *PayNotifyTask) { n.Edges.NotifyLog = []*PayNotifyLog{} }, + func(n *PayNotifyTask, e *PayNotifyLog) { n.Edges.NotifyLog = append(n.Edges.NotifyLog, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayNotifyTaskQuery) loadApp(ctx context.Context, query *AppQuery, nodes []*PayNotifyTask, init func(*PayNotifyTask), assign func(*PayNotifyTask, *App)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayNotifyTask) + for i := range nodes { + fk := nodes[i].AppID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(app.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "app_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PayNotifyTaskQuery) loadOrder(ctx context.Context, query *PayOrderQuery, nodes []*PayNotifyTask, init func(*PayNotifyTask), assign func(*PayNotifyTask, *PayOrder)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayNotifyTask) + for i := range nodes { + fk := nodes[i].OrderID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(payorder.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "order_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PayNotifyTaskQuery) loadNotifyLog(ctx context.Context, query *PayNotifyLogQuery, nodes []*PayNotifyTask, init func(*PayNotifyTask), assign func(*PayNotifyTask, *PayNotifyLog)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayNotifyTask) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(paynotifylog.FieldTaskID) + } + query.Where(predicate.PayNotifyLog(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(paynotifytask.NotifyLogColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.TaskID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "task_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *PayNotifyTaskQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *PayNotifyTaskQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(paynotifytask.Table, paynotifytask.Columns, sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, paynotifytask.FieldID) + for i := range fields { + if fields[i] != paynotifytask.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withApp != nil { + _spec.Node.AddColumnOnce(paynotifytask.FieldAppID) + } + if _q.withOrder != nil { + _spec.Node.AddColumnOnce(paynotifytask.FieldOrderID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *PayNotifyTaskQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(paynotifytask.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = paynotifytask.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// PayNotifyTaskGroupBy is the group-by builder for PayNotifyTask entities. +type PayNotifyTaskGroupBy struct { + selector + build *PayNotifyTaskQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayNotifyTaskGroupBy) Aggregate(fns ...AggregateFunc) *PayNotifyTaskGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayNotifyTaskGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayNotifyTaskQuery, *PayNotifyTaskGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayNotifyTaskGroupBy) sqlScan(ctx context.Context, root *PayNotifyTaskQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PayNotifyTaskSelect is the builder for selecting fields of PayNotifyTask entities. +type PayNotifyTaskSelect struct { + *PayNotifyTaskQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayNotifyTaskSelect) Aggregate(fns ...AggregateFunc) *PayNotifyTaskSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayNotifyTaskSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayNotifyTaskQuery, *PayNotifyTaskSelect](ctx, _s.PayNotifyTaskQuery, _s, _s.inters, v) +} + +func (_s *PayNotifyTaskSelect) sqlScan(ctx context.Context, root *PayNotifyTaskQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/paynotifytask_update.go b/rpc/ent/paynotifytask_update.go new file mode 100644 index 0000000..1c60cbf --- /dev/null +++ b/rpc/ent/paynotifytask_update.go @@ -0,0 +1,1207 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayNotifyTaskUpdate is the builder for updating PayNotifyTask entities. +type PayNotifyTaskUpdate struct { + config + hooks []Hook + mutation *PayNotifyTaskMutation +} + +// Where appends a list predicates to the PayNotifyTaskUpdate builder. +func (_u *PayNotifyTaskUpdate) Where(ps ...predicate.PayNotifyTask) *PayNotifyTaskUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayNotifyTaskUpdate) SetUpdatedAt(v time.Time) *PayNotifyTaskUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayNotifyTaskUpdate) SetStatus(v uint8) *PayNotifyTaskUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableStatus(v *uint8) *PayNotifyTaskUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayNotifyTaskUpdate) AddStatus(v int8) *PayNotifyTaskUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayNotifyTaskUpdate) ClearStatus() *PayNotifyTaskUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayNotifyTaskUpdate) SetDeletedAt(v time.Time) *PayNotifyTaskUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableDeletedAt(v *time.Time) *PayNotifyTaskUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayNotifyTaskUpdate) ClearDeletedAt() *PayNotifyTaskUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetType sets the "type" field. +func (_u *PayNotifyTaskUpdate) SetType(v uint8) *PayNotifyTaskUpdate { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableType(v *uint8) *PayNotifyTaskUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// AddType adds value to the "type" field. +func (_u *PayNotifyTaskUpdate) AddType(v int8) *PayNotifyTaskUpdate { + _u.mutation.AddType(v) + return _u +} + +// SetDataID sets the "data_id" field. +func (_u *PayNotifyTaskUpdate) SetDataID(v uint64) *PayNotifyTaskUpdate { + _u.mutation.ResetDataID() + _u.mutation.SetDataID(v) + return _u +} + +// SetNillableDataID sets the "data_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableDataID(v *uint64) *PayNotifyTaskUpdate { + if v != nil { + _u.SetDataID(*v) + } + return _u +} + +// AddDataID adds value to the "data_id" field. +func (_u *PayNotifyTaskUpdate) AddDataID(v int64) *PayNotifyTaskUpdate { + _u.mutation.AddDataID(v) + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayNotifyTaskUpdate) SetOrderID(v uint64) *PayNotifyTaskUpdate { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableOrderID(v *uint64) *PayNotifyTaskUpdate { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetAppID sets the "app_id" field. +func (_u *PayNotifyTaskUpdate) SetAppID(v uint64) *PayNotifyTaskUpdate { + _u.mutation.SetAppID(v) + return _u +} + +// SetNillableAppID sets the "app_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableAppID(v *uint64) *PayNotifyTaskUpdate { + if v != nil { + _u.SetAppID(*v) + } + return _u +} + +// SetNotifyStatus sets the "notify_status" field. +func (_u *PayNotifyTaskUpdate) SetNotifyStatus(v uint8) *PayNotifyTaskUpdate { + _u.mutation.ResetNotifyStatus() + _u.mutation.SetNotifyStatus(v) + return _u +} + +// SetNillableNotifyStatus sets the "notify_status" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableNotifyStatus(v *uint8) *PayNotifyTaskUpdate { + if v != nil { + _u.SetNotifyStatus(*v) + } + return _u +} + +// AddNotifyStatus adds value to the "notify_status" field. +func (_u *PayNotifyTaskUpdate) AddNotifyStatus(v int8) *PayNotifyTaskUpdate { + _u.mutation.AddNotifyStatus(v) + return _u +} + +// SetNextNotifyTime sets the "next_notify_time" field. +func (_u *PayNotifyTaskUpdate) SetNextNotifyTime(v time.Time) *PayNotifyTaskUpdate { + _u.mutation.SetNextNotifyTime(v) + return _u +} + +// SetNillableNextNotifyTime sets the "next_notify_time" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableNextNotifyTime(v *time.Time) *PayNotifyTaskUpdate { + if v != nil { + _u.SetNextNotifyTime(*v) + } + return _u +} + +// ClearNextNotifyTime clears the value of the "next_notify_time" field. +func (_u *PayNotifyTaskUpdate) ClearNextNotifyTime() *PayNotifyTaskUpdate { + _u.mutation.ClearNextNotifyTime() + return _u +} + +// SetLastExecuteTime sets the "last_execute_time" field. +func (_u *PayNotifyTaskUpdate) SetLastExecuteTime(v time.Time) *PayNotifyTaskUpdate { + _u.mutation.SetLastExecuteTime(v) + return _u +} + +// SetNillableLastExecuteTime sets the "last_execute_time" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableLastExecuteTime(v *time.Time) *PayNotifyTaskUpdate { + if v != nil { + _u.SetLastExecuteTime(*v) + } + return _u +} + +// ClearLastExecuteTime clears the value of the "last_execute_time" field. +func (_u *PayNotifyTaskUpdate) ClearLastExecuteTime() *PayNotifyTaskUpdate { + _u.mutation.ClearLastExecuteTime() + return _u +} + +// SetRetryCount sets the "retry_count" field. +func (_u *PayNotifyTaskUpdate) SetRetryCount(v uint32) *PayNotifyTaskUpdate { + _u.mutation.ResetRetryCount() + _u.mutation.SetRetryCount(v) + return _u +} + +// SetNillableRetryCount sets the "retry_count" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableRetryCount(v *uint32) *PayNotifyTaskUpdate { + if v != nil { + _u.SetRetryCount(*v) + } + return _u +} + +// AddRetryCount adds value to the "retry_count" field. +func (_u *PayNotifyTaskUpdate) AddRetryCount(v int32) *PayNotifyTaskUpdate { + _u.mutation.AddRetryCount(v) + return _u +} + +// ClearRetryCount clears the value of the "retry_count" field. +func (_u *PayNotifyTaskUpdate) ClearRetryCount() *PayNotifyTaskUpdate { + _u.mutation.ClearRetryCount() + return _u +} + +// SetMaxRetryCount sets the "max_retry_count" field. +func (_u *PayNotifyTaskUpdate) SetMaxRetryCount(v uint32) *PayNotifyTaskUpdate { + _u.mutation.ResetMaxRetryCount() + _u.mutation.SetMaxRetryCount(v) + return _u +} + +// SetNillableMaxRetryCount sets the "max_retry_count" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableMaxRetryCount(v *uint32) *PayNotifyTaskUpdate { + if v != nil { + _u.SetMaxRetryCount(*v) + } + return _u +} + +// AddMaxRetryCount adds value to the "max_retry_count" field. +func (_u *PayNotifyTaskUpdate) AddMaxRetryCount(v int32) *PayNotifyTaskUpdate { + _u.mutation.AddMaxRetryCount(v) + return _u +} + +// ClearMaxRetryCount clears the value of the "max_retry_count" field. +func (_u *PayNotifyTaskUpdate) ClearMaxRetryCount() *PayNotifyTaskUpdate { + _u.mutation.ClearMaxRetryCount() + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayNotifyTaskUpdate) SetNotifyURL(v string) *PayNotifyTaskUpdate { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayNotifyTaskUpdate) SetNillableNotifyURL(v *string) *PayNotifyTaskUpdate { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (_u *PayNotifyTaskUpdate) ClearNotifyURL() *PayNotifyTaskUpdate { + _u.mutation.ClearNotifyURL() + return _u +} + +// SetApp sets the "app" edge to the App entity. +func (_u *PayNotifyTaskUpdate) SetApp(v *App) *PayNotifyTaskUpdate { + return _u.SetAppID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayNotifyTaskUpdate) SetOrder(v *PayOrder) *PayNotifyTaskUpdate { + return _u.SetOrderID(v.ID) +} + +// AddNotifyLogIDs adds the "notify_log" edge to the PayNotifyLog entity by IDs. +func (_u *PayNotifyTaskUpdate) AddNotifyLogIDs(ids ...uint64) *PayNotifyTaskUpdate { + _u.mutation.AddNotifyLogIDs(ids...) + return _u +} + +// AddNotifyLog adds the "notify_log" edges to the PayNotifyLog entity. +func (_u *PayNotifyTaskUpdate) AddNotifyLog(v ...*PayNotifyLog) *PayNotifyTaskUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyLogIDs(ids...) +} + +// Mutation returns the PayNotifyTaskMutation object of the builder. +func (_u *PayNotifyTaskUpdate) Mutation() *PayNotifyTaskMutation { + return _u.mutation +} + +// ClearApp clears the "app" edge to the App entity. +func (_u *PayNotifyTaskUpdate) ClearApp() *PayNotifyTaskUpdate { + _u.mutation.ClearApp() + return _u +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayNotifyTaskUpdate) ClearOrder() *PayNotifyTaskUpdate { + _u.mutation.ClearOrder() + return _u +} + +// ClearNotifyLog clears all "notify_log" edges to the PayNotifyLog entity. +func (_u *PayNotifyTaskUpdate) ClearNotifyLog() *PayNotifyTaskUpdate { + _u.mutation.ClearNotifyLog() + return _u +} + +// RemoveNotifyLogIDs removes the "notify_log" edge to PayNotifyLog entities by IDs. +func (_u *PayNotifyTaskUpdate) RemoveNotifyLogIDs(ids ...uint64) *PayNotifyTaskUpdate { + _u.mutation.RemoveNotifyLogIDs(ids...) + return _u +} + +// RemoveNotifyLog removes "notify_log" edges to PayNotifyLog entities. +func (_u *PayNotifyTaskUpdate) RemoveNotifyLog(v ...*PayNotifyLog) *PayNotifyTaskUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyLogIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayNotifyTaskUpdate) 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 *PayNotifyTaskUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayNotifyTaskUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayNotifyTaskUpdate) 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 *PayNotifyTaskUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paynotifytask.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayNotifyTaskUpdate) check() error { + if _u.mutation.AppCleared() && len(_u.mutation.AppIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyTask.app"`) + } + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyTask.order"`) + } + return nil +} + +func (_u *PayNotifyTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paynotifytask.Table, paynotifytask.Columns, sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(paynotifytask.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paynotifytask.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paynotifytask.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paynotifytask.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paynotifytask.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paynotifytask.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(paynotifytask.FieldType, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedType(); ok { + _spec.AddField(paynotifytask.FieldType, field.TypeUint8, value) + } + if value, ok := _u.mutation.DataID(); ok { + _spec.SetField(paynotifytask.FieldDataID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedDataID(); ok { + _spec.AddField(paynotifytask.FieldDataID, field.TypeUint64, value) + } + if value, ok := _u.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifytask.FieldNotifyStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedNotifyStatus(); ok { + _spec.AddField(paynotifytask.FieldNotifyStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.NextNotifyTime(); ok { + _spec.SetField(paynotifytask.FieldNextNotifyTime, field.TypeTime, value) + } + if _u.mutation.NextNotifyTimeCleared() { + _spec.ClearField(paynotifytask.FieldNextNotifyTime, field.TypeTime) + } + if value, ok := _u.mutation.LastExecuteTime(); ok { + _spec.SetField(paynotifytask.FieldLastExecuteTime, field.TypeTime, value) + } + if _u.mutation.LastExecuteTimeCleared() { + _spec.ClearField(paynotifytask.FieldLastExecuteTime, field.TypeTime) + } + if value, ok := _u.mutation.RetryCount(); ok { + _spec.SetField(paynotifytask.FieldRetryCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedRetryCount(); ok { + _spec.AddField(paynotifytask.FieldRetryCount, field.TypeUint32, value) + } + if _u.mutation.RetryCountCleared() { + _spec.ClearField(paynotifytask.FieldRetryCount, field.TypeUint32) + } + if value, ok := _u.mutation.MaxRetryCount(); ok { + _spec.SetField(paynotifytask.FieldMaxRetryCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedMaxRetryCount(); ok { + _spec.AddField(paynotifytask.FieldMaxRetryCount, field.TypeUint32, value) + } + if _u.mutation.MaxRetryCountCleared() { + _spec.ClearField(paynotifytask.FieldMaxRetryCount, field.TypeUint32) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(paynotifytask.FieldNotifyURL, field.TypeString, value) + } + if _u.mutation.NotifyURLCleared() { + _spec.ClearField(paynotifytask.FieldNotifyURL, field.TypeString) + } + if _u.mutation.AppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.AppTable, + Columns: []string{paynotifytask.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.AppTable, + Columns: []string{paynotifytask.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.OrderTable, + Columns: []string{paynotifytask.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.OrderTable, + Columns: []string{paynotifytask.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyLogCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyLogIDs(); len(nodes) > 0 && !_u.mutation.NotifyLogCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyLogIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{paynotifytask.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayNotifyTaskUpdateOne is the builder for updating a single PayNotifyTask entity. +type PayNotifyTaskUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayNotifyTaskMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayNotifyTaskUpdateOne) SetUpdatedAt(v time.Time) *PayNotifyTaskUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayNotifyTaskUpdateOne) SetStatus(v uint8) *PayNotifyTaskUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableStatus(v *uint8) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayNotifyTaskUpdateOne) AddStatus(v int8) *PayNotifyTaskUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayNotifyTaskUpdateOne) ClearStatus() *PayNotifyTaskUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayNotifyTaskUpdateOne) SetDeletedAt(v time.Time) *PayNotifyTaskUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableDeletedAt(v *time.Time) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayNotifyTaskUpdateOne) ClearDeletedAt() *PayNotifyTaskUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetType sets the "type" field. +func (_u *PayNotifyTaskUpdateOne) SetType(v uint8) *PayNotifyTaskUpdateOne { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableType(v *uint8) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// AddType adds value to the "type" field. +func (_u *PayNotifyTaskUpdateOne) AddType(v int8) *PayNotifyTaskUpdateOne { + _u.mutation.AddType(v) + return _u +} + +// SetDataID sets the "data_id" field. +func (_u *PayNotifyTaskUpdateOne) SetDataID(v uint64) *PayNotifyTaskUpdateOne { + _u.mutation.ResetDataID() + _u.mutation.SetDataID(v) + return _u +} + +// SetNillableDataID sets the "data_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableDataID(v *uint64) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetDataID(*v) + } + return _u +} + +// AddDataID adds value to the "data_id" field. +func (_u *PayNotifyTaskUpdateOne) AddDataID(v int64) *PayNotifyTaskUpdateOne { + _u.mutation.AddDataID(v) + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayNotifyTaskUpdateOne) SetOrderID(v uint64) *PayNotifyTaskUpdateOne { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableOrderID(v *uint64) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetAppID sets the "app_id" field. +func (_u *PayNotifyTaskUpdateOne) SetAppID(v uint64) *PayNotifyTaskUpdateOne { + _u.mutation.SetAppID(v) + return _u +} + +// SetNillableAppID sets the "app_id" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableAppID(v *uint64) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetAppID(*v) + } + return _u +} + +// SetNotifyStatus sets the "notify_status" field. +func (_u *PayNotifyTaskUpdateOne) SetNotifyStatus(v uint8) *PayNotifyTaskUpdateOne { + _u.mutation.ResetNotifyStatus() + _u.mutation.SetNotifyStatus(v) + return _u +} + +// SetNillableNotifyStatus sets the "notify_status" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableNotifyStatus(v *uint8) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetNotifyStatus(*v) + } + return _u +} + +// AddNotifyStatus adds value to the "notify_status" field. +func (_u *PayNotifyTaskUpdateOne) AddNotifyStatus(v int8) *PayNotifyTaskUpdateOne { + _u.mutation.AddNotifyStatus(v) + return _u +} + +// SetNextNotifyTime sets the "next_notify_time" field. +func (_u *PayNotifyTaskUpdateOne) SetNextNotifyTime(v time.Time) *PayNotifyTaskUpdateOne { + _u.mutation.SetNextNotifyTime(v) + return _u +} + +// SetNillableNextNotifyTime sets the "next_notify_time" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableNextNotifyTime(v *time.Time) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetNextNotifyTime(*v) + } + return _u +} + +// ClearNextNotifyTime clears the value of the "next_notify_time" field. +func (_u *PayNotifyTaskUpdateOne) ClearNextNotifyTime() *PayNotifyTaskUpdateOne { + _u.mutation.ClearNextNotifyTime() + return _u +} + +// SetLastExecuteTime sets the "last_execute_time" field. +func (_u *PayNotifyTaskUpdateOne) SetLastExecuteTime(v time.Time) *PayNotifyTaskUpdateOne { + _u.mutation.SetLastExecuteTime(v) + return _u +} + +// SetNillableLastExecuteTime sets the "last_execute_time" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableLastExecuteTime(v *time.Time) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetLastExecuteTime(*v) + } + return _u +} + +// ClearLastExecuteTime clears the value of the "last_execute_time" field. +func (_u *PayNotifyTaskUpdateOne) ClearLastExecuteTime() *PayNotifyTaskUpdateOne { + _u.mutation.ClearLastExecuteTime() + return _u +} + +// SetRetryCount sets the "retry_count" field. +func (_u *PayNotifyTaskUpdateOne) SetRetryCount(v uint32) *PayNotifyTaskUpdateOne { + _u.mutation.ResetRetryCount() + _u.mutation.SetRetryCount(v) + return _u +} + +// SetNillableRetryCount sets the "retry_count" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableRetryCount(v *uint32) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetRetryCount(*v) + } + return _u +} + +// AddRetryCount adds value to the "retry_count" field. +func (_u *PayNotifyTaskUpdateOne) AddRetryCount(v int32) *PayNotifyTaskUpdateOne { + _u.mutation.AddRetryCount(v) + return _u +} + +// ClearRetryCount clears the value of the "retry_count" field. +func (_u *PayNotifyTaskUpdateOne) ClearRetryCount() *PayNotifyTaskUpdateOne { + _u.mutation.ClearRetryCount() + return _u +} + +// SetMaxRetryCount sets the "max_retry_count" field. +func (_u *PayNotifyTaskUpdateOne) SetMaxRetryCount(v uint32) *PayNotifyTaskUpdateOne { + _u.mutation.ResetMaxRetryCount() + _u.mutation.SetMaxRetryCount(v) + return _u +} + +// SetNillableMaxRetryCount sets the "max_retry_count" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableMaxRetryCount(v *uint32) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetMaxRetryCount(*v) + } + return _u +} + +// AddMaxRetryCount adds value to the "max_retry_count" field. +func (_u *PayNotifyTaskUpdateOne) AddMaxRetryCount(v int32) *PayNotifyTaskUpdateOne { + _u.mutation.AddMaxRetryCount(v) + return _u +} + +// ClearMaxRetryCount clears the value of the "max_retry_count" field. +func (_u *PayNotifyTaskUpdateOne) ClearMaxRetryCount() *PayNotifyTaskUpdateOne { + _u.mutation.ClearMaxRetryCount() + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayNotifyTaskUpdateOne) SetNotifyURL(v string) *PayNotifyTaskUpdateOne { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayNotifyTaskUpdateOne) SetNillableNotifyURL(v *string) *PayNotifyTaskUpdateOne { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (_u *PayNotifyTaskUpdateOne) ClearNotifyURL() *PayNotifyTaskUpdateOne { + _u.mutation.ClearNotifyURL() + return _u +} + +// SetApp sets the "app" edge to the App entity. +func (_u *PayNotifyTaskUpdateOne) SetApp(v *App) *PayNotifyTaskUpdateOne { + return _u.SetAppID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayNotifyTaskUpdateOne) SetOrder(v *PayOrder) *PayNotifyTaskUpdateOne { + return _u.SetOrderID(v.ID) +} + +// AddNotifyLogIDs adds the "notify_log" edge to the PayNotifyLog entity by IDs. +func (_u *PayNotifyTaskUpdateOne) AddNotifyLogIDs(ids ...uint64) *PayNotifyTaskUpdateOne { + _u.mutation.AddNotifyLogIDs(ids...) + return _u +} + +// AddNotifyLog adds the "notify_log" edges to the PayNotifyLog entity. +func (_u *PayNotifyTaskUpdateOne) AddNotifyLog(v ...*PayNotifyLog) *PayNotifyTaskUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyLogIDs(ids...) +} + +// Mutation returns the PayNotifyTaskMutation object of the builder. +func (_u *PayNotifyTaskUpdateOne) Mutation() *PayNotifyTaskMutation { + return _u.mutation +} + +// ClearApp clears the "app" edge to the App entity. +func (_u *PayNotifyTaskUpdateOne) ClearApp() *PayNotifyTaskUpdateOne { + _u.mutation.ClearApp() + return _u +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayNotifyTaskUpdateOne) ClearOrder() *PayNotifyTaskUpdateOne { + _u.mutation.ClearOrder() + return _u +} + +// ClearNotifyLog clears all "notify_log" edges to the PayNotifyLog entity. +func (_u *PayNotifyTaskUpdateOne) ClearNotifyLog() *PayNotifyTaskUpdateOne { + _u.mutation.ClearNotifyLog() + return _u +} + +// RemoveNotifyLogIDs removes the "notify_log" edge to PayNotifyLog entities by IDs. +func (_u *PayNotifyTaskUpdateOne) RemoveNotifyLogIDs(ids ...uint64) *PayNotifyTaskUpdateOne { + _u.mutation.RemoveNotifyLogIDs(ids...) + return _u +} + +// RemoveNotifyLog removes "notify_log" edges to PayNotifyLog entities. +func (_u *PayNotifyTaskUpdateOne) RemoveNotifyLog(v ...*PayNotifyLog) *PayNotifyTaskUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyLogIDs(ids...) +} + +// Where appends a list predicates to the PayNotifyTaskUpdate builder. +func (_u *PayNotifyTaskUpdateOne) Where(ps ...predicate.PayNotifyTask) *PayNotifyTaskUpdateOne { + _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 *PayNotifyTaskUpdateOne) Select(field string, fields ...string) *PayNotifyTaskUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayNotifyTask entity. +func (_u *PayNotifyTaskUpdateOne) Save(ctx context.Context) (*PayNotifyTask, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayNotifyTaskUpdateOne) SaveX(ctx context.Context) *PayNotifyTask { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayNotifyTaskUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayNotifyTaskUpdateOne) 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 *PayNotifyTaskUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paynotifytask.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayNotifyTaskUpdateOne) check() error { + if _u.mutation.AppCleared() && len(_u.mutation.AppIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyTask.app"`) + } + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayNotifyTask.order"`) + } + return nil +} + +func (_u *PayNotifyTaskUpdateOne) sqlSave(ctx context.Context) (_node *PayNotifyTask, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paynotifytask.Table, paynotifytask.Columns, sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayNotifyTask.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, paynotifytask.FieldID) + for _, f := range fields { + if !paynotifytask.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != paynotifytask.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.UpdatedAt(); ok { + _spec.SetField(paynotifytask.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paynotifytask.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paynotifytask.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paynotifytask.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paynotifytask.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paynotifytask.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(paynotifytask.FieldType, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedType(); ok { + _spec.AddField(paynotifytask.FieldType, field.TypeUint8, value) + } + if value, ok := _u.mutation.DataID(); ok { + _spec.SetField(paynotifytask.FieldDataID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedDataID(); ok { + _spec.AddField(paynotifytask.FieldDataID, field.TypeUint64, value) + } + if value, ok := _u.mutation.NotifyStatus(); ok { + _spec.SetField(paynotifytask.FieldNotifyStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedNotifyStatus(); ok { + _spec.AddField(paynotifytask.FieldNotifyStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.NextNotifyTime(); ok { + _spec.SetField(paynotifytask.FieldNextNotifyTime, field.TypeTime, value) + } + if _u.mutation.NextNotifyTimeCleared() { + _spec.ClearField(paynotifytask.FieldNextNotifyTime, field.TypeTime) + } + if value, ok := _u.mutation.LastExecuteTime(); ok { + _spec.SetField(paynotifytask.FieldLastExecuteTime, field.TypeTime, value) + } + if _u.mutation.LastExecuteTimeCleared() { + _spec.ClearField(paynotifytask.FieldLastExecuteTime, field.TypeTime) + } + if value, ok := _u.mutation.RetryCount(); ok { + _spec.SetField(paynotifytask.FieldRetryCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedRetryCount(); ok { + _spec.AddField(paynotifytask.FieldRetryCount, field.TypeUint32, value) + } + if _u.mutation.RetryCountCleared() { + _spec.ClearField(paynotifytask.FieldRetryCount, field.TypeUint32) + } + if value, ok := _u.mutation.MaxRetryCount(); ok { + _spec.SetField(paynotifytask.FieldMaxRetryCount, field.TypeUint32, value) + } + if value, ok := _u.mutation.AddedMaxRetryCount(); ok { + _spec.AddField(paynotifytask.FieldMaxRetryCount, field.TypeUint32, value) + } + if _u.mutation.MaxRetryCountCleared() { + _spec.ClearField(paynotifytask.FieldMaxRetryCount, field.TypeUint32) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(paynotifytask.FieldNotifyURL, field.TypeString, value) + } + if _u.mutation.NotifyURLCleared() { + _spec.ClearField(paynotifytask.FieldNotifyURL, field.TypeString) + } + if _u.mutation.AppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.AppTable, + Columns: []string{paynotifytask.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.AppTable, + Columns: []string{paynotifytask.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.OrderTable, + Columns: []string{paynotifytask.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paynotifytask.OrderTable, + Columns: []string{paynotifytask.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyLogCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyLogIDs(); len(nodes) > 0 && !_u.mutation.NotifyLogCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyLogIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paynotifytask.NotifyLogTable, + Columns: []string{paynotifytask.NotifyLogColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifylog.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayNotifyTask{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{paynotifytask.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/payrefund.go b/rpc/ent/payrefund.go new file mode 100644 index 0000000..68ed60e --- /dev/null +++ b/rpc/ent/payrefund.go @@ -0,0 +1,363 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payrefund" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayRefund Table | 退款订单表 +type PayRefund struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 支付渠道 ID + ChannelID uint64 `json:"channel_id,omitempty"` + // 用户 ID + UserID uint64 `json:"user_id,omitempty"` + // 订单 ID + OrderID uint64 `json:"order_id,omitempty"` + // 回调地址 + NotifyURL string `json:"notify_url,omitempty"` + // 退款状态 + RefundStatus uint8 `json:"refund_status,omitempty"` + // 退款金额 + RefundAmount uint64 `json:"refund_amount,omitempty"` + // 支付金额 + PayAmount uint64 `json:"pay_amount,omitempty"` + // 退款单号 + RefundNo string `json:"refund_no,omitempty"` + // 退款原因 + RefundReason string `json:"refund_reason,omitempty"` + // 用户 IP + UserIP string `json:"user_ip,omitempty"` + // 渠道退款单号 + ChannelRefundNo string `json:"channel_refund_no,omitempty"` + // 退款成功时间 + RefundTime time.Time `json:"refund_time,omitempty"` + // 渠道错误码 + ChannelErrorCode string `json:"channel_error_code,omitempty"` + // 渠道错误信息 + ChannelErrorMsg string `json:"channel_error_msg,omitempty"` + // 渠道回调数据 + ChannelNotifyData string `json:"channel_notify_data,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayRefundQuery when eager-loading is set. + Edges PayRefundEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayRefundEdges holds the relations/edges for other nodes in the graph. +type PayRefundEdges struct { + // Order holds the value of the order edge. + Order *PayOrder `json:"order,omitempty"` + // Channel holds the value of the channel edge. + Channel *PayChannel `json:"channel,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// OrderOrErr returns the Order value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayRefundEdges) OrderOrErr() (*PayOrder, error) { + if e.Order != nil { + return e.Order, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: payorder.Label} + } + return nil, &NotLoadedError{edge: "order"} +} + +// ChannelOrErr returns the Channel value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayRefundEdges) ChannelOrErr() (*PayChannel, error) { + if e.Channel != nil { + return e.Channel, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: paychannel.Label} + } + return nil, &NotLoadedError{edge: "channel"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayRefund) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case payrefund.FieldID, payrefund.FieldStatus, payrefund.FieldTenantID, payrefund.FieldChannelID, payrefund.FieldUserID, payrefund.FieldOrderID, payrefund.FieldRefundStatus, payrefund.FieldRefundAmount, payrefund.FieldPayAmount: + values[i] = new(sql.NullInt64) + case payrefund.FieldNotifyURL, payrefund.FieldRefundNo, payrefund.FieldRefundReason, payrefund.FieldUserIP, payrefund.FieldChannelRefundNo, payrefund.FieldChannelErrorCode, payrefund.FieldChannelErrorMsg, payrefund.FieldChannelNotifyData: + values[i] = new(sql.NullString) + case payrefund.FieldCreatedAt, payrefund.FieldUpdatedAt, payrefund.FieldDeletedAt, payrefund.FieldRefundTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PayRefund fields. +func (_m *PayRefund) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case payrefund.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case payrefund.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + case payrefund.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Time + } + case payrefund.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case payrefund.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case payrefund.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case payrefund.FieldChannelID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field channel_id", values[i]) + } else if value.Valid { + _m.ChannelID = uint64(value.Int64) + } + case payrefund.FieldUserID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + _m.UserID = uint64(value.Int64) + } + case payrefund.FieldOrderID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field order_id", values[i]) + } else if value.Valid { + _m.OrderID = uint64(value.Int64) + } + case payrefund.FieldNotifyURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notify_url", values[i]) + } else if value.Valid { + _m.NotifyURL = value.String + } + case payrefund.FieldRefundStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field refund_status", values[i]) + } else if value.Valid { + _m.RefundStatus = uint8(value.Int64) + } + case payrefund.FieldRefundAmount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field refund_amount", values[i]) + } else if value.Valid { + _m.RefundAmount = uint64(value.Int64) + } + case payrefund.FieldPayAmount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field pay_amount", values[i]) + } else if value.Valid { + _m.PayAmount = uint64(value.Int64) + } + case payrefund.FieldRefundNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field refund_no", values[i]) + } else if value.Valid { + _m.RefundNo = value.String + } + case payrefund.FieldRefundReason: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field refund_reason", values[i]) + } else if value.Valid { + _m.RefundReason = value.String + } + case payrefund.FieldUserIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_ip", values[i]) + } else if value.Valid { + _m.UserIP = value.String + } + case payrefund.FieldChannelRefundNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_refund_no", values[i]) + } else if value.Valid { + _m.ChannelRefundNo = value.String + } + case payrefund.FieldRefundTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field refund_time", values[i]) + } else if value.Valid { + _m.RefundTime = value.Time + } + case payrefund.FieldChannelErrorCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_error_code", values[i]) + } else if value.Valid { + _m.ChannelErrorCode = value.String + } + case payrefund.FieldChannelErrorMsg: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_error_msg", values[i]) + } else if value.Valid { + _m.ChannelErrorMsg = value.String + } + case payrefund.FieldChannelNotifyData: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_notify_data", values[i]) + } else if value.Valid { + _m.ChannelNotifyData = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayRefund. +// This includes values selected through modifiers, order, etc. +func (_m *PayRefund) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryOrder queries the "order" edge of the PayRefund entity. +func (_m *PayRefund) QueryOrder() *PayOrderQuery { + return NewPayRefundClient(_m.config).QueryOrder(_m) +} + +// QueryChannel queries the "channel" edge of the PayRefund entity. +func (_m *PayRefund) QueryChannel() *PayChannelQuery { + return NewPayRefundClient(_m.config).QueryChannel(_m) +} + +// Update returns a builder for updating this PayRefund. +// Note that you need to call PayRefund.Unwrap() before calling this method if this PayRefund +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayRefund) Update() *PayRefundUpdateOne { + return NewPayRefundClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayRefund entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *PayRefund) Unwrap() *PayRefund { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayRefund is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayRefund) String() string { + var builder strings.Builder + builder.WriteString("PayRefund(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("created_at=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("channel_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ChannelID)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("order_id=") + builder.WriteString(fmt.Sprintf("%v", _m.OrderID)) + builder.WriteString(", ") + builder.WriteString("notify_url=") + builder.WriteString(_m.NotifyURL) + builder.WriteString(", ") + builder.WriteString("refund_status=") + builder.WriteString(fmt.Sprintf("%v", _m.RefundStatus)) + builder.WriteString(", ") + builder.WriteString("refund_amount=") + builder.WriteString(fmt.Sprintf("%v", _m.RefundAmount)) + builder.WriteString(", ") + builder.WriteString("pay_amount=") + builder.WriteString(fmt.Sprintf("%v", _m.PayAmount)) + builder.WriteString(", ") + builder.WriteString("refund_no=") + builder.WriteString(_m.RefundNo) + builder.WriteString(", ") + builder.WriteString("refund_reason=") + builder.WriteString(_m.RefundReason) + builder.WriteString(", ") + builder.WriteString("user_ip=") + builder.WriteString(_m.UserIP) + builder.WriteString(", ") + builder.WriteString("channel_refund_no=") + builder.WriteString(_m.ChannelRefundNo) + builder.WriteString(", ") + builder.WriteString("refund_time=") + builder.WriteString(_m.RefundTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("channel_error_code=") + builder.WriteString(_m.ChannelErrorCode) + builder.WriteString(", ") + builder.WriteString("channel_error_msg=") + builder.WriteString(_m.ChannelErrorMsg) + builder.WriteString(", ") + builder.WriteString("channel_notify_data=") + builder.WriteString(_m.ChannelNotifyData) + builder.WriteByte(')') + return builder.String() +} + +// PayRefunds is a parsable slice of PayRefund. +type PayRefunds []*PayRefund diff --git a/rpc/ent/payrefund/payrefund.go b/rpc/ent/payrefund/payrefund.go new file mode 100644 index 0000000..806a030 --- /dev/null +++ b/rpc/ent/payrefund/payrefund.go @@ -0,0 +1,267 @@ +// Code generated by ent, DO NOT EDIT. + +package payrefund + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the payrefund type in the database. + Label = "pay_refund" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldChannelID holds the string denoting the channel_id field in the database. + FieldChannelID = "channel_id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldOrderID holds the string denoting the order_id field in the database. + FieldOrderID = "order_id" + // FieldNotifyURL holds the string denoting the notify_url field in the database. + FieldNotifyURL = "notify_url" + // FieldRefundStatus holds the string denoting the refund_status field in the database. + FieldRefundStatus = "refund_status" + // FieldRefundAmount holds the string denoting the refund_amount field in the database. + FieldRefundAmount = "refund_amount" + // FieldPayAmount holds the string denoting the pay_amount field in the database. + FieldPayAmount = "pay_amount" + // FieldRefundNo holds the string denoting the refund_no field in the database. + FieldRefundNo = "refund_no" + // FieldRefundReason holds the string denoting the refund_reason field in the database. + FieldRefundReason = "refund_reason" + // FieldUserIP holds the string denoting the user_ip field in the database. + FieldUserIP = "user_ip" + // FieldChannelRefundNo holds the string denoting the channel_refund_no field in the database. + FieldChannelRefundNo = "channel_refund_no" + // FieldRefundTime holds the string denoting the refund_time field in the database. + FieldRefundTime = "refund_time" + // FieldChannelErrorCode holds the string denoting the channel_error_code field in the database. + FieldChannelErrorCode = "channel_error_code" + // FieldChannelErrorMsg holds the string denoting the channel_error_msg field in the database. + FieldChannelErrorMsg = "channel_error_msg" + // FieldChannelNotifyData holds the string denoting the channel_notify_data field in the database. + FieldChannelNotifyData = "channel_notify_data" + // EdgeOrder holds the string denoting the order edge name in mutations. + EdgeOrder = "order" + // EdgeChannel holds the string denoting the channel edge name in mutations. + EdgeChannel = "channel" + // Table holds the table name of the payrefund in the database. + Table = "pay_refund" + // OrderTable is the table that holds the order relation/edge. + OrderTable = "pay_refund" + // OrderInverseTable is the table name for the PayOrder entity. + // It exists in this package in order to avoid circular dependency with the "payorder" package. + OrderInverseTable = "pay_order" + // OrderColumn is the table column denoting the order relation/edge. + OrderColumn = "order_id" + // ChannelTable is the table that holds the channel relation/edge. + ChannelTable = "pay_refund" + // ChannelInverseTable is the table name for the PayChannel entity. + // It exists in this package in order to avoid circular dependency with the "paychannel" package. + ChannelInverseTable = "pay_channel" + // ChannelColumn is the table column denoting the channel relation/edge. + ChannelColumn = "channel_id" +) + +// Columns holds all SQL columns for payrefund fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldChannelID, + FieldUserID, + FieldOrderID, + FieldNotifyURL, + FieldRefundStatus, + FieldRefundAmount, + FieldPayAmount, + FieldRefundNo, + FieldRefundReason, + FieldUserIP, + FieldChannelRefundNo, + FieldRefundTime, + FieldChannelErrorCode, + FieldChannelErrorMsg, + FieldChannelNotifyData, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time + // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. + UpdateDefaultUpdatedAt func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultRefundStatus holds the default value on creation for the "refund_status" field. + DefaultRefundStatus uint8 + // DefaultRefundAmount holds the default value on creation for the "refund_amount" field. + DefaultRefundAmount uint64 + // DefaultPayAmount holds the default value on creation for the "pay_amount" field. + DefaultPayAmount uint64 +) + +// OrderOption defines the ordering options for the PayRefund queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByChannelID orders the results by the channel_id field. +func ByChannelID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByOrderID orders the results by the order_id field. +func ByOrderID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderID, opts...).ToFunc() +} + +// ByNotifyURL orders the results by the notify_url field. +func ByNotifyURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyURL, opts...).ToFunc() +} + +// ByRefundStatus orders the results by the refund_status field. +func ByRefundStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundStatus, opts...).ToFunc() +} + +// ByRefundAmount orders the results by the refund_amount field. +func ByRefundAmount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundAmount, opts...).ToFunc() +} + +// ByPayAmount orders the results by the pay_amount field. +func ByPayAmount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPayAmount, opts...).ToFunc() +} + +// ByRefundNo orders the results by the refund_no field. +func ByRefundNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundNo, opts...).ToFunc() +} + +// ByRefundReason orders the results by the refund_reason field. +func ByRefundReason(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundReason, opts...).ToFunc() +} + +// ByUserIP orders the results by the user_ip field. +func ByUserIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserIP, opts...).ToFunc() +} + +// ByChannelRefundNo orders the results by the channel_refund_no field. +func ByChannelRefundNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelRefundNo, opts...).ToFunc() +} + +// ByRefundTime orders the results by the refund_time field. +func ByRefundTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundTime, opts...).ToFunc() +} + +// ByChannelErrorCode orders the results by the channel_error_code field. +func ByChannelErrorCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelErrorCode, opts...).ToFunc() +} + +// ByChannelErrorMsg orders the results by the channel_error_msg field. +func ByChannelErrorMsg(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelErrorMsg, opts...).ToFunc() +} + +// ByChannelNotifyData orders the results by the channel_notify_data field. +func ByChannelNotifyData(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelNotifyData, opts...).ToFunc() +} + +// ByOrderField orders the results by order field. +func ByOrderField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrderStep(), sql.OrderByField(field, opts...)) + } +} + +// ByChannelField orders the results by channel field. +func ByChannelField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChannelStep(), sql.OrderByField(field, opts...)) + } +} +func newOrderStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrderInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) +} +func newChannelStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ChannelInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) +} diff --git a/rpc/ent/payrefund/where.go b/rpc/ent/payrefund/where.go new file mode 100644 index 0000000..8d3d68b --- /dev/null +++ b/rpc/ent/payrefund/where.go @@ -0,0 +1,1247 @@ +// Code generated by ent, DO NOT EDIT. + +package payrefund + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldCreatedAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldDeletedAt, v)) +} + +// ChannelID applies equality check predicate on the "channel_id" field. It's identical to ChannelIDEQ. +func ChannelID(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelID, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUserID, v)) +} + +// OrderID applies equality check predicate on the "order_id" field. It's identical to OrderIDEQ. +func OrderID(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldOrderID, v)) +} + +// NotifyURL applies equality check predicate on the "notify_url" field. It's identical to NotifyURLEQ. +func NotifyURL(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldNotifyURL, v)) +} + +// RefundStatus applies equality check predicate on the "refund_status" field. It's identical to RefundStatusEQ. +func RefundStatus(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundStatus, v)) +} + +// RefundAmount applies equality check predicate on the "refund_amount" field. It's identical to RefundAmountEQ. +func RefundAmount(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundAmount, v)) +} + +// PayAmount applies equality check predicate on the "pay_amount" field. It's identical to PayAmountEQ. +func PayAmount(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldPayAmount, v)) +} + +// RefundNo applies equality check predicate on the "refund_no" field. It's identical to RefundNoEQ. +func RefundNo(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundNo, v)) +} + +// RefundReason applies equality check predicate on the "refund_reason" field. It's identical to RefundReasonEQ. +func RefundReason(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundReason, v)) +} + +// UserIP applies equality check predicate on the "user_ip" field. It's identical to UserIPEQ. +func UserIP(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUserIP, v)) +} + +// ChannelRefundNo applies equality check predicate on the "channel_refund_no" field. It's identical to ChannelRefundNoEQ. +func ChannelRefundNo(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelRefundNo, v)) +} + +// RefundTime applies equality check predicate on the "refund_time" field. It's identical to RefundTimeEQ. +func RefundTime(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundTime, v)) +} + +// ChannelErrorCode applies equality check predicate on the "channel_error_code" field. It's identical to ChannelErrorCodeEQ. +func ChannelErrorCode(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorMsg applies equality check predicate on the "channel_error_msg" field. It's identical to ChannelErrorMsgEQ. +func ChannelErrorMsg(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelErrorMsg, v)) +} + +// ChannelNotifyData applies equality check predicate on the "channel_notify_data" field. It's identical to ChannelNotifyDataEQ. +func ChannelNotifyData(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelNotifyData, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldDeletedAt)) +} + +// ChannelIDEQ applies the EQ predicate on the "channel_id" field. +func ChannelIDEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelID, v)) +} + +// ChannelIDNEQ applies the NEQ predicate on the "channel_id" field. +func ChannelIDNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldChannelID, v)) +} + +// ChannelIDIn applies the In predicate on the "channel_id" field. +func ChannelIDIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldChannelID, vs...)) +} + +// ChannelIDNotIn applies the NotIn predicate on the "channel_id" field. +func ChannelIDNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldChannelID, vs...)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldUserID, v)) +} + +// OrderIDEQ applies the EQ predicate on the "order_id" field. +func OrderIDEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldOrderID, v)) +} + +// OrderIDNEQ applies the NEQ predicate on the "order_id" field. +func OrderIDNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldOrderID, v)) +} + +// OrderIDIn applies the In predicate on the "order_id" field. +func OrderIDIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldOrderID, vs...)) +} + +// OrderIDNotIn applies the NotIn predicate on the "order_id" field. +func OrderIDNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldOrderID, vs...)) +} + +// NotifyURLEQ applies the EQ predicate on the "notify_url" field. +func NotifyURLEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldNotifyURL, v)) +} + +// NotifyURLNEQ applies the NEQ predicate on the "notify_url" field. +func NotifyURLNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldNotifyURL, v)) +} + +// NotifyURLIn applies the In predicate on the "notify_url" field. +func NotifyURLIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldNotifyURL, vs...)) +} + +// NotifyURLNotIn applies the NotIn predicate on the "notify_url" field. +func NotifyURLNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldNotifyURL, vs...)) +} + +// NotifyURLGT applies the GT predicate on the "notify_url" field. +func NotifyURLGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldNotifyURL, v)) +} + +// NotifyURLGTE applies the GTE predicate on the "notify_url" field. +func NotifyURLGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldNotifyURL, v)) +} + +// NotifyURLLT applies the LT predicate on the "notify_url" field. +func NotifyURLLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldNotifyURL, v)) +} + +// NotifyURLLTE applies the LTE predicate on the "notify_url" field. +func NotifyURLLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldNotifyURL, v)) +} + +// NotifyURLContains applies the Contains predicate on the "notify_url" field. +func NotifyURLContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldNotifyURL, v)) +} + +// NotifyURLHasPrefix applies the HasPrefix predicate on the "notify_url" field. +func NotifyURLHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldNotifyURL, v)) +} + +// NotifyURLHasSuffix applies the HasSuffix predicate on the "notify_url" field. +func NotifyURLHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldNotifyURL, v)) +} + +// NotifyURLIsNil applies the IsNil predicate on the "notify_url" field. +func NotifyURLIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldNotifyURL)) +} + +// NotifyURLNotNil applies the NotNil predicate on the "notify_url" field. +func NotifyURLNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldNotifyURL)) +} + +// NotifyURLEqualFold applies the EqualFold predicate on the "notify_url" field. +func NotifyURLEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldNotifyURL, v)) +} + +// NotifyURLContainsFold applies the ContainsFold predicate on the "notify_url" field. +func NotifyURLContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldNotifyURL, v)) +} + +// RefundStatusEQ applies the EQ predicate on the "refund_status" field. +func RefundStatusEQ(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundStatus, v)) +} + +// RefundStatusNEQ applies the NEQ predicate on the "refund_status" field. +func RefundStatusNEQ(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldRefundStatus, v)) +} + +// RefundStatusIn applies the In predicate on the "refund_status" field. +func RefundStatusIn(vs ...uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldRefundStatus, vs...)) +} + +// RefundStatusNotIn applies the NotIn predicate on the "refund_status" field. +func RefundStatusNotIn(vs ...uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldRefundStatus, vs...)) +} + +// RefundStatusGT applies the GT predicate on the "refund_status" field. +func RefundStatusGT(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldRefundStatus, v)) +} + +// RefundStatusGTE applies the GTE predicate on the "refund_status" field. +func RefundStatusGTE(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldRefundStatus, v)) +} + +// RefundStatusLT applies the LT predicate on the "refund_status" field. +func RefundStatusLT(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldRefundStatus, v)) +} + +// RefundStatusLTE applies the LTE predicate on the "refund_status" field. +func RefundStatusLTE(v uint8) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldRefundStatus, v)) +} + +// RefundAmountEQ applies the EQ predicate on the "refund_amount" field. +func RefundAmountEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundAmount, v)) +} + +// RefundAmountNEQ applies the NEQ predicate on the "refund_amount" field. +func RefundAmountNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldRefundAmount, v)) +} + +// RefundAmountIn applies the In predicate on the "refund_amount" field. +func RefundAmountIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldRefundAmount, vs...)) +} + +// RefundAmountNotIn applies the NotIn predicate on the "refund_amount" field. +func RefundAmountNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldRefundAmount, vs...)) +} + +// RefundAmountGT applies the GT predicate on the "refund_amount" field. +func RefundAmountGT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldRefundAmount, v)) +} + +// RefundAmountGTE applies the GTE predicate on the "refund_amount" field. +func RefundAmountGTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldRefundAmount, v)) +} + +// RefundAmountLT applies the LT predicate on the "refund_amount" field. +func RefundAmountLT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldRefundAmount, v)) +} + +// RefundAmountLTE applies the LTE predicate on the "refund_amount" field. +func RefundAmountLTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldRefundAmount, v)) +} + +// PayAmountEQ applies the EQ predicate on the "pay_amount" field. +func PayAmountEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldPayAmount, v)) +} + +// PayAmountNEQ applies the NEQ predicate on the "pay_amount" field. +func PayAmountNEQ(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldPayAmount, v)) +} + +// PayAmountIn applies the In predicate on the "pay_amount" field. +func PayAmountIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldPayAmount, vs...)) +} + +// PayAmountNotIn applies the NotIn predicate on the "pay_amount" field. +func PayAmountNotIn(vs ...uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldPayAmount, vs...)) +} + +// PayAmountGT applies the GT predicate on the "pay_amount" field. +func PayAmountGT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldPayAmount, v)) +} + +// PayAmountGTE applies the GTE predicate on the "pay_amount" field. +func PayAmountGTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldPayAmount, v)) +} + +// PayAmountLT applies the LT predicate on the "pay_amount" field. +func PayAmountLT(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldPayAmount, v)) +} + +// PayAmountLTE applies the LTE predicate on the "pay_amount" field. +func PayAmountLTE(v uint64) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldPayAmount, v)) +} + +// RefundNoEQ applies the EQ predicate on the "refund_no" field. +func RefundNoEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundNo, v)) +} + +// RefundNoNEQ applies the NEQ predicate on the "refund_no" field. +func RefundNoNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldRefundNo, v)) +} + +// RefundNoIn applies the In predicate on the "refund_no" field. +func RefundNoIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldRefundNo, vs...)) +} + +// RefundNoNotIn applies the NotIn predicate on the "refund_no" field. +func RefundNoNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldRefundNo, vs...)) +} + +// RefundNoGT applies the GT predicate on the "refund_no" field. +func RefundNoGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldRefundNo, v)) +} + +// RefundNoGTE applies the GTE predicate on the "refund_no" field. +func RefundNoGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldRefundNo, v)) +} + +// RefundNoLT applies the LT predicate on the "refund_no" field. +func RefundNoLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldRefundNo, v)) +} + +// RefundNoLTE applies the LTE predicate on the "refund_no" field. +func RefundNoLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldRefundNo, v)) +} + +// RefundNoContains applies the Contains predicate on the "refund_no" field. +func RefundNoContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldRefundNo, v)) +} + +// RefundNoHasPrefix applies the HasPrefix predicate on the "refund_no" field. +func RefundNoHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldRefundNo, v)) +} + +// RefundNoHasSuffix applies the HasSuffix predicate on the "refund_no" field. +func RefundNoHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldRefundNo, v)) +} + +// RefundNoEqualFold applies the EqualFold predicate on the "refund_no" field. +func RefundNoEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldRefundNo, v)) +} + +// RefundNoContainsFold applies the ContainsFold predicate on the "refund_no" field. +func RefundNoContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldRefundNo, v)) +} + +// RefundReasonEQ applies the EQ predicate on the "refund_reason" field. +func RefundReasonEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundReason, v)) +} + +// RefundReasonNEQ applies the NEQ predicate on the "refund_reason" field. +func RefundReasonNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldRefundReason, v)) +} + +// RefundReasonIn applies the In predicate on the "refund_reason" field. +func RefundReasonIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldRefundReason, vs...)) +} + +// RefundReasonNotIn applies the NotIn predicate on the "refund_reason" field. +func RefundReasonNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldRefundReason, vs...)) +} + +// RefundReasonGT applies the GT predicate on the "refund_reason" field. +func RefundReasonGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldRefundReason, v)) +} + +// RefundReasonGTE applies the GTE predicate on the "refund_reason" field. +func RefundReasonGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldRefundReason, v)) +} + +// RefundReasonLT applies the LT predicate on the "refund_reason" field. +func RefundReasonLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldRefundReason, v)) +} + +// RefundReasonLTE applies the LTE predicate on the "refund_reason" field. +func RefundReasonLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldRefundReason, v)) +} + +// RefundReasonContains applies the Contains predicate on the "refund_reason" field. +func RefundReasonContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldRefundReason, v)) +} + +// RefundReasonHasPrefix applies the HasPrefix predicate on the "refund_reason" field. +func RefundReasonHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldRefundReason, v)) +} + +// RefundReasonHasSuffix applies the HasSuffix predicate on the "refund_reason" field. +func RefundReasonHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldRefundReason, v)) +} + +// RefundReasonEqualFold applies the EqualFold predicate on the "refund_reason" field. +func RefundReasonEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldRefundReason, v)) +} + +// RefundReasonContainsFold applies the ContainsFold predicate on the "refund_reason" field. +func RefundReasonContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldRefundReason, v)) +} + +// UserIPEQ applies the EQ predicate on the "user_ip" field. +func UserIPEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldUserIP, v)) +} + +// UserIPNEQ applies the NEQ predicate on the "user_ip" field. +func UserIPNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldUserIP, v)) +} + +// UserIPIn applies the In predicate on the "user_ip" field. +func UserIPIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldUserIP, vs...)) +} + +// UserIPNotIn applies the NotIn predicate on the "user_ip" field. +func UserIPNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldUserIP, vs...)) +} + +// UserIPGT applies the GT predicate on the "user_ip" field. +func UserIPGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldUserIP, v)) +} + +// UserIPGTE applies the GTE predicate on the "user_ip" field. +func UserIPGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldUserIP, v)) +} + +// UserIPLT applies the LT predicate on the "user_ip" field. +func UserIPLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldUserIP, v)) +} + +// UserIPLTE applies the LTE predicate on the "user_ip" field. +func UserIPLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldUserIP, v)) +} + +// UserIPContains applies the Contains predicate on the "user_ip" field. +func UserIPContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldUserIP, v)) +} + +// UserIPHasPrefix applies the HasPrefix predicate on the "user_ip" field. +func UserIPHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldUserIP, v)) +} + +// UserIPHasSuffix applies the HasSuffix predicate on the "user_ip" field. +func UserIPHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldUserIP, v)) +} + +// UserIPIsNil applies the IsNil predicate on the "user_ip" field. +func UserIPIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldUserIP)) +} + +// UserIPNotNil applies the NotNil predicate on the "user_ip" field. +func UserIPNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldUserIP)) +} + +// UserIPEqualFold applies the EqualFold predicate on the "user_ip" field. +func UserIPEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldUserIP, v)) +} + +// UserIPContainsFold applies the ContainsFold predicate on the "user_ip" field. +func UserIPContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldUserIP, v)) +} + +// ChannelRefundNoEQ applies the EQ predicate on the "channel_refund_no" field. +func ChannelRefundNoEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoNEQ applies the NEQ predicate on the "channel_refund_no" field. +func ChannelRefundNoNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoIn applies the In predicate on the "channel_refund_no" field. +func ChannelRefundNoIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldChannelRefundNo, vs...)) +} + +// ChannelRefundNoNotIn applies the NotIn predicate on the "channel_refund_no" field. +func ChannelRefundNoNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldChannelRefundNo, vs...)) +} + +// ChannelRefundNoGT applies the GT predicate on the "channel_refund_no" field. +func ChannelRefundNoGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoGTE applies the GTE predicate on the "channel_refund_no" field. +func ChannelRefundNoGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoLT applies the LT predicate on the "channel_refund_no" field. +func ChannelRefundNoLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoLTE applies the LTE predicate on the "channel_refund_no" field. +func ChannelRefundNoLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoContains applies the Contains predicate on the "channel_refund_no" field. +func ChannelRefundNoContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoHasPrefix applies the HasPrefix predicate on the "channel_refund_no" field. +func ChannelRefundNoHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoHasSuffix applies the HasSuffix predicate on the "channel_refund_no" field. +func ChannelRefundNoHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoEqualFold applies the EqualFold predicate on the "channel_refund_no" field. +func ChannelRefundNoEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldChannelRefundNo, v)) +} + +// ChannelRefundNoContainsFold applies the ContainsFold predicate on the "channel_refund_no" field. +func ChannelRefundNoContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldChannelRefundNo, v)) +} + +// RefundTimeEQ applies the EQ predicate on the "refund_time" field. +func RefundTimeEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldRefundTime, v)) +} + +// RefundTimeNEQ applies the NEQ predicate on the "refund_time" field. +func RefundTimeNEQ(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldRefundTime, v)) +} + +// RefundTimeIn applies the In predicate on the "refund_time" field. +func RefundTimeIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldRefundTime, vs...)) +} + +// RefundTimeNotIn applies the NotIn predicate on the "refund_time" field. +func RefundTimeNotIn(vs ...time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldRefundTime, vs...)) +} + +// RefundTimeGT applies the GT predicate on the "refund_time" field. +func RefundTimeGT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldRefundTime, v)) +} + +// RefundTimeGTE applies the GTE predicate on the "refund_time" field. +func RefundTimeGTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldRefundTime, v)) +} + +// RefundTimeLT applies the LT predicate on the "refund_time" field. +func RefundTimeLT(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldRefundTime, v)) +} + +// RefundTimeLTE applies the LTE predicate on the "refund_time" field. +func RefundTimeLTE(v time.Time) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldRefundTime, v)) +} + +// ChannelErrorCodeEQ applies the EQ predicate on the "channel_error_code" field. +func ChannelErrorCodeEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeNEQ applies the NEQ predicate on the "channel_error_code" field. +func ChannelErrorCodeNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeIn applies the In predicate on the "channel_error_code" field. +func ChannelErrorCodeIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldChannelErrorCode, vs...)) +} + +// ChannelErrorCodeNotIn applies the NotIn predicate on the "channel_error_code" field. +func ChannelErrorCodeNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldChannelErrorCode, vs...)) +} + +// ChannelErrorCodeGT applies the GT predicate on the "channel_error_code" field. +func ChannelErrorCodeGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeGTE applies the GTE predicate on the "channel_error_code" field. +func ChannelErrorCodeGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeLT applies the LT predicate on the "channel_error_code" field. +func ChannelErrorCodeLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeLTE applies the LTE predicate on the "channel_error_code" field. +func ChannelErrorCodeLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeContains applies the Contains predicate on the "channel_error_code" field. +func ChannelErrorCodeContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeHasPrefix applies the HasPrefix predicate on the "channel_error_code" field. +func ChannelErrorCodeHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeHasSuffix applies the HasSuffix predicate on the "channel_error_code" field. +func ChannelErrorCodeHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeIsNil applies the IsNil predicate on the "channel_error_code" field. +func ChannelErrorCodeIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldChannelErrorCode)) +} + +// ChannelErrorCodeNotNil applies the NotNil predicate on the "channel_error_code" field. +func ChannelErrorCodeNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldChannelErrorCode)) +} + +// ChannelErrorCodeEqualFold applies the EqualFold predicate on the "channel_error_code" field. +func ChannelErrorCodeEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeContainsFold applies the ContainsFold predicate on the "channel_error_code" field. +func ChannelErrorCodeContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldChannelErrorCode, v)) +} + +// ChannelErrorMsgEQ applies the EQ predicate on the "channel_error_msg" field. +func ChannelErrorMsgEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgNEQ applies the NEQ predicate on the "channel_error_msg" field. +func ChannelErrorMsgNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgIn applies the In predicate on the "channel_error_msg" field. +func ChannelErrorMsgIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldChannelErrorMsg, vs...)) +} + +// ChannelErrorMsgNotIn applies the NotIn predicate on the "channel_error_msg" field. +func ChannelErrorMsgNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldChannelErrorMsg, vs...)) +} + +// ChannelErrorMsgGT applies the GT predicate on the "channel_error_msg" field. +func ChannelErrorMsgGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgGTE applies the GTE predicate on the "channel_error_msg" field. +func ChannelErrorMsgGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgLT applies the LT predicate on the "channel_error_msg" field. +func ChannelErrorMsgLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgLTE applies the LTE predicate on the "channel_error_msg" field. +func ChannelErrorMsgLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgContains applies the Contains predicate on the "channel_error_msg" field. +func ChannelErrorMsgContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgHasPrefix applies the HasPrefix predicate on the "channel_error_msg" field. +func ChannelErrorMsgHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgHasSuffix applies the HasSuffix predicate on the "channel_error_msg" field. +func ChannelErrorMsgHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgIsNil applies the IsNil predicate on the "channel_error_msg" field. +func ChannelErrorMsgIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldChannelErrorMsg)) +} + +// ChannelErrorMsgNotNil applies the NotNil predicate on the "channel_error_msg" field. +func ChannelErrorMsgNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldChannelErrorMsg)) +} + +// ChannelErrorMsgEqualFold applies the EqualFold predicate on the "channel_error_msg" field. +func ChannelErrorMsgEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgContainsFold applies the ContainsFold predicate on the "channel_error_msg" field. +func ChannelErrorMsgContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldChannelErrorMsg, v)) +} + +// ChannelNotifyDataEQ applies the EQ predicate on the "channel_notify_data" field. +func ChannelNotifyDataEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEQ(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataNEQ applies the NEQ predicate on the "channel_notify_data" field. +func ChannelNotifyDataNEQ(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNEQ(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataIn applies the In predicate on the "channel_notify_data" field. +func ChannelNotifyDataIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldIn(FieldChannelNotifyData, vs...)) +} + +// ChannelNotifyDataNotIn applies the NotIn predicate on the "channel_notify_data" field. +func ChannelNotifyDataNotIn(vs ...string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotIn(FieldChannelNotifyData, vs...)) +} + +// ChannelNotifyDataGT applies the GT predicate on the "channel_notify_data" field. +func ChannelNotifyDataGT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGT(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataGTE applies the GTE predicate on the "channel_notify_data" field. +func ChannelNotifyDataGTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldGTE(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataLT applies the LT predicate on the "channel_notify_data" field. +func ChannelNotifyDataLT(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLT(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataLTE applies the LTE predicate on the "channel_notify_data" field. +func ChannelNotifyDataLTE(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldLTE(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataContains applies the Contains predicate on the "channel_notify_data" field. +func ChannelNotifyDataContains(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContains(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataHasPrefix applies the HasPrefix predicate on the "channel_notify_data" field. +func ChannelNotifyDataHasPrefix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasPrefix(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataHasSuffix applies the HasSuffix predicate on the "channel_notify_data" field. +func ChannelNotifyDataHasSuffix(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldHasSuffix(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataIsNil applies the IsNil predicate on the "channel_notify_data" field. +func ChannelNotifyDataIsNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldIsNull(FieldChannelNotifyData)) +} + +// ChannelNotifyDataNotNil applies the NotNil predicate on the "channel_notify_data" field. +func ChannelNotifyDataNotNil() predicate.PayRefund { + return predicate.PayRefund(sql.FieldNotNull(FieldChannelNotifyData)) +} + +// ChannelNotifyDataEqualFold applies the EqualFold predicate on the "channel_notify_data" field. +func ChannelNotifyDataEqualFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldEqualFold(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataContainsFold applies the ContainsFold predicate on the "channel_notify_data" field. +func ChannelNotifyDataContainsFold(v string) predicate.PayRefund { + return predicate.PayRefund(sql.FieldContainsFold(FieldChannelNotifyData, v)) +} + +// HasOrder applies the HasEdge predicate on the "order" edge. +func HasOrder() predicate.PayRefund { + return predicate.PayRefund(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrderWith applies the HasEdge predicate on the "order" edge with a given conditions (other predicates). +func HasOrderWith(preds ...predicate.PayOrder) predicate.PayRefund { + return predicate.PayRefund(func(s *sql.Selector) { + step := newOrderStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasChannel applies the HasEdge predicate on the "channel" edge. +func HasChannel() predicate.PayRefund { + return predicate.PayRefund(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChannelWith applies the HasEdge predicate on the "channel" edge with a given conditions (other predicates). +func HasChannelWith(preds ...predicate.PayChannel) predicate.PayRefund { + return predicate.PayRefund(func(s *sql.Selector) { + step := newChannelStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayRefund) predicate.PayRefund { + return predicate.PayRefund(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayRefund) predicate.PayRefund { + return predicate.PayRefund(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayRefund) predicate.PayRefund { + return predicate.PayRefund(sql.NotPredicates(p)) +} diff --git a/rpc/ent/payrefund_create.go b/rpc/ent/payrefund_create.go new file mode 100644 index 0000000..2c54791 --- /dev/null +++ b/rpc/ent/payrefund_create.go @@ -0,0 +1,604 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payrefund" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayRefundCreate is the builder for creating a PayRefund entity. +type PayRefundCreate struct { + config + mutation *PayRefundMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayRefundCreate) SetCreatedAt(v time.Time) *PayRefundCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableCreatedAt(v *time.Time) *PayRefundCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayRefundCreate) SetUpdatedAt(v time.Time) *PayRefundCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableUpdatedAt(v *time.Time) *PayRefundCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayRefundCreate) SetStatus(v uint8) *PayRefundCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableStatus(v *uint8) *PayRefundCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayRefundCreate) SetTenantID(v uint64) *PayRefundCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableTenantID(v *uint64) *PayRefundCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayRefundCreate) SetDeletedAt(v time.Time) *PayRefundCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableDeletedAt(v *time.Time) *PayRefundCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetChannelID sets the "channel_id" field. +func (_c *PayRefundCreate) SetChannelID(v uint64) *PayRefundCreate { + _c.mutation.SetChannelID(v) + return _c +} + +// SetUserID sets the "user_id" field. +func (_c *PayRefundCreate) SetUserID(v uint64) *PayRefundCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetOrderID sets the "order_id" field. +func (_c *PayRefundCreate) SetOrderID(v uint64) *PayRefundCreate { + _c.mutation.SetOrderID(v) + return _c +} + +// SetNotifyURL sets the "notify_url" field. +func (_c *PayRefundCreate) SetNotifyURL(v string) *PayRefundCreate { + _c.mutation.SetNotifyURL(v) + return _c +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableNotifyURL(v *string) *PayRefundCreate { + if v != nil { + _c.SetNotifyURL(*v) + } + return _c +} + +// SetRefundStatus sets the "refund_status" field. +func (_c *PayRefundCreate) SetRefundStatus(v uint8) *PayRefundCreate { + _c.mutation.SetRefundStatus(v) + return _c +} + +// SetNillableRefundStatus sets the "refund_status" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableRefundStatus(v *uint8) *PayRefundCreate { + if v != nil { + _c.SetRefundStatus(*v) + } + return _c +} + +// SetRefundAmount sets the "refund_amount" field. +func (_c *PayRefundCreate) SetRefundAmount(v uint64) *PayRefundCreate { + _c.mutation.SetRefundAmount(v) + return _c +} + +// SetNillableRefundAmount sets the "refund_amount" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableRefundAmount(v *uint64) *PayRefundCreate { + if v != nil { + _c.SetRefundAmount(*v) + } + return _c +} + +// SetPayAmount sets the "pay_amount" field. +func (_c *PayRefundCreate) SetPayAmount(v uint64) *PayRefundCreate { + _c.mutation.SetPayAmount(v) + return _c +} + +// SetNillablePayAmount sets the "pay_amount" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillablePayAmount(v *uint64) *PayRefundCreate { + if v != nil { + _c.SetPayAmount(*v) + } + return _c +} + +// SetRefundNo sets the "refund_no" field. +func (_c *PayRefundCreate) SetRefundNo(v string) *PayRefundCreate { + _c.mutation.SetRefundNo(v) + return _c +} + +// SetRefundReason sets the "refund_reason" field. +func (_c *PayRefundCreate) SetRefundReason(v string) *PayRefundCreate { + _c.mutation.SetRefundReason(v) + return _c +} + +// SetUserIP sets the "user_ip" field. +func (_c *PayRefundCreate) SetUserIP(v string) *PayRefundCreate { + _c.mutation.SetUserIP(v) + return _c +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableUserIP(v *string) *PayRefundCreate { + if v != nil { + _c.SetUserIP(*v) + } + return _c +} + +// SetChannelRefundNo sets the "channel_refund_no" field. +func (_c *PayRefundCreate) SetChannelRefundNo(v string) *PayRefundCreate { + _c.mutation.SetChannelRefundNo(v) + return _c +} + +// SetRefundTime sets the "refund_time" field. +func (_c *PayRefundCreate) SetRefundTime(v time.Time) *PayRefundCreate { + _c.mutation.SetRefundTime(v) + return _c +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_c *PayRefundCreate) SetChannelErrorCode(v string) *PayRefundCreate { + _c.mutation.SetChannelErrorCode(v) + return _c +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableChannelErrorCode(v *string) *PayRefundCreate { + if v != nil { + _c.SetChannelErrorCode(*v) + } + return _c +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_c *PayRefundCreate) SetChannelErrorMsg(v string) *PayRefundCreate { + _c.mutation.SetChannelErrorMsg(v) + return _c +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableChannelErrorMsg(v *string) *PayRefundCreate { + if v != nil { + _c.SetChannelErrorMsg(*v) + } + return _c +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_c *PayRefundCreate) SetChannelNotifyData(v string) *PayRefundCreate { + _c.mutation.SetChannelNotifyData(v) + return _c +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_c *PayRefundCreate) SetNillableChannelNotifyData(v *string) *PayRefundCreate { + if v != nil { + _c.SetChannelNotifyData(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayRefundCreate) SetID(v uint64) *PayRefundCreate { + _c.mutation.SetID(v) + return _c +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_c *PayRefundCreate) SetOrder(v *PayOrder) *PayRefundCreate { + return _c.SetOrderID(v.ID) +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_c *PayRefundCreate) SetChannel(v *PayChannel) *PayRefundCreate { + return _c.SetChannelID(v.ID) +} + +// Mutation returns the PayRefundMutation object of the builder. +func (_c *PayRefundCreate) Mutation() *PayRefundMutation { + return _c.mutation +} + +// Save creates the PayRefund in the database. +func (_c *PayRefundCreate) Save(ctx context.Context) (*PayRefund, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayRefundCreate) SaveX(ctx context.Context) *PayRefund { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayRefundCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayRefundCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayRefundCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := payrefund.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := payrefund.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := payrefund.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := payrefund.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.RefundStatus(); !ok { + v := payrefund.DefaultRefundStatus + _c.mutation.SetRefundStatus(v) + } + if _, ok := _c.mutation.RefundAmount(); !ok { + v := payrefund.DefaultRefundAmount + _c.mutation.SetRefundAmount(v) + } + if _, ok := _c.mutation.PayAmount(); !ok { + v := payrefund.DefaultPayAmount + _c.mutation.SetPayAmount(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayRefundCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayRefund.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayRefund.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayRefund.tenant_id"`)} + } + if _, ok := _c.mutation.ChannelID(); !ok { + return &ValidationError{Name: "channel_id", err: errors.New(`ent: missing required field "PayRefund.channel_id"`)} + } + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "PayRefund.user_id"`)} + } + if _, ok := _c.mutation.OrderID(); !ok { + return &ValidationError{Name: "order_id", err: errors.New(`ent: missing required field "PayRefund.order_id"`)} + } + if _, ok := _c.mutation.RefundStatus(); !ok { + return &ValidationError{Name: "refund_status", err: errors.New(`ent: missing required field "PayRefund.refund_status"`)} + } + if _, ok := _c.mutation.RefundAmount(); !ok { + return &ValidationError{Name: "refund_amount", err: errors.New(`ent: missing required field "PayRefund.refund_amount"`)} + } + if _, ok := _c.mutation.PayAmount(); !ok { + return &ValidationError{Name: "pay_amount", err: errors.New(`ent: missing required field "PayRefund.pay_amount"`)} + } + if _, ok := _c.mutation.RefundNo(); !ok { + return &ValidationError{Name: "refund_no", err: errors.New(`ent: missing required field "PayRefund.refund_no"`)} + } + if _, ok := _c.mutation.RefundReason(); !ok { + return &ValidationError{Name: "refund_reason", err: errors.New(`ent: missing required field "PayRefund.refund_reason"`)} + } + if _, ok := _c.mutation.ChannelRefundNo(); !ok { + return &ValidationError{Name: "channel_refund_no", err: errors.New(`ent: missing required field "PayRefund.channel_refund_no"`)} + } + if _, ok := _c.mutation.RefundTime(); !ok { + return &ValidationError{Name: "refund_time", err: errors.New(`ent: missing required field "PayRefund.refund_time"`)} + } + if len(_c.mutation.OrderIDs()) == 0 { + return &ValidationError{Name: "order", err: errors.New(`ent: missing required edge "PayRefund.order"`)} + } + if len(_c.mutation.ChannelIDs()) == 0 { + return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "PayRefund.channel"`)} + } + return nil +} + +func (_c *PayRefundCreate) sqlSave(ctx context.Context) (*PayRefund, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.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) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayRefundCreate) createSpec() (*PayRefund, *sqlgraph.CreateSpec) { + var ( + _node = &PayRefund{config: _c.config} + _spec = sqlgraph.NewCreateSpec(payrefund.Table, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(payrefund.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(payrefund.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(payrefund.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(payrefund.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(payrefund.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.UserID(); ok { + _spec.SetField(payrefund.FieldUserID, field.TypeUint64, value) + _node.UserID = value + } + if value, ok := _c.mutation.NotifyURL(); ok { + _spec.SetField(payrefund.FieldNotifyURL, field.TypeString, value) + _node.NotifyURL = value + } + if value, ok := _c.mutation.RefundStatus(); ok { + _spec.SetField(payrefund.FieldRefundStatus, field.TypeUint8, value) + _node.RefundStatus = value + } + if value, ok := _c.mutation.RefundAmount(); ok { + _spec.SetField(payrefund.FieldRefundAmount, field.TypeUint64, value) + _node.RefundAmount = value + } + if value, ok := _c.mutation.PayAmount(); ok { + _spec.SetField(payrefund.FieldPayAmount, field.TypeUint64, value) + _node.PayAmount = value + } + if value, ok := _c.mutation.RefundNo(); ok { + _spec.SetField(payrefund.FieldRefundNo, field.TypeString, value) + _node.RefundNo = value + } + if value, ok := _c.mutation.RefundReason(); ok { + _spec.SetField(payrefund.FieldRefundReason, field.TypeString, value) + _node.RefundReason = value + } + if value, ok := _c.mutation.UserIP(); ok { + _spec.SetField(payrefund.FieldUserIP, field.TypeString, value) + _node.UserIP = value + } + if value, ok := _c.mutation.ChannelRefundNo(); ok { + _spec.SetField(payrefund.FieldChannelRefundNo, field.TypeString, value) + _node.ChannelRefundNo = value + } + if value, ok := _c.mutation.RefundTime(); ok { + _spec.SetField(payrefund.FieldRefundTime, field.TypeTime, value) + _node.RefundTime = value + } + if value, ok := _c.mutation.ChannelErrorCode(); ok { + _spec.SetField(payrefund.FieldChannelErrorCode, field.TypeString, value) + _node.ChannelErrorCode = value + } + if value, ok := _c.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payrefund.FieldChannelErrorMsg, field.TypeString, value) + _node.ChannelErrorMsg = value + } + if value, ok := _c.mutation.ChannelNotifyData(); ok { + _spec.SetField(payrefund.FieldChannelNotifyData, field.TypeString, value) + _node.ChannelNotifyData = value + } + if nodes := _c.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.OrderTable, + Columns: []string{payrefund.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.OrderID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.ChannelTable, + Columns: []string{payrefund.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ChannelID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayRefundCreateBulk is the builder for creating many PayRefund entities in bulk. +type PayRefundCreateBulk struct { + config + err error + builders []*PayRefundCreate +} + +// Save creates the PayRefund entities in the database. +func (_c *PayRefundCreateBulk) Save(ctx context.Context) ([]*PayRefund, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayRefund, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayRefundMutation) + 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, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.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, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayRefundCreateBulk) SaveX(ctx context.Context) []*PayRefund { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayRefundCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayRefundCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payrefund_delete.go b/rpc/ent/payrefund_delete.go new file mode 100644 index 0000000..8a3c3dc --- /dev/null +++ b/rpc/ent/payrefund_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayRefundDelete is the builder for deleting a PayRefund entity. +type PayRefundDelete struct { + config + hooks []Hook + mutation *PayRefundMutation +} + +// Where appends a list predicates to the PayRefundDelete builder. +func (_d *PayRefundDelete) Where(ps ...predicate.PayRefund) *PayRefundDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayRefundDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayRefundDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayRefundDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(payrefund.Table, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// PayRefundDeleteOne is the builder for deleting a single PayRefund entity. +type PayRefundDeleteOne struct { + _d *PayRefundDelete +} + +// Where appends a list predicates to the PayRefundDelete builder. +func (_d *PayRefundDeleteOne) Where(ps ...predicate.PayRefund) *PayRefundDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayRefundDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{payrefund.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayRefundDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payrefund_query.go b/rpc/ent/payrefund_query.go new file mode 100644 index 0000000..676287e --- /dev/null +++ b/rpc/ent/payrefund_query.go @@ -0,0 +1,681 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayRefundQuery is the builder for querying PayRefund entities. +type PayRefundQuery struct { + config + ctx *QueryContext + order []payrefund.OrderOption + inters []Interceptor + predicates []predicate.PayRefund + withOrder *PayOrderQuery + withChannel *PayChannelQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayRefundQuery builder. +func (_q *PayRefundQuery) Where(ps ...predicate.PayRefund) *PayRefundQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayRefundQuery) Limit(limit int) *PayRefundQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayRefundQuery) Offset(offset int) *PayRefundQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *PayRefundQuery) Unique(unique bool) *PayRefundQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayRefundQuery) Order(o ...payrefund.OrderOption) *PayRefundQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryOrder chains the current query on the "order" edge. +func (_q *PayRefundQuery) QueryOrder() *PayOrderQuery { + query := (&PayOrderClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payrefund.Table, payrefund.FieldID, selector), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payrefund.OrderTable, payrefund.OrderColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChannel chains the current query on the "channel" edge. +func (_q *PayRefundQuery) QueryChannel() *PayChannelQuery { + query := (&PayChannelClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payrefund.Table, payrefund.FieldID, selector), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payrefund.ChannelTable, payrefund.ChannelColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayRefund entity from the query. +// Returns a *NotFoundError when no PayRefund was found. +func (_q *PayRefundQuery) First(ctx context.Context) (*PayRefund, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{payrefund.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayRefundQuery) FirstX(ctx context.Context) *PayRefund { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayRefund ID from the query. +// Returns a *NotFoundError when no PayRefund ID was found. +func (_q *PayRefundQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{payrefund.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayRefundQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayRefund entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayRefund entity is found. +// Returns a *NotFoundError when no PayRefund entities are found. +func (_q *PayRefundQuery) Only(ctx context.Context) (*PayRefund, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{payrefund.Label} + default: + return nil, &NotSingularError{payrefund.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayRefundQuery) OnlyX(ctx context.Context) *PayRefund { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayRefund ID in the query. +// Returns a *NotSingularError when more than one PayRefund ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayRefundQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{payrefund.Label} + default: + err = &NotSingularError{payrefund.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayRefundQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayRefunds. +func (_q *PayRefundQuery) All(ctx context.Context) ([]*PayRefund, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayRefund, *PayRefundQuery]() + return withInterceptors[[]*PayRefund](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayRefundQuery) AllX(ctx context.Context) []*PayRefund { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayRefund IDs. +func (_q *PayRefundQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(payrefund.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayRefundQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayRefundQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*PayRefundQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayRefundQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *PayRefundQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *PayRefundQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayRefundQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *PayRefundQuery) Clone() *PayRefundQuery { + if _q == nil { + return nil + } + return &PayRefundQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]payrefund.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayRefund{}, _q.predicates...), + withOrder: _q.withOrder.Clone(), + withChannel: _q.withChannel.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithOrder tells the query-builder to eager-load the nodes that are connected to +// the "order" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayRefundQuery) WithOrder(opts ...func(*PayOrderQuery)) *PayRefundQuery { + query := (&PayOrderClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrder = query + return _q +} + +// WithChannel tells the query-builder to eager-load the nodes that are connected to +// the "channel" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayRefundQuery) WithChannel(opts ...func(*PayChannelQuery)) *PayRefundQuery { + query := (&PayChannelClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChannel = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayRefund.Query(). +// GroupBy(payrefund.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayRefundQuery) GroupBy(field string, fields ...string) *PayRefundGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayRefundGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = payrefund.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayRefund.Query(). +// Select(payrefund.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayRefundQuery) Select(fields ...string) *PayRefundSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayRefundSelect{PayRefundQuery: _q} + sbuild.label = payrefund.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayRefundSelect configured with the given aggregations. +func (_q *PayRefundQuery) Aggregate(fns ...AggregateFunc) *PayRefundSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayRefundQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !payrefund.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *PayRefundQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayRefund, error) { + var ( + nodes = []*PayRefund{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withOrder != nil, + _q.withChannel != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayRefund).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayRefund{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withOrder; query != nil { + if err := _q.loadOrder(ctx, query, nodes, nil, + func(n *PayRefund, e *PayOrder) { n.Edges.Order = e }); err != nil { + return nil, err + } + } + if query := _q.withChannel; query != nil { + if err := _q.loadChannel(ctx, query, nodes, nil, + func(n *PayRefund, e *PayChannel) { n.Edges.Channel = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayRefundQuery) loadOrder(ctx context.Context, query *PayOrderQuery, nodes []*PayRefund, init func(*PayRefund), assign func(*PayRefund, *PayOrder)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayRefund) + for i := range nodes { + fk := nodes[i].OrderID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(payorder.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "order_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PayRefundQuery) loadChannel(ctx context.Context, query *PayChannelQuery, nodes []*PayRefund, init func(*PayRefund), assign func(*PayRefund, *PayChannel)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayRefund) + for i := range nodes { + fk := nodes[i].ChannelID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(paychannel.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "channel_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *PayRefundQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *PayRefundQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(payrefund.Table, payrefund.Columns, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, payrefund.FieldID) + for i := range fields { + if fields[i] != payrefund.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withOrder != nil { + _spec.Node.AddColumnOnce(payrefund.FieldOrderID) + } + if _q.withChannel != nil { + _spec.Node.AddColumnOnce(payrefund.FieldChannelID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *PayRefundQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(payrefund.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = payrefund.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// PayRefundGroupBy is the group-by builder for PayRefund entities. +type PayRefundGroupBy struct { + selector + build *PayRefundQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayRefundGroupBy) Aggregate(fns ...AggregateFunc) *PayRefundGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayRefundGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayRefundQuery, *PayRefundGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayRefundGroupBy) sqlScan(ctx context.Context, root *PayRefundQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PayRefundSelect is the builder for selecting fields of PayRefund entities. +type PayRefundSelect struct { + *PayRefundQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayRefundSelect) Aggregate(fns ...AggregateFunc) *PayRefundSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayRefundSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PayRefundQuery, *PayRefundSelect](ctx, _s.PayRefundQuery, _s, _s.inters, v) +} + +func (_s *PayRefundSelect) sqlScan(ctx context.Context, root *PayRefundQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/payrefund_update.go b/rpc/ent/payrefund_update.go new file mode 100644 index 0000000..088cc17 --- /dev/null +++ b/rpc/ent/payrefund_update.go @@ -0,0 +1,1194 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayRefundUpdate is the builder for updating PayRefund entities. +type PayRefundUpdate struct { + config + hooks []Hook + mutation *PayRefundMutation +} + +// Where appends a list predicates to the PayRefundUpdate builder. +func (_u *PayRefundUpdate) Where(ps ...predicate.PayRefund) *PayRefundUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayRefundUpdate) SetUpdatedAt(v time.Time) *PayRefundUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayRefundUpdate) SetStatus(v uint8) *PayRefundUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableStatus(v *uint8) *PayRefundUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayRefundUpdate) AddStatus(v int8) *PayRefundUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayRefundUpdate) ClearStatus() *PayRefundUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayRefundUpdate) SetDeletedAt(v time.Time) *PayRefundUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableDeletedAt(v *time.Time) *PayRefundUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayRefundUpdate) ClearDeletedAt() *PayRefundUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayRefundUpdate) SetChannelID(v uint64) *PayRefundUpdate { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableChannelID(v *uint64) *PayRefundUpdate { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *PayRefundUpdate) SetUserID(v uint64) *PayRefundUpdate { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableUserID(v *uint64) *PayRefundUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *PayRefundUpdate) AddUserID(v int64) *PayRefundUpdate { + _u.mutation.AddUserID(v) + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayRefundUpdate) SetOrderID(v uint64) *PayRefundUpdate { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableOrderID(v *uint64) *PayRefundUpdate { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayRefundUpdate) SetNotifyURL(v string) *PayRefundUpdate { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableNotifyURL(v *string) *PayRefundUpdate { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (_u *PayRefundUpdate) ClearNotifyURL() *PayRefundUpdate { + _u.mutation.ClearNotifyURL() + return _u +} + +// SetRefundStatus sets the "refund_status" field. +func (_u *PayRefundUpdate) SetRefundStatus(v uint8) *PayRefundUpdate { + _u.mutation.ResetRefundStatus() + _u.mutation.SetRefundStatus(v) + return _u +} + +// SetNillableRefundStatus sets the "refund_status" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableRefundStatus(v *uint8) *PayRefundUpdate { + if v != nil { + _u.SetRefundStatus(*v) + } + return _u +} + +// AddRefundStatus adds value to the "refund_status" field. +func (_u *PayRefundUpdate) AddRefundStatus(v int8) *PayRefundUpdate { + _u.mutation.AddRefundStatus(v) + return _u +} + +// SetRefundAmount sets the "refund_amount" field. +func (_u *PayRefundUpdate) SetRefundAmount(v uint64) *PayRefundUpdate { + _u.mutation.ResetRefundAmount() + _u.mutation.SetRefundAmount(v) + return _u +} + +// SetNillableRefundAmount sets the "refund_amount" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableRefundAmount(v *uint64) *PayRefundUpdate { + if v != nil { + _u.SetRefundAmount(*v) + } + return _u +} + +// AddRefundAmount adds value to the "refund_amount" field. +func (_u *PayRefundUpdate) AddRefundAmount(v int64) *PayRefundUpdate { + _u.mutation.AddRefundAmount(v) + return _u +} + +// SetPayAmount sets the "pay_amount" field. +func (_u *PayRefundUpdate) SetPayAmount(v uint64) *PayRefundUpdate { + _u.mutation.ResetPayAmount() + _u.mutation.SetPayAmount(v) + return _u +} + +// SetNillablePayAmount sets the "pay_amount" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillablePayAmount(v *uint64) *PayRefundUpdate { + if v != nil { + _u.SetPayAmount(*v) + } + return _u +} + +// AddPayAmount adds value to the "pay_amount" field. +func (_u *PayRefundUpdate) AddPayAmount(v int64) *PayRefundUpdate { + _u.mutation.AddPayAmount(v) + return _u +} + +// SetRefundNo sets the "refund_no" field. +func (_u *PayRefundUpdate) SetRefundNo(v string) *PayRefundUpdate { + _u.mutation.SetRefundNo(v) + return _u +} + +// SetNillableRefundNo sets the "refund_no" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableRefundNo(v *string) *PayRefundUpdate { + if v != nil { + _u.SetRefundNo(*v) + } + return _u +} + +// SetRefundReason sets the "refund_reason" field. +func (_u *PayRefundUpdate) SetRefundReason(v string) *PayRefundUpdate { + _u.mutation.SetRefundReason(v) + return _u +} + +// SetNillableRefundReason sets the "refund_reason" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableRefundReason(v *string) *PayRefundUpdate { + if v != nil { + _u.SetRefundReason(*v) + } + return _u +} + +// SetUserIP sets the "user_ip" field. +func (_u *PayRefundUpdate) SetUserIP(v string) *PayRefundUpdate { + _u.mutation.SetUserIP(v) + return _u +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableUserIP(v *string) *PayRefundUpdate { + if v != nil { + _u.SetUserIP(*v) + } + return _u +} + +// ClearUserIP clears the value of the "user_ip" field. +func (_u *PayRefundUpdate) ClearUserIP() *PayRefundUpdate { + _u.mutation.ClearUserIP() + return _u +} + +// SetChannelRefundNo sets the "channel_refund_no" field. +func (_u *PayRefundUpdate) SetChannelRefundNo(v string) *PayRefundUpdate { + _u.mutation.SetChannelRefundNo(v) + return _u +} + +// SetNillableChannelRefundNo sets the "channel_refund_no" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableChannelRefundNo(v *string) *PayRefundUpdate { + if v != nil { + _u.SetChannelRefundNo(*v) + } + return _u +} + +// SetRefundTime sets the "refund_time" field. +func (_u *PayRefundUpdate) SetRefundTime(v time.Time) *PayRefundUpdate { + _u.mutation.SetRefundTime(v) + return _u +} + +// SetNillableRefundTime sets the "refund_time" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableRefundTime(v *time.Time) *PayRefundUpdate { + if v != nil { + _u.SetRefundTime(*v) + } + return _u +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_u *PayRefundUpdate) SetChannelErrorCode(v string) *PayRefundUpdate { + _u.mutation.SetChannelErrorCode(v) + return _u +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableChannelErrorCode(v *string) *PayRefundUpdate { + if v != nil { + _u.SetChannelErrorCode(*v) + } + return _u +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (_u *PayRefundUpdate) ClearChannelErrorCode() *PayRefundUpdate { + _u.mutation.ClearChannelErrorCode() + return _u +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_u *PayRefundUpdate) SetChannelErrorMsg(v string) *PayRefundUpdate { + _u.mutation.SetChannelErrorMsg(v) + return _u +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableChannelErrorMsg(v *string) *PayRefundUpdate { + if v != nil { + _u.SetChannelErrorMsg(*v) + } + return _u +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (_u *PayRefundUpdate) ClearChannelErrorMsg() *PayRefundUpdate { + _u.mutation.ClearChannelErrorMsg() + return _u +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_u *PayRefundUpdate) SetChannelNotifyData(v string) *PayRefundUpdate { + _u.mutation.SetChannelNotifyData(v) + return _u +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_u *PayRefundUpdate) SetNillableChannelNotifyData(v *string) *PayRefundUpdate { + if v != nil { + _u.SetChannelNotifyData(*v) + } + return _u +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (_u *PayRefundUpdate) ClearChannelNotifyData() *PayRefundUpdate { + _u.mutation.ClearChannelNotifyData() + return _u +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayRefundUpdate) SetOrder(v *PayOrder) *PayRefundUpdate { + return _u.SetOrderID(v.ID) +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayRefundUpdate) SetChannel(v *PayChannel) *PayRefundUpdate { + return _u.SetChannelID(v.ID) +} + +// Mutation returns the PayRefundMutation object of the builder. +func (_u *PayRefundUpdate) Mutation() *PayRefundMutation { + return _u.mutation +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayRefundUpdate) ClearOrder() *PayRefundUpdate { + _u.mutation.ClearOrder() + return _u +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayRefundUpdate) ClearChannel() *PayRefundUpdate { + _u.mutation.ClearChannel() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayRefundUpdate) 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 *PayRefundUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayRefundUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayRefundUpdate) 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 *PayRefundUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payrefund.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayRefundUpdate) check() error { + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayRefund.order"`) + } + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayRefund.channel"`) + } + return nil +} + +func (_u *PayRefundUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payrefund.Table, payrefund.Columns, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(payrefund.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payrefund.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payrefund.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payrefund.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payrefund.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payrefund.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(payrefund.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(payrefund.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(payrefund.FieldNotifyURL, field.TypeString, value) + } + if _u.mutation.NotifyURLCleared() { + _spec.ClearField(payrefund.FieldNotifyURL, field.TypeString) + } + if value, ok := _u.mutation.RefundStatus(); ok { + _spec.SetField(payrefund.FieldRefundStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedRefundStatus(); ok { + _spec.AddField(payrefund.FieldRefundStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.RefundAmount(); ok { + _spec.SetField(payrefund.FieldRefundAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedRefundAmount(); ok { + _spec.AddField(payrefund.FieldRefundAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.PayAmount(); ok { + _spec.SetField(payrefund.FieldPayAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedPayAmount(); ok { + _spec.AddField(payrefund.FieldPayAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.RefundNo(); ok { + _spec.SetField(payrefund.FieldRefundNo, field.TypeString, value) + } + if value, ok := _u.mutation.RefundReason(); ok { + _spec.SetField(payrefund.FieldRefundReason, field.TypeString, value) + } + if value, ok := _u.mutation.UserIP(); ok { + _spec.SetField(payrefund.FieldUserIP, field.TypeString, value) + } + if _u.mutation.UserIPCleared() { + _spec.ClearField(payrefund.FieldUserIP, field.TypeString) + } + if value, ok := _u.mutation.ChannelRefundNo(); ok { + _spec.SetField(payrefund.FieldChannelRefundNo, field.TypeString, value) + } + if value, ok := _u.mutation.RefundTime(); ok { + _spec.SetField(payrefund.FieldRefundTime, field.TypeTime, value) + } + if value, ok := _u.mutation.ChannelErrorCode(); ok { + _spec.SetField(payrefund.FieldChannelErrorCode, field.TypeString, value) + } + if _u.mutation.ChannelErrorCodeCleared() { + _spec.ClearField(payrefund.FieldChannelErrorCode, field.TypeString) + } + if value, ok := _u.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payrefund.FieldChannelErrorMsg, field.TypeString, value) + } + if _u.mutation.ChannelErrorMsgCleared() { + _spec.ClearField(payrefund.FieldChannelErrorMsg, field.TypeString) + } + if value, ok := _u.mutation.ChannelNotifyData(); ok { + _spec.SetField(payrefund.FieldChannelNotifyData, field.TypeString, value) + } + if _u.mutation.ChannelNotifyDataCleared() { + _spec.ClearField(payrefund.FieldChannelNotifyData, field.TypeString) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.OrderTable, + Columns: []string{payrefund.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.OrderTable, + Columns: []string{payrefund.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.ChannelTable, + Columns: []string{payrefund.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.ChannelTable, + Columns: []string{payrefund.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{payrefund.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayRefundUpdateOne is the builder for updating a single PayRefund entity. +type PayRefundUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayRefundMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayRefundUpdateOne) SetUpdatedAt(v time.Time) *PayRefundUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayRefundUpdateOne) SetStatus(v uint8) *PayRefundUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableStatus(v *uint8) *PayRefundUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayRefundUpdateOne) AddStatus(v int8) *PayRefundUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayRefundUpdateOne) ClearStatus() *PayRefundUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayRefundUpdateOne) SetDeletedAt(v time.Time) *PayRefundUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableDeletedAt(v *time.Time) *PayRefundUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayRefundUpdateOne) ClearDeletedAt() *PayRefundUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayRefundUpdateOne) SetChannelID(v uint64) *PayRefundUpdateOne { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableChannelID(v *uint64) *PayRefundUpdateOne { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *PayRefundUpdateOne) SetUserID(v uint64) *PayRefundUpdateOne { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableUserID(v *uint64) *PayRefundUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *PayRefundUpdateOne) AddUserID(v int64) *PayRefundUpdateOne { + _u.mutation.AddUserID(v) + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayRefundUpdateOne) SetOrderID(v uint64) *PayRefundUpdateOne { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableOrderID(v *uint64) *PayRefundUpdateOne { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayRefundUpdateOne) SetNotifyURL(v string) *PayRefundUpdateOne { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableNotifyURL(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (_u *PayRefundUpdateOne) ClearNotifyURL() *PayRefundUpdateOne { + _u.mutation.ClearNotifyURL() + return _u +} + +// SetRefundStatus sets the "refund_status" field. +func (_u *PayRefundUpdateOne) SetRefundStatus(v uint8) *PayRefundUpdateOne { + _u.mutation.ResetRefundStatus() + _u.mutation.SetRefundStatus(v) + return _u +} + +// SetNillableRefundStatus sets the "refund_status" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableRefundStatus(v *uint8) *PayRefundUpdateOne { + if v != nil { + _u.SetRefundStatus(*v) + } + return _u +} + +// AddRefundStatus adds value to the "refund_status" field. +func (_u *PayRefundUpdateOne) AddRefundStatus(v int8) *PayRefundUpdateOne { + _u.mutation.AddRefundStatus(v) + return _u +} + +// SetRefundAmount sets the "refund_amount" field. +func (_u *PayRefundUpdateOne) SetRefundAmount(v uint64) *PayRefundUpdateOne { + _u.mutation.ResetRefundAmount() + _u.mutation.SetRefundAmount(v) + return _u +} + +// SetNillableRefundAmount sets the "refund_amount" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableRefundAmount(v *uint64) *PayRefundUpdateOne { + if v != nil { + _u.SetRefundAmount(*v) + } + return _u +} + +// AddRefundAmount adds value to the "refund_amount" field. +func (_u *PayRefundUpdateOne) AddRefundAmount(v int64) *PayRefundUpdateOne { + _u.mutation.AddRefundAmount(v) + return _u +} + +// SetPayAmount sets the "pay_amount" field. +func (_u *PayRefundUpdateOne) SetPayAmount(v uint64) *PayRefundUpdateOne { + _u.mutation.ResetPayAmount() + _u.mutation.SetPayAmount(v) + return _u +} + +// SetNillablePayAmount sets the "pay_amount" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillablePayAmount(v *uint64) *PayRefundUpdateOne { + if v != nil { + _u.SetPayAmount(*v) + } + return _u +} + +// AddPayAmount adds value to the "pay_amount" field. +func (_u *PayRefundUpdateOne) AddPayAmount(v int64) *PayRefundUpdateOne { + _u.mutation.AddPayAmount(v) + return _u +} + +// SetRefundNo sets the "refund_no" field. +func (_u *PayRefundUpdateOne) SetRefundNo(v string) *PayRefundUpdateOne { + _u.mutation.SetRefundNo(v) + return _u +} + +// SetNillableRefundNo sets the "refund_no" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableRefundNo(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetRefundNo(*v) + } + return _u +} + +// SetRefundReason sets the "refund_reason" field. +func (_u *PayRefundUpdateOne) SetRefundReason(v string) *PayRefundUpdateOne { + _u.mutation.SetRefundReason(v) + return _u +} + +// SetNillableRefundReason sets the "refund_reason" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableRefundReason(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetRefundReason(*v) + } + return _u +} + +// SetUserIP sets the "user_ip" field. +func (_u *PayRefundUpdateOne) SetUserIP(v string) *PayRefundUpdateOne { + _u.mutation.SetUserIP(v) + return _u +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableUserIP(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetUserIP(*v) + } + return _u +} + +// ClearUserIP clears the value of the "user_ip" field. +func (_u *PayRefundUpdateOne) ClearUserIP() *PayRefundUpdateOne { + _u.mutation.ClearUserIP() + return _u +} + +// SetChannelRefundNo sets the "channel_refund_no" field. +func (_u *PayRefundUpdateOne) SetChannelRefundNo(v string) *PayRefundUpdateOne { + _u.mutation.SetChannelRefundNo(v) + return _u +} + +// SetNillableChannelRefundNo sets the "channel_refund_no" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableChannelRefundNo(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetChannelRefundNo(*v) + } + return _u +} + +// SetRefundTime sets the "refund_time" field. +func (_u *PayRefundUpdateOne) SetRefundTime(v time.Time) *PayRefundUpdateOne { + _u.mutation.SetRefundTime(v) + return _u +} + +// SetNillableRefundTime sets the "refund_time" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableRefundTime(v *time.Time) *PayRefundUpdateOne { + if v != nil { + _u.SetRefundTime(*v) + } + return _u +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_u *PayRefundUpdateOne) SetChannelErrorCode(v string) *PayRefundUpdateOne { + _u.mutation.SetChannelErrorCode(v) + return _u +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableChannelErrorCode(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetChannelErrorCode(*v) + } + return _u +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (_u *PayRefundUpdateOne) ClearChannelErrorCode() *PayRefundUpdateOne { + _u.mutation.ClearChannelErrorCode() + return _u +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_u *PayRefundUpdateOne) SetChannelErrorMsg(v string) *PayRefundUpdateOne { + _u.mutation.SetChannelErrorMsg(v) + return _u +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableChannelErrorMsg(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetChannelErrorMsg(*v) + } + return _u +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (_u *PayRefundUpdateOne) ClearChannelErrorMsg() *PayRefundUpdateOne { + _u.mutation.ClearChannelErrorMsg() + return _u +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_u *PayRefundUpdateOne) SetChannelNotifyData(v string) *PayRefundUpdateOne { + _u.mutation.SetChannelNotifyData(v) + return _u +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_u *PayRefundUpdateOne) SetNillableChannelNotifyData(v *string) *PayRefundUpdateOne { + if v != nil { + _u.SetChannelNotifyData(*v) + } + return _u +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (_u *PayRefundUpdateOne) ClearChannelNotifyData() *PayRefundUpdateOne { + _u.mutation.ClearChannelNotifyData() + return _u +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayRefundUpdateOne) SetOrder(v *PayOrder) *PayRefundUpdateOne { + return _u.SetOrderID(v.ID) +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayRefundUpdateOne) SetChannel(v *PayChannel) *PayRefundUpdateOne { + return _u.SetChannelID(v.ID) +} + +// Mutation returns the PayRefundMutation object of the builder. +func (_u *PayRefundUpdateOne) Mutation() *PayRefundMutation { + return _u.mutation +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayRefundUpdateOne) ClearOrder() *PayRefundUpdateOne { + _u.mutation.ClearOrder() + return _u +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayRefundUpdateOne) ClearChannel() *PayRefundUpdateOne { + _u.mutation.ClearChannel() + return _u +} + +// Where appends a list predicates to the PayRefundUpdate builder. +func (_u *PayRefundUpdateOne) Where(ps ...predicate.PayRefund) *PayRefundUpdateOne { + _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 *PayRefundUpdateOne) Select(field string, fields ...string) *PayRefundUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayRefund entity. +func (_u *PayRefundUpdateOne) Save(ctx context.Context) (*PayRefund, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayRefundUpdateOne) SaveX(ctx context.Context) *PayRefund { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayRefundUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayRefundUpdateOne) 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 *PayRefundUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payrefund.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayRefundUpdateOne) check() error { + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayRefund.order"`) + } + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayRefund.channel"`) + } + return nil +} + +func (_u *PayRefundUpdateOne) sqlSave(ctx context.Context) (_node *PayRefund, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payrefund.Table, payrefund.Columns, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayRefund.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, payrefund.FieldID) + for _, f := range fields { + if !payrefund.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != payrefund.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.UpdatedAt(); ok { + _spec.SetField(payrefund.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payrefund.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payrefund.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payrefund.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payrefund.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payrefund.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(payrefund.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(payrefund.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(payrefund.FieldNotifyURL, field.TypeString, value) + } + if _u.mutation.NotifyURLCleared() { + _spec.ClearField(payrefund.FieldNotifyURL, field.TypeString) + } + if value, ok := _u.mutation.RefundStatus(); ok { + _spec.SetField(payrefund.FieldRefundStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedRefundStatus(); ok { + _spec.AddField(payrefund.FieldRefundStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.RefundAmount(); ok { + _spec.SetField(payrefund.FieldRefundAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedRefundAmount(); ok { + _spec.AddField(payrefund.FieldRefundAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.PayAmount(); ok { + _spec.SetField(payrefund.FieldPayAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedPayAmount(); ok { + _spec.AddField(payrefund.FieldPayAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.RefundNo(); ok { + _spec.SetField(payrefund.FieldRefundNo, field.TypeString, value) + } + if value, ok := _u.mutation.RefundReason(); ok { + _spec.SetField(payrefund.FieldRefundReason, field.TypeString, value) + } + if value, ok := _u.mutation.UserIP(); ok { + _spec.SetField(payrefund.FieldUserIP, field.TypeString, value) + } + if _u.mutation.UserIPCleared() { + _spec.ClearField(payrefund.FieldUserIP, field.TypeString) + } + if value, ok := _u.mutation.ChannelRefundNo(); ok { + _spec.SetField(payrefund.FieldChannelRefundNo, field.TypeString, value) + } + if value, ok := _u.mutation.RefundTime(); ok { + _spec.SetField(payrefund.FieldRefundTime, field.TypeTime, value) + } + if value, ok := _u.mutation.ChannelErrorCode(); ok { + _spec.SetField(payrefund.FieldChannelErrorCode, field.TypeString, value) + } + if _u.mutation.ChannelErrorCodeCleared() { + _spec.ClearField(payrefund.FieldChannelErrorCode, field.TypeString) + } + if value, ok := _u.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payrefund.FieldChannelErrorMsg, field.TypeString, value) + } + if _u.mutation.ChannelErrorMsgCleared() { + _spec.ClearField(payrefund.FieldChannelErrorMsg, field.TypeString) + } + if value, ok := _u.mutation.ChannelNotifyData(); ok { + _spec.SetField(payrefund.FieldChannelNotifyData, field.TypeString, value) + } + if _u.mutation.ChannelNotifyDataCleared() { + _spec.ClearField(payrefund.FieldChannelNotifyData, field.TypeString) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.OrderTable, + Columns: []string{payrefund.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.OrderTable, + Columns: []string{payrefund.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.ChannelTable, + Columns: []string{payrefund.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payrefund.ChannelTable, + Columns: []string{payrefund.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayRefund{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{payrefund.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +}