activity_poster.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ActivityPoster 活动海报表结构体
  7. type ActivityPoster struct {
  8. ActivityPosterId int `orm:"column(activity_poster_id);pk" description:"活动海报ID"`
  9. ActivityId int ` description:"活动ID"`
  10. Url string `description:"海报地址"`
  11. Name string `description:"海报名称"`
  12. CreateTime time.Time `description:"创建时间"`
  13. }
  14. // TableName 表名变更
  15. func (activityPoster *ActivityPoster) TableName() string {
  16. return "yb_activity_poster"
  17. }
  18. // DelPosterByActivityId 根据活动id删除所有海报
  19. func DelPosterByActivityId(activityId int) (err error) {
  20. o := orm.NewOrm()
  21. sql := "delete from yb_activity_poster where activity_id=?"
  22. _, err = o.Raw(sql, activityId).Exec()
  23. return
  24. }
  25. // AddActivityPoster 新增活动海报
  26. func AddActivityPoster(activityPosterInfo *ActivityPoster) (err error) {
  27. o := orm.NewOrm()
  28. _, err = o.Insert(activityPosterInfo)
  29. return
  30. }
  31. // AddActivityPosterMulti 批量新增活动海报
  32. func AddActivityPosterMulti(activityPosterList []*ActivityPoster) (err error) {
  33. o := orm.NewOrm()
  34. _, err = o.InsertMulti(len(activityPosterList), activityPosterList)
  35. return
  36. }
  37. // GetPosterListByActivityIds 根据活动id集合获取海报列表
  38. func GetPosterListByActivityIds(activityIds string) (list []*ActivityPoster, err error) {
  39. if activityIds == "" {
  40. return
  41. }
  42. o := orm.NewOrm()
  43. sql := `select * from yb_activity_poster where activity_id in (` + activityIds + `) `
  44. _, err = o.Raw(sql).QueryRows(&list)
  45. return
  46. }
  47. // GetPosterListByActivityId 根据活动id获取海报列表
  48. func GetPosterListByActivityId(activityId int) (list []*ActivityPoster, err error) {
  49. o := orm.NewOrm()
  50. sql := `select * from yb_activity_poster where activity_id = ?`
  51. _, err = o.Raw(sql, activityId).QueryRows(&list)
  52. return
  53. }