343 lines
12 KiB
Go
343 lines
12 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"mingyang-admin-pay/rpc/ent/app"
|
|
"mingyang-admin-pay/rpc/ent/paychannel"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// PayChannel Table | 支付渠道表
|
|
type PayChannel 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"`
|
|
// Pay channel code | 支付渠道编码
|
|
Code string `json:"code,omitempty"`
|
|
// Pay channel name | 支付渠道英文名称
|
|
NameEn string `json:"name_en,omitempty"`
|
|
// Pay channel name | 支付渠道中文名称
|
|
NameZh string `json:"name_zh,omitempty"`
|
|
// Free rate | 手续费比例
|
|
FreeRate string `json:"free_rate,omitempty"`
|
|
// App ID | 应用ID
|
|
AppID uint64 `json:"app_id,omitempty"`
|
|
// Config | 配置信息
|
|
Config map[string]interface{} `json:"config,omitempty"`
|
|
// Remark | 备注
|
|
Remake string `json:"remake,omitempty"`
|
|
// Icon | 图标
|
|
Icon uint64 `json:"icon,omitempty"`
|
|
// Order time out | 订单超时时间
|
|
OrderTimeOut string `json:"order_time_out,omitempty"`
|
|
// Support currency | 支持币种
|
|
SupportCurrency string `json:"support_currency,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the PayChannelQuery when eager-loading is set.
|
|
Edges PayChannelEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// PayChannelEdges holds the relations/edges for other nodes in the graph.
|
|
type PayChannelEdges struct {
|
|
// Orders holds the value of the orders edge.
|
|
Orders []*PayOrder `json:"orders,omitempty"`
|
|
// OrdersExtension holds the value of the orders_extension edge.
|
|
OrdersExtension []*PayOrderExtension `json:"orders_extension,omitempty"`
|
|
// Refund holds the value of the refund edge.
|
|
Refund []*PayRefund `json:"refund,omitempty"`
|
|
// App holds the value of the app edge.
|
|
App *App `json:"app,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [4]bool
|
|
}
|
|
|
|
// OrdersOrErr returns the Orders value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e PayChannelEdges) OrdersOrErr() ([]*PayOrder, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Orders, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "orders"}
|
|
}
|
|
|
|
// OrdersExtensionOrErr returns the OrdersExtension value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e PayChannelEdges) OrdersExtensionOrErr() ([]*PayOrderExtension, error) {
|
|
if e.loadedTypes[1] {
|
|
return e.OrdersExtension, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "orders_extension"}
|
|
}
|
|
|
|
// RefundOrErr returns the Refund value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e PayChannelEdges) RefundOrErr() ([]*PayRefund, error) {
|
|
if e.loadedTypes[2] {
|
|
return e.Refund, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "refund"}
|
|
}
|
|
|
|
// 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 PayChannelEdges) AppOrErr() (*App, error) {
|
|
if e.App != nil {
|
|
return e.App, nil
|
|
} else if e.loadedTypes[3] {
|
|
return nil, &NotFoundError{label: app.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "app"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*PayChannel) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case paychannel.FieldConfig:
|
|
values[i] = new([]byte)
|
|
case paychannel.FieldID, paychannel.FieldStatus, paychannel.FieldTenantID, paychannel.FieldAppID, paychannel.FieldIcon:
|
|
values[i] = new(sql.NullInt64)
|
|
case paychannel.FieldCode, paychannel.FieldNameEn, paychannel.FieldNameZh, paychannel.FieldFreeRate, paychannel.FieldRemake, paychannel.FieldOrderTimeOut, paychannel.FieldSupportCurrency:
|
|
values[i] = new(sql.NullString)
|
|
case paychannel.FieldCreatedAt, paychannel.FieldUpdatedAt, paychannel.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 PayChannel fields.
|
|
func (_m *PayChannel) 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 paychannel.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 paychannel.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 paychannel.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 paychannel.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 paychannel.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 paychannel.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 paychannel.FieldCode:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field code", values[i])
|
|
} else if value.Valid {
|
|
_m.Code = value.String
|
|
}
|
|
case paychannel.FieldNameEn:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name_en", values[i])
|
|
} else if value.Valid {
|
|
_m.NameEn = value.String
|
|
}
|
|
case paychannel.FieldNameZh:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name_zh", values[i])
|
|
} else if value.Valid {
|
|
_m.NameZh = value.String
|
|
}
|
|
case paychannel.FieldFreeRate:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field free_rate", values[i])
|
|
} else if value.Valid {
|
|
_m.FreeRate = value.String
|
|
}
|
|
case paychannel.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 paychannel.FieldConfig:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field config", values[i])
|
|
} else if value != nil && len(*value) > 0 {
|
|
if err := json.Unmarshal(*value, &_m.Config); err != nil {
|
|
return fmt.Errorf("unmarshal field config: %w", err)
|
|
}
|
|
}
|
|
case paychannel.FieldRemake:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field remake", values[i])
|
|
} else if value.Valid {
|
|
_m.Remake = value.String
|
|
}
|
|
case paychannel.FieldIcon:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field icon", values[i])
|
|
} else if value.Valid {
|
|
_m.Icon = uint64(value.Int64)
|
|
}
|
|
case paychannel.FieldOrderTimeOut:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field order_time_out", values[i])
|
|
} else if value.Valid {
|
|
_m.OrderTimeOut = value.String
|
|
}
|
|
case paychannel.FieldSupportCurrency:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field support_currency", values[i])
|
|
} else if value.Valid {
|
|
_m.SupportCurrency = 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 PayChannel.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *PayChannel) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryOrders queries the "orders" edge of the PayChannel entity.
|
|
func (_m *PayChannel) QueryOrders() *PayOrderQuery {
|
|
return NewPayChannelClient(_m.config).QueryOrders(_m)
|
|
}
|
|
|
|
// QueryOrdersExtension queries the "orders_extension" edge of the PayChannel entity.
|
|
func (_m *PayChannel) QueryOrdersExtension() *PayOrderExtensionQuery {
|
|
return NewPayChannelClient(_m.config).QueryOrdersExtension(_m)
|
|
}
|
|
|
|
// QueryRefund queries the "refund" edge of the PayChannel entity.
|
|
func (_m *PayChannel) QueryRefund() *PayRefundQuery {
|
|
return NewPayChannelClient(_m.config).QueryRefund(_m)
|
|
}
|
|
|
|
// QueryApp queries the "app" edge of the PayChannel entity.
|
|
func (_m *PayChannel) QueryApp() *AppQuery {
|
|
return NewPayChannelClient(_m.config).QueryApp(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this PayChannel.
|
|
// Note that you need to call PayChannel.Unwrap() before calling this method if this PayChannel
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *PayChannel) Update() *PayChannelUpdateOne {
|
|
return NewPayChannelClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the PayChannel 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 *PayChannel) Unwrap() *PayChannel {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: PayChannel is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *PayChannel) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("PayChannel(")
|
|
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("code=")
|
|
builder.WriteString(_m.Code)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name_en=")
|
|
builder.WriteString(_m.NameEn)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name_zh=")
|
|
builder.WriteString(_m.NameZh)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("free_rate=")
|
|
builder.WriteString(_m.FreeRate)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("app_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.AppID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("config=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Config))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("remake=")
|
|
builder.WriteString(_m.Remake)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("icon=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Icon))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("order_time_out=")
|
|
builder.WriteString(_m.OrderTimeOut)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("support_currency=")
|
|
builder.WriteString(_m.SupportCurrency)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// PayChannels is a parsable slice of PayChannel.
|
|
type PayChannels []*PayChannel
|