互动
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.

44 lines
2.1 KiB

package models
import (
"time"
"git.ouxuan.net/tommy/osmanthuswine/src/core"
)
const VoteActivityHistoryTableName = TableNamePrefix + "new_vote_activity_history"
type NewVoteActivityHistory struct {
Id int `json:"id" xorm:"pk autoincr INT(11)"`
VoteActivityId int `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id') INT(11)"`
VoteActivityLadderId int `json:"vote_activity_ladder_id" xorm:"not null default(0) comment('投票活动对象') INT(11)"`
RehearsalId int `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
UserId int `json:"user_id" xorm:"not null default(0) comment('投票人') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') 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 Alias(t, name)
}
func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_ladder_id=? and "+
" rehearsal_id=? and arch_id=?", uid, lid, rid, archId).Exist(t)
}
func (t *NewVoteActivityHistory) ExistByVoteId(uid, vid, rid int, archId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_id=? and "+
" rehearsal_id=? and arch_id=?", uid, vid, rid, archId).Exist(t)
}
func (t *NewVoteActivityHistory) CountUser(uid, rid, vid int, archId interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and "+
" vote_activity_id=? and arch_id=?", uid, rid, vid, archId).Count(t)
}