models

package
v0.0.0-...-89505e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const APPROVAL_STATUS_APPROVED int8 = 3
View Source
const APPROVAL_STATUS_DRAFT int8 = 0
View Source
const APPROVAL_STATUS_PENDING int8 = 1
View Source
const APPROVAL_STATUS_REJECTED int8 = 4
View Source
const MODEL_STATUS_ACTIVE int8 = 1
View Source
const MODEL_STATUS_CANCELED int8 = 2
View Source
const MODEL_STATUS_DRAFT int8 = 0
View Source
const MODEL_STATUS_INACTIVE int8 = 4
View Source
const MODEL_STATUS_PENDING int8 = 3
View Source
const PLATFORM_ALIPAY = "AliPay"
View Source
const PLATFORM_WECHAT = "WeChat"
View Source
const TABLE_NAME_Merchant_To_App_Config = "merchant_to_app_config"
View Source
const UNIQUE_ID = "uuid"

Variables

View Source
var ArrayModelFields *object.HashMap = &object.HashMap{}

Functions

func AssociationRelationship

func AssociationRelationship(db *gorm.DB, conditions *gorm.DB, mdl interface{}, relationship string, withClauseAssociations bool) *gorm.Association

*

  • Association Relationship

func ClearAssociation

func ClearAssociation(db *gorm.DB, object Model, foreignKey string, pivot Model) error

func GetFirst

func GetFirst(db *gorm.DB, conditions *gorm.DB, model interface{}, preloads []string) (err error)

func GetList

func GetList(db *gorm.DB, conditions *gorm.DB,
	models interface{}, preloads []string,
	page int, pageSize int) (paginator *database.Pagination, err error)

func GetModelFields

func GetModelFields(model interface{}) (fields []string)

func Paginate

func Paginate(page int, pageSize int) func(db *gorm.DB) *gorm.DB

func WhereUUID

func WhereUUID(uuid string) func(db *gorm.DB) *gorm.DB

*

  • Scope Where Conditions

Types

type App

type App struct {
	Model

	Name   string `gorm:"column:name" json:"name"`
	AppID  string `gorm:"column:app_id" json:"appID"`
	Secret string `gorm:"column:secret" json:"secret"`
}

type Merchant

type Merchant struct {
	Model

	Name     string `gorm:"column:name" json:"name"`
	MchID    string `gorm:"column:mch_id" json:"mchID"`
	Secret   string `gorm:"column:secret" json:"secret"`
	SecretV3 string `gorm:"column:secret_v3" json:"secretV3"`
	CertPath string `gorm:"column:cert_path" json:"certPath"`
	KeyPath  string `gorm:"column:key_path" json:"keyPath"`
	SerialNo string `gorm:"column:serial_no" json:"serialNO"`
}

type MerchantToAppConfig

type MerchantToAppConfig struct {
	*MyRelationship

	Merchant *Merchant `gorm:"foreignKey:AwardableObjectUUID;references:UUID"`
	App      *App      `gorm:"foreignKey:AwardableObjectUUID;references:UUID"`

	//common fields
	Status       int8              `gorm:"column:status" json:"status"`
	ConfigType   int8              `gorm:"column:config_type" json:"ConfigType"`
	MerchantUUID object.NullString `gorm:"column:merchant_uuid;not null;index:index_merchant_uuid" json:"merchantUUID"`
	AppUUID      object.NullString `gorm:"column:app_uuid;not null;index:index_app_uuid" json:"appUUID"`
}

merchant_to_app_config 数据表结构

type Model

type Model interface {
	GetTableName(needFull bool) string
	GetID() interface{}
	GetPrimaryKey() string
	GetForeignKey() string
}

type MyModel

type MyModel struct {
	ID   int    `gorm:"autoIncrement:true;unique; column:id; ->;<-:create" json:"-"`
	UUID string `gorm:"primaryKey;autoIncrement:false;unique; column:uuid; ->;<-:create " json:"uuid" sql:"index"`

	CreatedAt time.Time `gorm:"column:created_at; ->;<-:create " json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
}

func NewMyModel

func NewMyModel() *MyModel

func (*MyModel) GetForeignKey

func (mdl *MyModel) GetForeignKey() string

func (*MyModel) GetID

func (mdl *MyModel) GetID() interface{}

func (*MyModel) GetPrimaryKey

func (mdl *MyModel) GetPrimaryKey() string

type MyRelationship

type MyRelationship struct {
	ID        int       `gorm:"autoIncrement:true;unique; column:id; ->;<-:create" json:"-"`
	CreatedAt time.Time `gorm:"column:created_at; ->;<-:create " json:"createdAt"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
}

func NewMyRelationship

func NewMyRelationship() *MyRelationship

func (*MyRelationship) GetForeignKey

func (mdl *MyRelationship) GetForeignKey() string

func (*MyRelationship) GetID

func (mdl *MyRelationship) GetID() interface{}

func (*MyRelationship) GetPrimaryKey

func (mdl *MyRelationship) GetPrimaryKey() string

type Platform

type Platform struct {
	Model

	Name string `gorm:"column:name" json:"name"`
}

type User

type User struct {
	Id       int    `gorm:"json:id column:id"`
	Password string `gorm:"column:password json:password"`
	Locale   string `gorm:"column:locale json:locale"`
	UUID     string `gorm:"column:uuid" json:"uuid" primaryKey;autoIncrement:"false" sql:"index"`
}

func NewUser

func NewUser() *User

func (*User) TableName

func (*User) TableName() string

TableName overrides the table name used by User to `profiles`

func (*User) WhereIsValid

func (user *User) WhereIsValid(db *gorm.DB) *gorm.DB

func (*User) WhereUserName

func (user *User) WhereUserName(uuidOrPhone string) func(db *gorm.DB) *gorm.DB

*

  • Scope Where Conditions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL