model

package
v0.0.0-...-6873a34 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Conn *gorm.DB

定义全局 DB 连接

Functions

func Close

func Close()

func NewMysql

func NewMysql()

NewMysql 初始化数据库连接器。 (单例模式)

func UpdateVoteCount

func UpdateVoteCount(id int64, voteId int64) error

UpdateVoteCount 更新 VoteOpt 表计数器

Types

type User

type User struct {
	Id          int64     `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL" form:"id" json:"id"`
	Name        string    `gorm:"column:name;default:NULL" form:"name" json:"name"`
	Password    string    `gorm:"column:password;default:NULL" form:"password" json:"password"`
	CreatedTime time.Time `gorm:"column:created_time;default:NULL" form:"createdTime" json:"createdTime"`
	UpdatedTime time.Time `gorm:"column:updated_time;default:NULL" form:"updatedTime" json:"updatedTime"`
}

func GetUser

func GetUser(user *User) (*User, error)

GetUser 查询用户数据 https://gorm.io/docs/query.html

func (*User) TableName

func (u *User) TableName() string

type Vote

type Vote struct {
	Id          int64     `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL"`
	Title       string    `gorm:"column:title;default:NULL"`
	Type        int32     `gorm:"column:type;default:NULL;comment:'0 for single, 1 for multiple choice'"`
	Status      int32     `gorm:"column:status;default:NULL;comment:'0 for normal, 1 for expired'"`
	UserId      int64     `gorm:"column:user_id;default:NULL;comment:'who created'"`
	ExpiredIn   int64     `gorm:"column:expired_in;default:NULL"`
	CreatedTime time.Time `gorm:"column:created_time;default:NULL"`
	UpdatedTime time.Time `gorm:"column:updated_time;default:NULL"`
}

func GetVote

func GetVote(id int64) (Vote, error)

GetVote 根据 ID 查询数据

func GetVotes

func GetVotes() ([]Vote, error)

GetVotes 获取投票列表

func (*Vote) TableName

func (v *Vote) TableName() string

type VoteOpt

type VoteOpt struct {
	Id          int64     `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL"`
	Name        string    `gorm:"column:name;default:NULL;comment:'选项名称'"`
	Count       int32     `gorm:"column:count;default:NULL;comment:'选项投票计数器'"`
	VoteId      int64     `gorm:"column:vote_id;default:NULL;comment:'绑定到的投票单'"`
	CreatedTime time.Time `gorm:"column:created_time;default:NULL"`
	UpdatedTime time.Time `gorm:"column:updated_time;default:NULL"`
}

func GetVoteOptsByVoteId

func GetVoteOptsByVoteId(voteId int64) ([]VoteOpt, error)

GetVoteOptsByVoteId 根据投票 ID 查询选项

func (*VoteOpt) TableName

func (v *VoteOpt) TableName() string

type VoteOptUser

type VoteOptUser struct {
	Id          int64     `gorm:"column:id;primary_key;NOT NULL"`
	VoteId      int64     `gorm:"column:vote_id;default:NULL;comment:'表单ID'"`
	UserId      int64     `gorm:"column:user_id;default:NULL;comment:'投票用户ID'"`
	VoteOptId   int64     `gorm:"column:vote_opt_id;default:NULL;comment:'选项ID'"`
	CreatedTime time.Time `gorm:"column:created_time;default:NULL"`
	UpdatedTime time.Time `gorm:"column:updated_time;default:NULL"`
}

func (*VoteOptUser) TableName

func (v *VoteOptUser) TableName() string

Jump to

Keyboard shortcuts

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