1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type Classify struct {
- Id int `orm:"column(id);pk"`
- ClassifyName string `description:"分类名称"`
- Sort int `json:"-"`
- ParentId int `description:"父级分类id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- Abstract string `description:"栏目简介"`
- Descript string `description:"分享描述"`
- ReportAuthor string `description:"栏目作者"`
- AuthorDescript string `description:"作者简介"`
- ColumnImgUrl string `description:"栏目配图"`
- HeadImgUrl string `description:"头部banner"`
- AvatarImgUrl string `description:"头像"`
- ReportImgUrl string `description:"报告配图"`
- HomeImgUrl string `description:"首页配图"`
- }
- func GetClassifyById(classifyId int) (item *Classify, err error) {
- sql := ` SELECT * FROM classify WHERE id = ? `
- o := orm.NewOrmUsingDB("rddp")
- err = o.Raw(sql, classifyId).QueryRow(&item)
- return
- }
- func GetClassifyList() (item []*Classify, err error) {
- sql := ` SELECT * FROM classify WHERE parent_id = 0 AND classify_name not in("权益研报","双周报","月报","晨报","周报","草根调研","需求报告","会议纪要","大事点评","年报合集","宏观点评") `
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Raw(sql).QueryRows(&item)
- return
- }
- func GetClassifySecondList(classifyId int) (item []*ClassifyDetail, err error) {
- sql := ` SELECT a.id AS classify_id,a.classify_name,a.sort,a.parent_id,a.create_time,a.modify_time,a.abstract,a.descript,a.report_author,a.author_descript,a.report_img_url,a.head_img_url,a.avatar_img_url,a.column_img_url,a.home_img_url,a.is_home_column,MAX(b.stage) AS stage
- FROM classify AS a
- LEFT JOIN report AS b ON a.id=b.classify_id_second
- WHERE a.parent_id = ?
- GROUP BY a.id
- ORDER BY sort ASC `
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Raw(sql, classifyId).QueryRows(&item)
- return
- }
- type ClassifyDetail struct {
- ClassifyId int `description:"分类id"`
- ClassifyName string `description:"分类名称"`
- Sort int `json:"-"`
- ParentId int `description:"父级分类id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- Abstract string `description:"栏目简介"`
- Descript string `description:"分享描述"`
- ReportAuthor string `description:"栏目作者"`
- AuthorDescript string `description:"作者简介"`
- ColumnImgUrl string `description:"栏目配图"`
- HeadImgUrl string `description:"头部banner"`
- AvatarImgUrl string `description:"头像"`
- ReportImgUrl string `description:"报告配图"`
- HomeImgUrl string `description:"首页配图"`
- Stage int `description:"最新期数"`
- CommentList []*CustomerComment
- }
- func GetClassifyDetailById(classifyId int) (item *ClassifyDetail, err error) {
- sql := ` SELECT id AS classify_id,classify_name,sort,parent_id,create_time,modify_time,abstract,descript,report_author,author_descript,report_img_url,head_img_url,avatar_img_url,column_img_url FROM classify WHERE id = ? `
- o := orm.NewOrmUsingDB("rddp")
- err = o.Raw(sql, classifyId).QueryRow(&item)
- return
- }
|