model

package
v0.0.0-...-61dbfe3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCasbin

func AddCasbin(roleId int, path, method string) error

func AddUser

func AddUser(userName, password string) error

func AddUsr

func AddUsr(data map[string]interface{}) error

func AddVoucher

func AddVoucher(data map[string]interface{}) error

AddVoucher 添加票券

func DeleteVoucher

func DeleteVoucher(voucherId int) error

DeleteVoucher 删除票券

func EditVoucher

func EditVoucher(voucherId int, data map[string]interface{}) error

EditVoucher 编辑票券

func ExistByEmail

func ExistByEmail(email string) (bool, error)

ExistByEmail checks if there is a user with same email

func ExistByPhoneNumber

func ExistByPhoneNumber(phoneNumber string) (bool, error)

ExistByPhoneNumber checks if there is a user with same phonenumber

func ExistByUserId

func ExistByUserId(userId int) (bool, error)

ExistByUserId checks if there is a user with same user_id

func ExistByUserName

func ExistByUserName(userName string) (bool, error)

ExistByUserName checks if there is a user with same user_name

func ExistCasbin

func ExistCasbin(roleId int, path, method string) (bool, error)

func ExistVoucherById

func ExistVoucherById(voucherId int) (bool, error)

ExistVoucherById checks if an voucher exists based on VoucherId

func GetCasbinList

func GetCasbinList(roleId int) [][]string

func ParamsMatch

func ParamsMatch(fullNameKey1 string, key2 string) bool

@function: ParamsMatch @description: 自定义规则函数 @param: fullNameKey1 string, key2 string @return: bool

func ParamsMatchFunc

func ParamsMatchFunc(args ...interface{}) (interface{}, error)

@function: ParamsMatchFunc @description: 自定义规则函数 @param: args ...interface{} @return: interface{}, error

func Setup

func Setup()

Setup initializes the database instance

func SyncUserVoucher

func SyncUserVoucher(userId, voucherId int) error

Types

type BaseModel

type BaseModel struct {
	CreatedBy string     `json:"created_by" binding:"-"`
	CreatedAt time.Time  `json:"created_at" binding:"-"`
	UpdatedBy string     `json:"updated_by" binding:"-"`
	UpdatedAt time.Time  `json:"updated_at" binding:"-"`
	DeletedAt *time.Time `json:"deleted_at" sql:"index" binding:"-"`
	Remark    string     `json:"remark"`
}

type CasbinModel

type CasbinModel struct {
	PType  string `json:"p_type" gorm:"column:p_type" description:"策略类型"`
	RoleId int    `json:"role_id" gorm:"column:v0" description:"角色ID"`
	Path   string `json:"path" gorm:"column:v1" description:"api路径"`
	Method string `json:"method" gorm:"column:v2" description:"访问方法"`
}

func (*CasbinModel) TableName

func (c *CasbinModel) TableName() string

func (*CasbinModel) Update

func (c *CasbinModel) Update(db *gorm.DB, values interface{}) error

type SysConfig

type SysConfig struct {
	BaseModel
	ConfigId    int
	ConfigName  string
	ConfigKey   string
	ConfigValue string
	ConfigType  string
}

type SysDept

type SysDept struct {
	BaseModel
	DeptId    int
	ParentId  int
	Ancestors string
	DeptName  string
	OrderNum  int
	Leader    string
	Phone     string
	Email     string
	Status    string
	DelFlag   string
}

type SysDictData

type SysDictData struct {
	BaseModel
	DictDataId int
	DictSort   int
	DictLabel  string
	DictValue  string
	DictType   string
	CssClass   string
	ListClass  string
	IsDefault  string
	Status     string
}

type SysDictType

type SysDictType struct {
	BaseModel
	DictTypeId int
	DictName   string
	DictType   string
	Status     string
}

type SysMenu

type SysMenu struct {
	BaseModel
	MenuId    int
	ParentId  int
	MenuName  string
	MenuType  string
	OrderNum  int
	Path      string
	Component string
	Query     string
	IsFrame   int
	IsCache   int
	Visible   string
	Status    string
	Perms     string
	Icon      string
}

type SysRole

type SysRole struct {
	BaseModel
	RoleId            int
	RoleName          string
	RoleKey           string
	RoleSort          int
	DataScope         string
	MenuCheckStrictly int
	DeptCheckStrictly int
}

type SysUser

type SysUser struct {
	BaseModel
	UserId      int       `gorm:"type:bigint(32);primary_key;auto_increment"`
	DeptId      int       `gorm:"type:bigint(32)"`
	UserName    string    `gorm:"type:varchar(32)"`
	NickName    string    `gorm:"type:varchar(32)"`
	UserType    string    `gorm:"type:varchar(2)"`
	Email       string    `gorm:"type:varchar(64)"`
	PhoneNumber string    `gorm:"type:varchar(15)"`
	Sex         int       `gorm:"type:int(1)"`
	Avatar      string    `gorm:"type:varchar(128)"`
	Password    string    `gorm:"type:varchar(64)"`
	Status      string    `gorm:"type:char(1)"`
	LoginIP     string    `gorm:"type:varchar(128)"`
	LoginDate   time.Time `gorm:"type:datetime"`
}

func FindUserByUserNameAndPassword

func FindUserByUserNameAndPassword(userName, password string) (*SysUser, error)

func (*SysUser) TableName

func (this *SysUser) TableName() string

TableName 自定义表名

type UserVoucher

type UserVoucher struct {
	UserId    int
	VoucherId int
}

func (*UserVoucher) TableName

func (this *UserVoucher) TableName() string

TableName 自定义表名

type Voucher

type Voucher struct {
	BaseModel
	VoucherId         int       `gorm:"primary_key;auto_increment"`   // 票券ID
	MerchantId        int       `gorm:"type:int(20); not null"`       // 票券商家ID
	VoucherName       string    `gorm:"type:varchar(64); not null"`   // 票券名称
	VoucherCode       string    `gorm:"type:varchar(64); not null"`   // 票券编码
	VoucherType       int       `gorm:"type:int(2); not null"`        // 票券类型
	FullLimit         float32   `gorm:"type:decimal(8, 2); not null"` // 满额限制
	DiscountAmount    float32   `gorm:"type:decimal(8, 2); not null"` // 折扣金额
	UseRangeType      int       `gorm:"type:int(2); not null"`        // 使用范围类型
	UseRangeId        int       `gorm:"type:int(2); not null"`        // 使用范围ID
	PublishCount      int       `gorm:"type:int(8); not null"`        // 发行数量
	UseCount          int       `gorm:"type:int(8); not null"`        // 使用数量
	ReceiveCount      int       `gorm:"type:int(8); not null"`        // 领取数量
	StartPeriod       time.Time `gorm:"type:datatime; not null"`      // 其实有效期
	EndPeriod         time.Time `gorm:"type:datatime; not null"`      // 结束有效期
	VoucherStatus     int       `gorm:"type:int(2); not null"`        // 票券状态
	AvailablePlatform int       `gorm:"type:int(2); not null"`        // 可用平台
}

Voucher 票券

func GetVoucher

func GetVoucher(voucherId int) (*Voucher, error)

GetVoucher 获取票券

func GetVouchers

func GetVouchers() ([]*Voucher, error)

GetVouchers 获取所有票券

func GetVouchersByPage

func GetVouchersByPage(pageNum, pageSize int, maps interface{}) ([]*Voucher, error)

GetVouchersByPage 根据分页条件获取所有票券

func (*Voucher) TableName

func (this *Voucher) TableName() string

TableName 自定义表名

Jump to

Keyboard shortcuts

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