package yb import ( "eta/eta_api/utils" "fmt" "github.com/beego/beego/v2/client/orm" "strings" "time" ) // YbPosterResource 研报小程序海报 type YbPosterResource struct { Id int `orm:"column(id);pk" description:"价格驱动ID"` Path string `description:"请求路径"` ImgUrl string `description:"图片地址"` Type string `description:"类型 poster-海报; qrcode-太阳码"` Version string `description:"版本号"` CreateTime time.Time `description:"创建时间"` } func (m *YbPosterResource) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*YbPosterResource, err error) { o := orm.NewOrmUsingDB("weekly") fields := strings.Join(fieldArr, ",") if len(fieldArr) == 0 { fields = `*` } order := `ORDER BY create_time DESC` if orderRule != "" { order = ` ORDER BY ` + orderRule } sql := fmt.Sprintf(`SELECT %s FROM yb_poster_resource WHERE 1=1 %s %s`, fields, condition, order) _, err = o.Raw(sql, pars).QueryRows(&items) return } func (m *YbPosterResource) RemovePosters(ids []int) (err error) { num := len(ids) if num == 0 { return } o := orm.NewOrmUsingDB("weekly") sql := fmt.Sprintf(`DELETE FROM yb_poster_resource WHERE id IN (%s) LIMIT %d`, utils.GetOrmInReplace(num), num) _, err = o.Raw(sql, ids).Exec() return }