package models import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "time" ) type ResearchReportList 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:"头像"` } func GetResearchReportList(classifyId int) (list []*ResearchReportList, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM classify WHERE parent_id=? ORDER BY sort ASC ` _, err = o.Raw(sql, classifyId).QueryRows(&list) return } type ResearchReportListResp struct { List []*ResearchReportList } func GetSearchReportListCount(condition string) (count int, err error) { o := orm.NewOrmUsingDB("rddp") sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 ` if condition != "" { sql += condition } err = o.Raw(sql).QueryRow(&count) return } func GetSearchReportList(condition string) (items []*ReportList, err error) { o := orm.NewOrmUsingDB("rddp") sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency, a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript, b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,b.home_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size FROM report AS a INNER JOIN classify AS b ON a.classify_id_second=b.id WHERE a.state=2 ` if condition != "" { sql += condition } sql += `ORDER BY a.publish_time DESC ` _, err = o.Raw(sql).QueryRows(&items) return } type PcSearchReportListResp struct { List []*ReportList Paging *paging.PagingItem }