model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package model 数据库操作

Package model 数据库操作

Package model 玩家操作

Package model 服务器数据操作

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(path string) error

Init 数据库初始化

func Open

func Open(path string) (db *gorm.DB, err error)

Open 打开数据库

Types

type Admin

type Admin struct {
	QQID      int64 `gorm:"primary_key;auto_increment:false"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Admin 管理表

func NewAdmin added in v1.0.2

func NewAdmin(qid int64) *Admin

NewAdmin creates a new Admin

func (*Admin) Create added in v1.0.2

func (a *Admin) Create(db *gorm.DB) error

Create 创建一个新的 Admin 记录

func (*Admin) DeleteByQQID added in v1.0.2

func (a *Admin) DeleteByQQID(db *gorm.DB) error

DeleteByQQID 根据 QQID 删除 Admin 记录

func (*Admin) GetByQQID added in v1.0.2

func (a *Admin) GetByQQID(db *gorm.DB) (*Admin, error)

GetByQQID 根据 QQID 获取 Admin 记录

func (*Admin) Update added in v1.0.2

func (a *Admin) Update(db *gorm.DB) error

Update 更新 Admin 记录

type Group

type Group struct {
	GroupID   int64 `gorm:"primary_key;auto_increment:false"`
	Owner     int64
	Servers   []Server `gorm:"many2many:group_servers"`
	Admins    []Admin  `gorm:"many2many:group_admins"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Group 群组表

func NewGroup added in v1.0.2

func NewGroup(groupID int64) *Group

NewGroup creates a new Group

func (*Group) Create added in v1.0.2

func (g *Group) Create(db *gorm.DB) error

Create 创建一个新的 Group 记录

func (*Group) DeleteAdmin added in v1.0.2

func (g *Group) DeleteAdmin(db *gorm.DB, adminQQ int64) error

DeleteAdmin 删除联表中的admin

func (*Group) DeleteByID added in v1.0.2

func (g *Group) DeleteByID(db *gorm.DB) error

DeleteByID 根据 GroupID 删除 Group 记录

func (*Group) DeleteServer added in v1.0.2

func (g *Group) DeleteServer(db *gorm.DB, gameID string) error

DeleteServer 删除联表中的server

func (*Group) GetByAlias added in v1.1.0

func (g *Group) GetByAlias(db *gorm.DB, alias string) (*Server, error)

GetByAlias 根据别名获取 Server 记录

func (*Group) GetByID added in v1.0.2

func (g *Group) GetByID(db *gorm.DB) (*Group, error)

GetByID 根据 GroupID 获取 Group 记录

func (*Group) IsAdmin added in v1.0.2

func (g *Group) IsAdmin(db *gorm.DB, qid int64) bool

IsAdmin 检查是否为该服务器群管理

func (*Group) IsOwner added in v1.0.2

func (g *Group) IsOwner(db *gorm.DB, qid int64) bool

IsOwner 检查是否为服务器拥有者

func (*Group) Update added in v1.0.2

func (g *Group) Update(db *gorm.DB) error

Update 更新 Group 记录

注意不能修改为各类型零值

type Player

type Player struct {
	CreatedAt   time.Time
	UpdatedAt   time.Time
	PersonalID  string // pid
	Qid         int64  `gorm:"primary_key;auto_increment:false"` // QQ号
	DisplayName string // 玩家id
}

Player 玩家表

func (*Player) Create

func (player *Player) Create(db *gorm.DB) error

Create 创建玩家条目

func (*Player) Delete

func (player *Player) Delete(db *gorm.DB) error

Delete 删除玩家信息

func (*Player) GetByName

func (player *Player) GetByName(db *gorm.DB, name string) (*Player, error)

GetByName 使用玩家名查询玩家表

func (*Player) GetByQID

func (player *Player) GetByQID(db *gorm.DB, qid int64) (*Player, error)

GetByQID 使用qq号查询玩家表

func (*Player) Update

func (player *Player) Update(db *gorm.DB) error

Update 使用Updates方法更新玩家信息,0值不更新

type Server

type Server struct {
	GameID      string `gorm:"primary_key"`
	ServerID    string
	PGID        string
	NameInGroup string
	ServerName  string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Server 服务器表

func NewServer added in v1.0.2

func NewServer(gameID string) *Server

NewServer creates a new Server

func (*Server) Create added in v1.0.2

func (s *Server) Create(db *gorm.DB) error

Create 创建一个新的 Server 记录

func (*Server) DeleteByGameID added in v1.0.2

func (s *Server) DeleteByGameID(db *gorm.DB) error

DeleteByGameID 根据 GameID 删除 Server 记录

func (*Server) GetByGameID added in v1.0.2

func (s *Server) GetByGameID(db *gorm.DB) (*Server, error)

GetByGameID 根据 GameID 获取 Server 记录

func (*Server) Update added in v1.0.2

func (s *Server) Update(db *gorm.DB) error

Update 更新 Server 记录

Jump to

Keyboard shortcuts

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