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.
42 lines
1.8 KiB
42 lines
1.8 KiB
package models
|
|
|
|
import (
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
"time"
|
|
)
|
|
|
|
const VoteActivityHistoryTableName = TableNamePrefix + "new_vote_activity_history"
|
|
|
|
type NewVoteActivityHistory struct {
|
|
Id int64 `json:"id" xorm:"pk autoincr INT(11)"`
|
|
VoteActivityId int64 `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id') INT(11)"`
|
|
VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default(0) comment('投票活动对象') INT(11)"`
|
|
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
|
|
UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人') INT(11)"`
|
|
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
|
|
CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间')"`
|
|
UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间')"`
|
|
}
|
|
|
|
func (t *NewVoteActivityHistory) TableName() string {
|
|
return VoteActivityHistoryTableName
|
|
}
|
|
|
|
func (t *NewVoteActivityHistory) Alias(name string) string {
|
|
return AliasTableName(t, name)
|
|
}
|
|
|
|
func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int64) (bool, error) {
|
|
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_ladder_id=? and "+
|
|
" rehearsal_id=?", uid, lid, rid).Exist(t)
|
|
}
|
|
|
|
func (t *NewVoteActivityHistory) ExistByVoteId(uid, vid, rid int64) (bool, error) {
|
|
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_id=? and rehearsal_id=?",
|
|
uid, vid, rid).Exist(t)
|
|
}
|
|
|
|
func (t *NewVoteActivityHistory) CountUser(uid, rid, vid int64) (int64, error) {
|
|
return core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=?",
|
|
uid, rid, vid).Count(t)
|
|
}
|