dao

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreditLogTypeRegitser = iota + 1
	CreditLogTypeInviteOtherRegitser
	CreditLogTypeBuyProduct
)
View Source
const (
	CreditLockStatusLocked = iota + 1
	CreditLockStatusDeducted
	CreditLockStatusReleased
)

Variables

View Source
var (
	ErrRecordChangedCuncurrently = errors.New("记录已被并发修改")
)

Functions

func InitTables

func InitTables(db *egorm.Component) error

Types

type Credit

type Credit struct {
	Id                 int64 `gorm:"primaryKey;autoIncrement;comment:积分表自增ID"`
	UserId             int64 `gorm:"not null;uniqueIndex:unq_user_id,comment:用户ID"`
	TotalCredits       int64 `gorm:"not null;default 0;comment:积分总数"`
	LockedTotalCredits int64 `gorm:"not null;default 0;comment:锁定的积分总数"`
	Version            int64 `gorm:"not null;default 1;comment:版本号"`
	Ctime              int64
	Utime              int64
}

type CreditDAO

type CreditDAO interface {
	Create(ctx context.Context, c Credit, l CreditLog) error
	Update(ctx context.Context, c Credit, l CreditLog) error
	CreateCreditLock(ctx context.Context, c CreditLock) error
	FindByUID(ctx context.Context, uid int64) (Credit, error)
}

func NewGORMCreditDAO

func NewGORMCreditDAO(db *egorm.Component) CreditDAO

type CreditLock

type CreditLock struct {
	Id     int64 `gorm:"primaryKey;autoIncrement;comment:积分预扣记录表自增ID"`
	UserId int64 `gorm:"not null;index:idx_user_id,comment:用户ID"`
	Amount int64 `gorm:"not null;comment:预扣积分数"`
	Status int64 `gorm:"type:tinyint unsigned;not null;default:1;comment:预扣状态 1=预扣中 2=已扣减 3=已释放"`
	Ctime  int64
	Utime  int64
}

type CreditLog

type CreditLog struct {
	Id            int64  `gorm:"primaryKey;autoIncrement;comment:积分流水表自增ID"`
	UserId        int64  `gorm:"not null;index:idx_user_id,comment:用户ID"`
	CreditChange  int64  `gorm:"not null;comment:积分变动数量,正数为获得,负数为消耗"`
	CreditBalance int64  `gorm:"not null;comment:变动后的积分余额"`
	Desc          string `gorm:"type:varchar(255);not null;comment:积分流水描述"`
	Type          int64  `` /* 146-byte string literal not displayed */
	Ctime         int64
	Utime         int64
}

Jump to

Keyboard shortcuts

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