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"` VoteActivityId int64 `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id')"` VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default('') comment('投票活动对象')"` RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式')"` UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人')"` IsDelete bool `json:"-" xorm:"default(0) comment('删除')"` CreatedAt time.Time `json:"-" 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) }