activity.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // Activity 活动表
  7. type Activity struct {
  8. ActivityId int `orm:"column(activity_id);pk" description:"活动ID"`
  9. FirstActivityTypeId int `description:"第一级的活动类型ID"`
  10. FirstActivityTypeName string `description:"第一级的活动类型名称"`
  11. ActivityTypeId int `description:"活动类型ID"`
  12. ActivityTypeName string `description:"活动类型名称"`
  13. ChartPermissionId int `description:"对应的权限id,表chart_permission中id"`
  14. ChartPermissionName string `description:"对应的权限名称,表chart_permission中name"`
  15. ActivityName string `description:"活动标题"`
  16. StartTime time.Time `description:"活动开始时间"`
  17. EndTime time.Time `description:"活动结束时间"`
  18. Speaker string `description:"主讲人"`
  19. SpeakerHeadPic string `description:"主讲人头像"`
  20. SpeakerBackgroundPic string `description:"主讲人背景图"`
  21. MainlandTel string `description:"大陆拨入"`
  22. HongKongTel string `description:"香港拨入"`
  23. TaiwanTel string `description:"台湾拨入"`
  24. AmericaTel string `description:"美国拨入"`
  25. SingaporeTel string `description:"新加坡拨入"`
  26. ParticipationCode string `description:"参会密码"`
  27. LinkParticipants string `description:"参会链接"`
  28. IsLimitPeople int8 `description:"是否限制人数 1是,0否"`
  29. LimitPeopleNum int `description:"限制人数数量"`
  30. ReportLink string `description:"报告链接"`
  31. City string `description:"城市"`
  32. Address string `description:"活动地址"`
  33. PosterUrl string `description:"活动海报地址"`
  34. Remarks string `description:"备注"`
  35. UserId int `description:"创建者id"`
  36. PublishStatus int8 `description:"发布状态,0未发布,1已发布"`
  37. IsSendWxMsg int8 `description:"是否推送过会议提醒微信消息,未推送:0,已推送:1"`
  38. IsSendSalonWxMsg int8 `description:"是否推送过沙龙提醒微信消息,未推送:0,已推送:1"`
  39. IsDelete int8 `description:"是否删除,0:未删除,1:已删除"`
  40. ArticleId int `description:"报告链接所关联的文章ID"`
  41. ModifyTime time.Time `description:"修改时间"`
  42. CreateTime time.Time `description:"创建时间"`
  43. }
  44. // TableName 表名变更
  45. func (activity *Activity) TableName() string {
  46. return "yb_activity"
  47. }
  48. // GetById 根据id获取活动详情
  49. func GetById(activityId int) (item *Activity, err error) {
  50. o := orm.NewOrm()
  51. sql := "select * from yb_activity where activity_id=? AND is_delete = 0 "
  52. err = o.Raw(sql, activityId).QueryRow(&item)
  53. return
  54. }
  55. type ActivityList struct {
  56. ActivityId int `orm:"column(activity_id);pk" description:"活动ID"`
  57. FirstActivityTypeId int `description:"第一级的活动类型ID"`
  58. FirstActivityTypeName string `description:"第一级的活动类型名称"`
  59. ActivityTypeId int `description:"活动类型ID"`
  60. ActivityTypeName string `description:"活动类型名称"`
  61. ChartPermissionId int `description:"对应的权限id,表chart_permission中id"`
  62. ChartPermissionName string `description:"对应的权限名称,表chart_permission中name"`
  63. ActivityName string `description:"活动标题"`
  64. StartTime time.Time `description:"活动开始时间"`
  65. EndTime time.Time `description:"活动结束时间"`
  66. Speaker string `description:"主讲人"`
  67. MainlandTel string `description:"大陆拨入"`
  68. HongKongTel string `description:"香港拨入"`
  69. TaiwanTel string `description:"台湾拨入"`
  70. AmericaTel string `description:"美国拨入"`
  71. SingaporeTel string `description:"新加坡拨入"`
  72. ParticipationCode string `description:"参会密码"`
  73. LinkParticipants string `description:"参会链接"`
  74. IsLimitPeople int8 `description:"是否限制人数 1是,0否"`
  75. LimitPeopleNum int `description:"限制人数数量"`
  76. ReportLink string `description:"报告链接"`
  77. City string `description:"城市"`
  78. Address string `description:"活动地址"`
  79. PosterUrl string `description:"活动海报地址"`
  80. Remarks string `description:"备注"`
  81. UserId int `description:"创建者id"`
  82. PublishStatus int8 `description:"发布状态,0未发布,1已发布"`
  83. IsSendWxMsg int8 `description:"是否推送过会议提醒微信消息,未推送:0,已推送:1"`
  84. IsSendSalonWxMsg int8 `description:"是否推送过沙龙提醒微信消息,未推送:0,已推送:1"`
  85. ArticleId int `description:"报告链接所关联的文章ID"`
  86. ModifyTime time.Time `description:"修改时间"`
  87. CreateTime time.Time `description:"创建时间"`
  88. VoiceList []*ActivityVoice `description:"音频文件列表"`
  89. }
  90. // GetList 获取活动列表数据
  91. func GetList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*Activity, err error) {
  92. o := orm.NewOrm()
  93. sql := "select * from yb_activity where 1=1 AND is_delete = 0 "
  94. sql += condition
  95. sql += ` order by modify_time desc `
  96. totalSql := `select count(1) total from (` + sql + `) z `
  97. err = o.Raw(totalSql, pars).QueryRow(&total)
  98. if err != nil {
  99. return
  100. }
  101. sql += ` LIMIT ?,? `
  102. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  103. return
  104. }
  105. // Update 更新活动
  106. func (activity *Activity) Update(cols []string) (err error) {
  107. o := orm.NewOrm()
  108. _, err = o.Update(activity, cols...)
  109. return
  110. }
  111. // AddActivity 新增活动
  112. func AddActivity(activity *Activity) (err error) {
  113. o := orm.NewOrm()
  114. id, err := o.Insert(activity)
  115. if err != nil {
  116. return
  117. }
  118. activity.ActivityId = int(id)
  119. return
  120. }