mingyang-admin-pay/rpc/ent/app.go

237 lines
7.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"mingyang-admin-pay/rpc/ent/app"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// PayApp Table | 支付应用表
type App 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"`
// appKey 应用标识
AppKey string `json:"app_key,omitempty"`
// 应用名称
AppName string `json:"app_name,omitempty"`
// 支付成功回调地址
OrderNotifyURL string `json:"order_notify_url,omitempty"`
// 退款成功回调地址
RefundNotifyURL string `json:"refund_notify_url,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AppQuery when eager-loading is set.
Edges AppEdges `json:"edges"`
selectValues sql.SelectValues
}
// AppEdges holds the relations/edges for other nodes in the graph.
type AppEdges struct {
// Channel holds the value of the channel edge.
Channel []*PayChannel `json:"channel,omitempty"`
// NotifyTask holds the value of the notify_task edge.
NotifyTask []*PayNotifyTask `json:"notify_task,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// ChannelOrErr returns the Channel value or an error if the edge
// was not loaded in eager-loading.
func (e AppEdges) ChannelOrErr() ([]*PayChannel, error) {
if e.loadedTypes[0] {
return e.Channel, nil
}
return nil, &NotLoadedError{edge: "channel"}
}
// NotifyTaskOrErr returns the NotifyTask value or an error if the edge
// was not loaded in eager-loading.
func (e AppEdges) NotifyTaskOrErr() ([]*PayNotifyTask, error) {
if e.loadedTypes[1] {
return e.NotifyTask, nil
}
return nil, &NotLoadedError{edge: "notify_task"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*App) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case app.FieldID, app.FieldStatus, app.FieldTenantID:
values[i] = new(sql.NullInt64)
case app.FieldAppKey, app.FieldAppName, app.FieldOrderNotifyURL, app.FieldRefundNotifyURL:
values[i] = new(sql.NullString)
case app.FieldCreatedAt, app.FieldUpdatedAt, app.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 App fields.
func (_m *App) 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 app.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 app.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 app.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 app.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 app.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 app.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 app.FieldAppKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field app_key", values[i])
} else if value.Valid {
_m.AppKey = value.String
}
case app.FieldAppName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field app_name", values[i])
} else if value.Valid {
_m.AppName = value.String
}
case app.FieldOrderNotifyURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field order_notify_url", values[i])
} else if value.Valid {
_m.OrderNotifyURL = value.String
}
case app.FieldRefundNotifyURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field refund_notify_url", values[i])
} else if value.Valid {
_m.RefundNotifyURL = 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 App.
// This includes values selected through modifiers, order, etc.
func (_m *App) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryChannel queries the "channel" edge of the App entity.
func (_m *App) QueryChannel() *PayChannelQuery {
return NewAppClient(_m.config).QueryChannel(_m)
}
// QueryNotifyTask queries the "notify_task" edge of the App entity.
func (_m *App) QueryNotifyTask() *PayNotifyTaskQuery {
return NewAppClient(_m.config).QueryNotifyTask(_m)
}
// Update returns a builder for updating this App.
// Note that you need to call App.Unwrap() before calling this method if this App
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *App) Update() *AppUpdateOne {
return NewAppClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the App 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 *App) Unwrap() *App {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: App is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *App) String() string {
var builder strings.Builder
builder.WriteString("App(")
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("app_key=")
builder.WriteString(_m.AppKey)
builder.WriteString(", ")
builder.WriteString("app_name=")
builder.WriteString(_m.AppName)
builder.WriteString(", ")
builder.WriteString("order_notify_url=")
builder.WriteString(_m.OrderNotifyURL)
builder.WriteString(", ")
builder.WriteString("refund_notify_url=")
builder.WriteString(_m.RefundNotifyURL)
builder.WriteByte(')')
return builder.String()
}
// Apps is a parsable slice of App.
type Apps []*App