You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.7 KiB
36 lines
1.7 KiB
package models
|
|
|
|
import (
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
"time"
|
|
)
|
|
|
|
const VoteActivityLadderTableName = TableNamePrefix + "new_vote_activity_ladder"
|
|
|
|
type NewVoteActivityLadder struct {
|
|
Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"`
|
|
VoteActivityId int64 `json:"vote_activity_id" xorm:"not null comment('投票轮次的id') INT(11)"`
|
|
VoteNumber int64 `json:"vote_number" xorm:"not null comment('投票的初始的票数') INT(11)"`
|
|
VoteMember string `json:"vote_member" xorm:"not null comment('投票的人员名字') VARCHAR(255)"`
|
|
MemberImg string `json:"member_img" xorm:"not null comment('被投票人员的图片')"`
|
|
TotalNumber int64 `json:"total_number" xorm:"not null default 0 comment('投票总数') INT(11)"`
|
|
IsVote bool `json:"is_vote" xorm:"-" description:"是否被投票"`
|
|
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
|
|
CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
|
|
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
|
|
}
|
|
|
|
func (t *NewVoteActivityLadder) TableName() string {
|
|
return VoteActivityLadderTableName
|
|
}
|
|
|
|
func (t *NewVoteActivityLadder) Incr(id, number int64) (int64, error) {
|
|
return core.GetXormAuto().Where("is_delete=0 and id=?", id).Incr("total_number", number).Update(t)
|
|
}
|
|
|
|
func GetNewVoteTopByVoteActivityId(voteId interface{}, limit int) ([]*NewVoteActivityLadder, error) {
|
|
ladders := make([]*NewVoteActivityLadder, 0)
|
|
err := core.GetXormAuto().Where("is_delete=0 and vote_activity_id=?", voteId).
|
|
Desc("total_number").Asc("updated_at").Limit(limit).Find(&ladders)
|
|
return ladders, err
|
|
}
|