12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ActivityPoster 活动海报表结构体
- type ActivityPoster struct {
- ActivityPosterId int `orm:"column(activity_poster_id);pk" description:"活动海报ID"`
- ActivityId int ` description:"活动ID"`
- Url string `description:"海报地址"`
- Name string `description:"海报名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- // TableName 表名变更
- func (activityPoster *ActivityPoster) TableName() string {
- return "yb_activity_poster"
- }
- // DelPosterByActivityId 根据活动id删除所有海报
- func DelPosterByActivityId(activityId int) (err error) {
- o := orm.NewOrm()
- sql := "delete from yb_activity_poster where activity_id=?"
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // AddActivityPoster 新增活动海报
- func AddActivityPoster(activityPosterInfo *ActivityPoster) (err error) {
- o := orm.NewOrm()
- _, err = o.Insert(activityPosterInfo)
- return
- }
- // AddActivityPosterMulti 批量新增活动海报
- func AddActivityPosterMulti(activityPosterList []*ActivityPoster) (err error) {
- o := orm.NewOrm()
- _, err = o.InsertMulti(len(activityPosterList), activityPosterList)
- return
- }
- // GetPosterListByActivityIds 根据活动id集合获取海报列表
- func GetPosterListByActivityIds(activityIds string) (list []*ActivityPoster, err error) {
- if activityIds == "" {
- return
- }
- o := orm.NewOrm()
- sql := `select * from yb_activity_poster where activity_id in (` + activityIds + `) `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // GetPosterListByActivityId 根据活动id获取海报列表
- func GetPosterListByActivityId(activityId int) (list []*ActivityPoster, err error) {
- o := orm.NewOrm()
- sql := `select * from yb_activity_poster where activity_id = ?`
- _, err = o.Raw(sql, activityId).QueryRows(&list)
- return
- }
|