123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxYanxuanSpecial struct {
- Id int `orm:"column(id);pk"`
- UserId int
- CreateTime time.Time
- ModifyTime time.Time
- PublishTime time.Time
- Content string
- Tags string
- Status int
- ImgUrl string
- DocUrl string
- Reason string
- Title string
- Type int
- }
- type CygxYanxuanSpecialItem struct {
- Id int `orm:"column(id);pk"`
- UserId int
- CreateTime string
- ModifyTime string
- PublishTime string
- Content string
- Tags string
- Status int
- ImgUrl string
- DocUrl string
- SpecialName string
- Introduction string
- Label string
- NickName string
- RealName string
- Mobile string
- HeadImg string
- BgImg string
- Reason string
- Title string
- Type string
- }
- func GetYanxuanSpecialList(condition string, pars []interface{}) (items []*CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
- FROM cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
- WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += `ORDER BY a.publish_time DESC `
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- type EnableCygxYanxuanSpecialReq struct {
- Id int
- Status int
- Reason string
- }
- func EnableYanxuanSpecial(id, status int, reason string) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW() WHERE id = ? `
- _, err = o.Raw(sql, status, reason, id).Exec()
- return
- }
- type SpecialListResp struct {
- List []*CygxYanxuanSpecialItem
- IsAuthor bool
- }
- func GetYanxuanSpecialById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
- FROM cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
- WHERE a.id=? `
- err = o.Raw(sql, specialId).QueryRow(&item)
- return
- }
- type CygxYanxuanSpecialReq struct {
- Id int `orm:"column(id);pk"`
- UserId int
- Content string
- Tags string
- DoType int
- ImgUrl string
- DocUrl string
- Title string
- Type int
- }
- func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,tags=?,img_url=?,doc_url=?,type=?,status=?,
- modify_time=NOW(),publish_time=NOW() WHERE id = ? `
- _, err = o.Raw(sql, item.Title, item.Content,item.Tags,item.ImgUrl,item.DocUrl,item.Type,item.Status).Exec()
- return
- }
- func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%`+keyword+`%' `
- _, err = o.Raw(sql).QueryRows(&IndustryNames)
- return
- }
|