123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type CygxYanxuanSpecial struct {
- Id int `orm:"column(id);pk"`
- UserId int
- CreateTime time.Time
- ModifyTime time.Time
- PublishTime time.Time
- Content string
- CompanyTags string
- IndustryTags string
- Status int
- ImgUrl string
- DocUrl string
- Reason string
- Title string
- Type int
- AdminName string
- }
- type CygxYanxuanSpecialItem struct {
- Id int `orm:"column(id);pk"`
- UserId int
- SpecialColumnId int
- CreateTime string
- ModifyTime string
- PublishTime string
- Content string
- Tags string
- TagList []string
- Status int
- ImgUrl string
- ImgUrlList []string
- DocUrl string
- SpecialName string
- Introduction string
- Label string
- NickName string
- RealName string
- Mobile string
- HeadImg string
- BgImg string
- Reason string
- Title string
- AuthorStatus int
- Type int
- CollectNum int
- MyCollectNum int
- IsCollect int
- ContentHasImg int
- CompanyTags string
- IndustryTags string
- Docs []Doc
- Annotation string `description:"核心观点"`
- Pv int `description:"Pv"`
- Uv int `description:"Uv"`
- HzPv int `description:"HzPv"`
- BodyHighlight []string `description:"搜索高亮展示结果"`
- }
- type CygxYanxuanSpecialResp struct {
- CygxYanxuanSpecialItem
- Docs []Doc
- CompanyTags []string
- IndustryTags []string
- HasPermission int `description:"1:正常展示,2:不展示"`
- IsApprovalAdmin bool
- ShareImg string `description:"分享图片"`
- IsFollowAuthor bool
- }
- type Doc struct {
- DocName string
- DocSuffix string
- DocUrl string
- DocIcon string
- }
- type DocReq struct {
- DocName string
- DocSuffix string
- DocUrl string
- }
- func GetYanxuanSpecialList(userId int, condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT a.*,b.id AS special_column_id,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,b.status AS author_status,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
- 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 `
- if startSize+pageSize > 0 {
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
- } else {
- _, err = o.Raw(sql, userId, pars).QueryRows(&items)
- }
- return
- }
- type EnableCygxYanxuanSpecialReq struct {
- Id int
- Status int
- Reason string
- }
- func EnableYanxuanSpecial(id, status int, reason, adminName string) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,admin_name = ? , publish_time=NOW() WHERE id = ? `
- _, err = o.Raw(sql, status, reason, adminName, id).Exec()
- return
- }
- type SpecialListResp struct {
- IsAuthor bool `description:"是否开通了研选专栏"`
- IsImproveInformation bool `description:"作者信息是否完善"`
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxYanxuanSpecialItem
- }
- func GetYanxuanSpecialById(specialId, userId int) (item *CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT a.*,b.id AS special_column_id,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
- b.nick_name,b.real_name,b.special_name,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
- 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, userId, specialId).QueryRow(&item)
- return
- }
- func GetYanxuanSpecialListBycondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := `SELECT a.* FROM cygx_yanxuan_special AS a WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- if startSize+pageSize > 0 {
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- } else {
- _, err = o.Raw(sql, pars).QueryRows(&items)
- }
- return
- }
- type CygxYanxuanSpecialReq struct {
- Id int `orm:"column(id);pk"`
- Content string
- IndustryTags []string
- CompanyTags []string
- DoType int
- ImgUrl []string
- Docs []Doc
- Title string
- Type int
- IsApprovalPersonnel bool
- }
- 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=?,company_tags=?,industry_tags=?,img_url=?,doc_url=?,type=?,status=?,
- modify_time=NOW(),publish_time=NOW(),admin_name = ? WHERE id = ? `
- _, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.AdminName, item.Id).Exec()
- return
- }
- func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT a.*
- FROM cygx_yanxuan_special AS a
- WHERE a.id=? `
- err = o.Raw(sql, specialId).QueryRow(&item)
- return
- }
- func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
- o := orm.NewOrm()
- sql := ``
- if keyword == "" {
- sql = `SELECT industry_name FROM cygx_yanxuan_special_industry `
- } else {
- sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%` + keyword + `%' `
- }
- _, err = o.Raw(sql).QueryRows(&IndustryNames)
- return
- }
- type CancelPublishCygxYanxuanSpecialReq struct {
- Id int
- }
- func CancelPublishYanxuanSpecial(id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET status=1,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- type DelCygxYanxuanSpecialReq struct {
- Id int
- }
- func DelYanxuanSpecial(id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- type CygxYanxuanSpecialCheckReq struct {
- Content string
- ImgUrl []string
- }
- func GetYanxuanSpecialFollowUserById(specialId int) (items []int, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT b.user_id
- FROM cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_follow AS b ON a.user_id = b.follow_user_id
- WHERE a.id=? `
- _, err = o.Raw(sql, specialId).QueryRows(&items)
- return
- }
- func GetYanxuanSpecialItemById(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
- }
- func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special as a WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- func UpdateYanxuanSpecialPv(id int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special SET pv=pv+1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialHzPv(id int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special SET hz_pv=hz_pv+1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialUv(id int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special SET uv=uv+1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialHzUv(id int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special SET hz_uv=hz_uv+1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialarticleCollectNumIncrease(id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num +1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialarticleCollectNumReduce(id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num - 1 WHERE id = ? `
- _, err = o.Raw(sql, id).Exec()
- return
- }
- func UpdateYanxuanSpecialarticleCollectNum(collectNum, id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET article_collect_num = ? WHERE id = ? `
- _, err = o.Raw(sql, collectNum, id).Exec()
- return
- }
- func UpdateYanxuanSpecialMomentsImg(momentsImg string, id int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special SET moments_img = ? WHERE id = ? `
- _, err = o.Raw(sql, momentsImg, id).Exec()
- return
- }
- func GetYanxuanSpecialListByconditioninit() (items []*CygxYanxuanSpecialItem, err error) {
- o := orm.NewOrm()
- sql := `SELECT a.* FROM cygx_yanxuan_special AS a WHERE 1=1 AND moments_img is NULL`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
|