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

5 years ago
5 years ago
5 years ago
  1. package models
  2. import (
  3. "github.com/ouxuanserver/osmanthuswine/src/core"
  4. "time"
  5. )
  6. const VoteActivityHistoryTableName = TableNamePrefix + "new_vote_activity_history"
  7. type NewVoteActivityHistory struct {
  8. Id int64 `json:"id" xorm:"pk autoincr INT(11)"`
  9. VoteActivityId int64 `json:"vote_activity_id" xorm:"not null default(0) comment('投票活动id') INT(11)"`
  10. VoteActivityLadderId int64 `json:"vote_activity_ladder_id" xorm:"not null default(0) comment('投票活动对象') INT(11)"`
  11. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') INT(11)"`
  12. UserId int64 `json:"user_id" xorm:"not null default(0) comment('投票人') INT(11)"`
  13. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
  14. CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间')"`
  15. UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间')"`
  16. }
  17. func (t *NewVoteActivityHistory) TableName() string {
  18. return VoteActivityHistoryTableName
  19. }
  20. func (t *NewVoteActivityHistory) Alias(name string) string {
  21. return AliasTableName(t, name)
  22. }
  23. func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int64) (bool, error) {
  24. return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_ladder_id=? and "+
  25. " rehearsal_id=?", uid, lid, rid).Exist(t)
  26. }
  27. func (t *NewVoteActivityHistory) ExistByVoteId(uid, vid, rid int64) (bool, error) {
  28. return core.GetXormAuto().Where("is_delete=0 and user_id=? and vote_activity_id=? and rehearsal_id=?",
  29. uid, vid, rid).Exist(t)
  30. }
  31. func (t *NewVoteActivityHistory) CountUser(uid, rid, vid int64) (int64, error) {
  32. return core.GetXormAuto().Where("is_delete=0 and user_id=? and rehearsal_id=? and vote_activity_id=?",
  33. uid, rid, vid).Count(t)
  34. }