325 lines
12 KiB
Go
325 lines
12 KiB
Go
// 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
|