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

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