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

61 lines
2.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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 SignHistoryTN = TableNamePrefix + "sign_history"
  7. //签到历史表
  8. type SignHistory struct {
  9. Id int64 `json:"id" xorm:"pk autoincr comment('主键') INT(11)"`
  10. AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
  11. ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
  12. RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0正式') INT(11)"`
  13. SignRuleId int64 `json:"sign_rule_id" xorm:"not null default 0 comment('sign_up表id') INT(11)"`
  14. Type int `json:"type" xorm:"not null default 0 comment('普通签到') TINYINT(1)"`
  15. UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户表id') TINYINT(11)"`
  16. SignMethod int `json:"sign_method" xorm:"not null default 0 comment('1扫码签到2实名签到3人脸签到') TINYINT(1)"`
  17. Content string `json:"content" xorm:"json comment('提交审核的内容') TEXT"`
  18. Nickname string `json:"nickname" xorm:"not null default('') comment('微信昵称') VARCHAR(128)"`
  19. Status int64 `json:"status" xorm:"not null default 0 comment('是否通过审核[0未通过审核1申请审核2通过审核]') TINYINT(1)"`
  20. IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"`
  21. CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
  22. UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"`
  23. }
  24. func (t *SignHistory) TableName() string {
  25. return SignHistoryTN
  26. }
  27. func (t *SignHistory) GetByUserId(aid, uid, rid, arid int64) (bool, error) {
  28. return core.GetXormAuto().Where("is_delete=0 and activity_id=? and user_id=? and "+
  29. "rehearsal_id=? and area_id=?", aid, uid, rid, arid).Get(t)
  30. }
  31. func (t *SignHistory) Count(signUpId, activityId, rehearsalId interface{}) (int64, error) {
  32. // 签到人数
  33. return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=? and status=2",
  34. signUpId, rehearsalId, activityId).Count(t)
  35. }
  36. func (t *SignHistory) UpdateById(ids interface{}, fields ...string) (err error) {
  37. if len(fields) > 0 {
  38. _, err = core.GetXormAuto().In("id", ids).Cols(fields...).Update(t)
  39. } else {
  40. _, err = core.GetXormAuto().In("id", ids).AllCols().Update(t)
  41. }
  42. return err
  43. }
  44. func (t *SignHistory) Insert() error {
  45. _, err := core.GetXormAuto().InsertOne(t)
  46. return err
  47. }
  48. func GetApplyRealSigns(aid interface{}, rid interface{}) ([]*SignHistory, error) {
  49. results := make([]*SignHistory, 0)
  50. err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=1",
  51. aid, rid).Asc("updated_at").Find(&results)
  52. return results, err
  53. }