db

package
v0.0.0-...-957e36a Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASYNC_TASK_IDLE = iota + 1
	ASYNC_TASK_RUNNING
	ASYNC_TASK_FAILED
	ASYNC_TASK_DONE
)
View Source
const (
	DM_TASK_STATUS_PAUSED = iota + 1
	DM_TASK_STATUS_RUNNING
	DM_TASK_STATUS_DONE
)
View Source
const (
	DM_DETAIL_STATUS_NOT_SEND = iota + 1
	DM_DETAIL_STATUS_FAIL
	DM_DETAIL_STATUS_DONE
)
View Source
const (
	EVENT_IDLE = iota + 1
	EVENT_CALCULATING
	EVENT_ERROR
	EVENT_READY
)
View Source
const (
	DB_SYSCONF_ADMIN_PASS = "admin_pass"
)
View Source
const (
	GORM_CTX_KEY gormCtxKey = "swe_ctx"
)

Variables

This section is empty.

Functions

func InitMySQL

func InitMySQL(dsn string) error

func InitSQLite

func InitSQLite(file string) error

Types

type AsyncTask

type AsyncTask struct {
	ID       int64  `gorm:"primaryKey;column:id"`
	Handler  string `gorm:"type:string;size:128;column:handler"`
	Param    string `gorm:"type:string;size:4096;column:param"`
	Status   int    `gorm:"column:status;index:idx_ast_status"`
	Schedule int64  `gorm:"column:schedule"`
}

func (AsyncTask) TableName

func (s AsyncTask) TableName() string

type AsyncTaskDAL

type AsyncTaskDAL struct{}

func GetAsyncTaskDAL

func GetAsyncTaskDAL() AsyncTaskDAL

func (AsyncTaskDAL) All

func (dal AsyncTaskDAL) All(ctx *swe.Context) ([]*AsyncTask, error)

func (AsyncTaskDAL) Get

func (dal AsyncTaskDAL) Get(ctx *swe.Context, id int64) (*AsyncTask, error)

func (AsyncTaskDAL) Put

func (dal AsyncTaskDAL) Put(ctx *swe.Context, value *AsyncTask) error

type DDInfo

type DDInfo struct {
	UID        int64  `gorm:"primaryKey;column:uid"`
	UserName   string `gorm:"type:string;size:256"`
	AccessCode string `gorm:"type:string;size:64;index:idx_dd_ac,unique;column:access_code"`
	PrivateKey string `gorm:"type:string;size:256;column:private_key"`
	PublicKey  string `gorm:"type:string;size:256;column:public_key"`
}

func (DDInfo) TableName

func (s DDInfo) TableName() string

type DDInfoDAL

type DDInfoDAL struct {
	// contains filtered or unexported fields
}

func GetDDInfoDAL

func GetDDInfoDAL() *DDInfoDAL

func (DDInfoDAL) BatchCreate

func (dal DDInfoDAL) BatchCreate(ctx *swe.Context, dd []DDInfo) error

func (*DDInfoDAL) BatchGet

func (dal *DDInfoDAL) BatchGet(ctx *swe.Context, uids []int64) (map[int64]*DDInfo, error)

func (*DDInfoDAL) GenerateAccessCode

func (dal *DDInfoDAL) GenerateAccessCode(ts, eventID, uid int64) string

func (*DDInfoDAL) Get

func (dal *DDInfoDAL) Get(ctx *swe.Context, uid int64) (*DDInfo, error)

func (*DDInfoDAL) GetByAccessCode

func (dal *DDInfoDAL) GetByAccessCode(ctx *swe.Context, code string) (*DDInfo, error)

func (*DDInfoDAL) GetPublicKeys

func (dal *DDInfoDAL) GetPublicKeys(ctx *swe.Context, uids []int64) (PublicKeyMap, error)

func (*DDInfoDAL) SetKeyPair

func (dal *DDInfoDAL) SetKeyPair(ctx *swe.Context, info *DDInfo) error

type DMDetail

type DMDetail struct {
	TaskID      int64  `gorm:"column:task_id;index:idx_dm_task"`
	RecieverUID int64  `gorm:"column:uid;index:idx_dm_task"`
	Content     string `gorm:"column:content;type:TEXT"`
	Status      int    `gorm:"column:status"`
	SendTime    int64  `gorm:"column:send_ts"`
	FailReason  string `gorm:"column:fail_reason;type:string;size:1024"`
}

func (DMDetail) TableName

func (s DMDetail) TableName() string

type DMTask

type DMTask struct {
	ID          int64  `gorm:"primaryKey;column:id"`
	RoomID      int64  `gorm:"column:room_id;index:idx_dmtask_room"`
	EventID     int64  `gorm:"column:event_id"`
	TaskName    string `gorm:"column:task_name;type:string;size:256"`
	MsgType     int    `gorm:"column:msg_type"`
	Content     string `gorm:"column:content;type:string;size:4096"`
	BatchMax    int    `gorm:"column:batch_max"`
	Status      int    `gorm:"column:status"`
	IntervalMin int    `gorm:"column:interval_min"`
	IntervalMax int    `gorm:"column:interval_max"`
	CreateTime  int64  `gorm:"create_time"`
}

func (DMTask) TableName

func (s DMTask) TableName() string

type DMTaskStat

type DMTaskStat struct {
	NotSend int
	Fail    int
	Done    int
}

type DirectMsgDAL

type DirectMsgDAL struct{}

func GetDirectMsgDAL

func GetDirectMsgDAL() DirectMsgDAL

func (DirectMsgDAL) BatchCreateDetails

func (dal DirectMsgDAL) BatchCreateDetails(ctx *swe.Context, details []DMDetail) error

func (DirectMsgDAL) Get

func (dal DirectMsgDAL) Get(ctx *swe.Context, id int64) (*DMTask, error)

func (DirectMsgDAL) GetByRoomID

func (dal DirectMsgDAL) GetByRoomID(ctx *swe.Context, id, roomID int64) (*DMTask, error)

func (DirectMsgDAL) LoadUnsentDetails

func (dal DirectMsgDAL) LoadUnsentDetails(ctx *swe.Context, id int64, limit int) ([]DMDetail, error)

func (DirectMsgDAL) Page

func (dal DirectMsgDAL) Page(ctx *swe.Context, roomID int64, offset, limit int) (int, []DMTask, error)

func (DirectMsgDAL) Put

func (dal DirectMsgDAL) Put(ctx *swe.Context, task *DMTask) error

func (DirectMsgDAL) Stats

func (dal DirectMsgDAL) Stats(ctx *swe.Context, id int64) (DMTaskStat, error)

func (DirectMsgDAL) UpdateDetailStatus

func (dal DirectMsgDAL) UpdateDetailStatus(ctx *swe.Context, id, uid int64, status int, reason string) error

func (DirectMsgDAL) UpdateStatus

func (dal DirectMsgDAL) UpdateStatus(ctx *swe.Context, id int64, status int) error

type GiftDAL

type GiftDAL struct{}

func GetGiftDAL

func GetGiftDAL() GiftDAL

func (GiftDAL) Infos

func (dal GiftDAL) Infos(ctx *swe.Context) (ret []GiftInfo, err error)

func (GiftDAL) Insert

func (dal GiftDAL) Insert(ctx *swe.Context, gift *GiftRecord) error

func (GiftDAL) Page

func (dal GiftDAL) Page(ctx *swe.Context, roomID, tsBegin, tsEnd int64, offset, limit int,
	uid int64, name string, giftID int64) (int, []GiftRecord, error)

func (GiftDAL) Range

func (dal GiftDAL) Range(ctx *swe.Context, roomID, tsBegin, tsEnd int64) ([]*GiftRecord, error)

func (GiftDAL) UpdateGiftInfo

func (dal GiftDAL) UpdateGiftInfo(ctx *swe.Context, id int64, name string, price int64) error

type GiftInfo

type GiftInfo struct {
	GiftID    int64  `gorm:"primaryKey;column:gift_id"`
	GiftName  string `gorm:"size:256"`
	GiftPrice int64
}

func (GiftInfo) TableName

func (s GiftInfo) TableName() string

type GiftRecord

type GiftRecord struct {
	BatchID    string `gorm:"type:string;size:1024;column:batch_id;primaryKey" json:"-"`
	RoomID     int64  `gorm:"index:idx_gift_room_time;column:room_id" json:"-"`
	SendTime   int64  `gorm:"index:idx_gift_room_time;column:send_time"`
	SenderUID  int64  `gorm:"column:sender_uid" json:"-"`
	SenderName string `gorm:"type:string;size:256;column:sender_name" json:"-"`
	GiftID     int64  `gorm:"column:gift_id"`
	GiftName   string `gorm:"type:string;size:256"`
	GiftPrice  int64
	GiftCount  int64 `gorm:"column:gift_count"`
}

func (GiftRecord) TableName

func (s GiftRecord) TableName() string

type MemberDAL

type MemberDAL struct{}

func GetMemberDal

func GetMemberDal() MemberDAL

func (MemberDAL) Insert

func (dal MemberDAL) Insert(ctx *swe.Context, roomID int64, ts int64, uid int64, name string, level, count int) error

func (MemberDAL) Page

func (dal MemberDAL) Page(ctx *swe.Context, roomID, tsBegin, tsEnd int64, offset, limit int,
	uid int64, name string, level []int) (int, []MembershipRecord, error)

func (MemberDAL) Range

func (dal MemberDAL) Range(ctx *swe.Context, roomID, tsBegin, tsEnd int64) ([]*MembershipRecord, error)

type MembershipRecord

type MembershipRecord struct {
	RoomID     int64  `gorm:"index:idx_member_room_time;column:room_id" json:"-"`
	SendTime   int64  `gorm:"index:idx_member_room_time;column:send_time"`
	SenderUID  int64  `gorm:"column:sender_uid" json:"-"`
	SenderName string `gorm:"type:string;size:256;column:sender_name" json:"-"`
	GuardLevel int    `gorm:"column:level"`
	Count      int
}

func (MembershipRecord) TableName

func (s MembershipRecord) TableName() string

type PublicKeyMap

type PublicKeyMap map[int64][]byte

type RewardEvent

type RewardEvent struct {
	ID            int64  `gorm:"primaryKey;column:id"`
	RoomID        int64  `gorm:"index:idx_re_room;column:room_id"`
	EventName     string `gorm:"type:string;size:256;column:name"`
	RewardContent string `gorm:"type:TEXT;column:content"`
	Conditions    string `gorm:"type:TEXT;column:conditions"`
	Hidden        int    `gorm:"column:hidden"`
	CreateTime    int64  `gorm:"index:idx_re_room;column:create_time"`
	Status        int    `gorm:"column:status"`
}

func (RewardEvent) TableName

func (s RewardEvent) TableName() string

type RewardEventDAL

type RewardEventDAL struct{}

func GetRewardEventDAL

func GetRewardEventDAL() RewardEventDAL

func (RewardEventDAL) BlockUser

func (dal RewardEventDAL) BlockUser(ctx *swe.Context, eventID, uid int64, block bool) (bool, error)

func (RewardEventDAL) ClearUsers

func (dal RewardEventDAL) ClearUsers(ctx *swe.Context, eventID int64) error

func (RewardEventDAL) Delete

func (dal RewardEventDAL) Delete(ctx *swe.Context, id, roomID int64) (int64, error)

func (RewardEventDAL) Exist

func (dal RewardEventDAL) Exist(ctx *swe.Context, id, roomID int64) (bool, error)

func (RewardEventDAL) Get

func (dal RewardEventDAL) Get(ctx *swe.Context, id int64) (*RewardEvent, error)

func (RewardEventDAL) GetByIDs

func (dal RewardEventDAL) GetByIDs(ctx *swe.Context, eventIDs []int64) ([]RewardEvent, error)

func (RewardEventDAL) GetByRoomID

func (dal RewardEventDAL) GetByRoomID(ctx *swe.Context, id, roomID int64) (*RewardEvent, error)

func (RewardEventDAL) Page

func (dal RewardEventDAL) Page(ctx *swe.Context, roomID int64, offset, limit int) (int, []RewardEvent, error)

func (RewardEventDAL) Put

func (dal RewardEventDAL) Put(ctx *swe.Context, item *RewardEvent) error

func (RewardEventDAL) PutUsers

func (dal RewardEventDAL) PutUsers(ctx *swe.Context, users []RewardUser) error

func (RewardEventDAL) SetStatus

func (dal RewardEventDAL) SetStatus(ctx *swe.Context, id int64, status int) error

func (RewardEventDAL) UpdateAddrInfo

func (dal RewardEventDAL) UpdateAddrInfo(ctx *swe.Context, uid, eventID int64, addr string) (int64, error)

func (RewardEventDAL) UpdateEventInfo

func (dal RewardEventDAL) UpdateEventInfo(ctx *swe.Context, id, roomID int64, name, content string, hidden int) error

func (RewardEventDAL) UserInfoByUIDAndEventID

func (dal RewardEventDAL) UserInfoByUIDAndEventID(ctx *swe.Context, uid, eventID int64) ([]RewardUser, error)

func (RewardEventDAL) UserPage

func (dal RewardEventDAL) UserPage(ctx *swe.Context, eventID int64, offset, limit int) (int, []RewardUser, error)

func (RewardEventDAL) UserRecords

func (dal RewardEventDAL) UserRecords(ctx *swe.Context, uid int64, offset, limit int) (int, []RewardUser, error)

func (RewardEventDAL) Users

func (dal RewardEventDAL) Users(ctx *swe.Context, eventID int64) ([]RewardUser, error)

type RewardUser

type RewardUser struct {
	EventID     int64  `gorm:"index:idx_ru_evt;column:event_id"`
	UID         int64  `gorm:"index:idx_ru_uid;column:uid"`
	UserName    string `gorm:"type:string;size:256;column:user_name"`
	Time        int64  `gorm:"column:ts"`
	Blocked     int    `gorm:"column:block"`
	Columns     string `gorm:"type:TEXT;column:cols"`
	AddressInfo string `gorm:"type:string;size:4096;column:address_info"`
}

func (RewardUser) TableName

func (s RewardUser) TableName() string

type SCDal

type SCDal struct{}

func GetSCDal

func GetSCDal() SCDal

func (SCDal) Insert

func (dal SCDal) Insert(ctx *swe.Context, roomID int64, ts int64, uid int64, name string, price int64, content string, bgColor, fontColor string) error

func (SCDal) Page

func (dal SCDal) Page(ctx *swe.Context, roomID, tsBegin, tsEnd int64, offset, limit int,
	uid int64, name, content string) (int, []SuperChatRecord, error)

func (SCDal) Range

func (dal SCDal) Range(ctx *swe.Context, roomID, tsBegin, tsEnd int64) ([]*SuperChatRecord, error)

type Streamer

type Streamer struct {
	RoomID       int64  `gorm:"primaryKey;column:room_id"`
	StreamerName string `gorm:"type:string;size:256"`
	AccountName  string `gorm:"type:string;size:256;index:idx_accname,unique;column:account_name"`
	PrivateKey   string `gorm:"type:string;size:256;column:private_key"`
	PublicKey    string `gorm:"type:string;size:256;column:public_key"`
}

func (Streamer) TableName

func (s Streamer) TableName() string

type StreamerDAL

type StreamerDAL struct{}

func GetStreamerDAL

func GetStreamerDAL() StreamerDAL

func (StreamerDAL) All

func (dal StreamerDAL) All(ctx *swe.Context) ([]Streamer, error)

func (StreamerDAL) Delete

func (dal StreamerDAL) Delete(ctx *swe.Context, id int64) (int64, error)

func (StreamerDAL) Find

func (dal StreamerDAL) Find(ctx *swe.Context, id int64) (*Streamer, error)

func (StreamerDAL) FindByAccount

func (dal StreamerDAL) FindByAccount(ctx *swe.Context, account string) (*Streamer, error)

func (StreamerDAL) FindByRoomIDs

func (dal StreamerDAL) FindByRoomIDs(ctx *swe.Context, roomIDs []int64) ([]Streamer, error)

func (StreamerDAL) Insert

func (dal StreamerDAL) Insert(ctx *swe.Context, data *Streamer, upsert bool) (int64, error)

func (StreamerDAL) Page

func (dal StreamerDAL) Page(ctx *swe.Context, offset, limit int) (int, []Streamer, error)

func (StreamerDAL) UpdatePrivateKey

func (dal StreamerDAL) UpdatePrivateKey(ctx *swe.Context, id int64, b64EncPriKey string) error

type SuperChatRecord

type SuperChatRecord struct {
	RoomID     int64  `gorm:"index:idx_sc_room_time;column:room_id" json:"-"`
	SendTime   int64  `gorm:"index:idx_sc_room_time;column:send_time"`
	SenderUID  int64  `gorm:"column:sender_uid" json:"-"`
	SenderName string `gorm:"type:string;size:256;column:sender_name" json:"-"`
	Price      int64
	Content    string `gorm:"type:string;size:1024;column:content"`
	BgColor    string `gorm:"type:string;size:32"`
	FontColor  string `gorm:"type:string;size:32"`
}

func (SuperChatRecord) TableName

func (s SuperChatRecord) TableName() string

type SysConfig

type SysConfig struct {
	Key   string `gorm:"type:string;size:1024;column:key;primaryKey"`
	Value string `gorm:"type:string;size:1024;column:value"`
}

func (SysConfig) TableName

func (s SysConfig) TableName() string

type SysConfigDAL

type SysConfigDAL struct{}

func GetSysConfigDAL

func GetSysConfigDAL() SysConfigDAL

func (SysConfigDAL) EncodeAdminPassword

func (dal SysConfigDAL) EncodeAdminPassword(pass string) string

func (SysConfigDAL) GetConfig

func (dal SysConfigDAL) GetConfig(ctx *swe.Context, key string) (string, error)

func (SysConfigDAL) SetConfig

func (dal SysConfigDAL) SetConfig(ctx *swe.Context, key, value string) error

Jump to

Keyboard shortcuts

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