database

package
v0.0.0-...-0dfa7a2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllModels = []interface{}{
	&MemberInfo{},
	&AttackRecord{},
	&Queue{},
	&SysInputLimit{},
	&SysBossInfo{},
}
View Source
var ErrDataExceeded = errors.New("数据超限")
View Source
var ErrDataExists = errors.New("表中已存在数据")
View Source
var ErrDataNotUnique = errors.New("数据不唯一")

Functions

func CountMemberInfoByGroup

func CountMemberInfoByGroup(grpID int) (int64, error)

Return row counts in member_infos

func Enqueue

func Enqueue(grpID int, userID int, joinBoss int, joinType int, joinRound int) error

Add queue

func GetQueueCountByUserID

func GetQueueCountByUserID(grpID int, userID int) ([]int, error)

Return rows by giving userID

func InitDB

func InitDB(path string) error

本函数用于群组第一次使用时创建全新的数据库, 并设定基础参数

func IsMemberInfoExists

func IsMemberInfoExists(grpID int, memberID int) (bool, error)

Check if member in the MemberInfo table

func JoinMemberInfo

func JoinMemberInfo(grpID int, memberID int, memberName string) (int64, error)

Add a member to member_infos

func QuitQueue

func QuitQueue(grpID int, userID int, boss int) error

Quit queue by userID and provided boss, if boss = 0 then quit all queue

func ResetAll

func ResetAll(grpid int) error

本函数用于应对新一轮公会战时, 重置包括成员列表在内的所有数据

func ResetRecords

func ResetRecords(grpid int) error

本函数用于应对新一轮公会战时, 重置伤害记录和队列

Types

type AttackRecord

type AttackRecord struct {
	RecID    int `gorm:"primaryKey"`
	MemberID int
	Damage   int
	RecRound int
	RecBoss  int
	RecType  int
	RecTime  time.Time
	Uploader int
}

type MemberInfo

type MemberInfo struct {
	MemberID   int `gorm:"primaryKey"`
	MemberName string
}

func GetMemberInfoByGroup

func GetMemberInfoByGroup(grpID int) ([]MemberInfo, error)

Get all rows in member_infos and return a struct array

type Queue

type Queue struct {
	MemberID  int
	JoinBoss  int `gorm:"primaryKey"`
	JoinSeq   int `gorm:"primaryKey"`
	JoinType  int
	JoinRound int // JoinRound will only need when sos
	JoinTime  time.Time
}

type QueueWithUsername

type QueueWithUsername struct {
	MemberID   int
	JoinBoss   int
	JoinSeq    int
	JoinType   int
	JoinRound  int
	JoinTime   time.Time
	MemberName string
}

func GetQueue

func GetQueue(grpID int, bossCode int) ([]QueueWithUsername, error)

Get queue, while bossCode invalid, query all bosses

type SysBossInfo

type SysBossInfo struct {
	Boss     int `gorm:"primaryKey"`
	InitHP   int
	RoundMin int `gorm:"primaryKey"`
	RoundMax int `gorm:"primaryKey"`
	SortFlag int
}

type SysInputLimit

type SysInputLimit struct {
	InputType  string `gorm:"primaryKey"`
	InputValue int
}

type TempProgress

type TempProgress struct {
	Boss     int
	Round    int
	Damage   int
	HP       int
	RoundMin int
	RoundMax int
}

Progress data, not in database

func GetProgress

func GetProgress(grpID int) ([]TempProgress, error)

Return progress slice contains all 5 bosses, the progress should as close to in-game as possible.

Jump to

Keyboard shortcuts

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