123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type CygxYanxuanSpecialAuthor struct {
- Id int `orm:"column(id);pk"`
- UserId int
- SpecialName string
- Introduction string
- Label string
- NickName string
- RealName string
- Mobile string
- CreateTime time.Time
- ModifyTime time.Time
- HeadImg string
- BgImg string
- BgImgDown string
- Status int
- }
- type CygxYanxuanSpecialAuthorItem struct {
- Id int `orm:"column(id);pk"`
- UserId int
- SpecialName string
- Introduction string
- Label string
- NickName string
- RealName string
- CompanyName string
- Mobile string
- CreateTime string
- ModifyTime time.Time
- HeadImg string
- BgImg string
- BgImgDown string
- Status int
- CollectNum int
- FollowNum int
- SpecialArticleNum int
- LatestPublishTime time.Time
- LatestPublishDate string
- IsFollow int
- HasChangeHeadImg int
- YanxuanSpecialCenter *CygxYanxuanSpecialCenterAuthorResp
- }
- type CygxYanxuanSpecialCenterAuthorResp struct {
- Id int
- UserId int
- PublishTime string
- Title string
- }
- func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type EnableCygxYanxuanSpecialAuthorReq struct {
- UserId int
- Status int
- }
- func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET status=?,modify_time=NOW() WHERE user_id = ? `
- _, err = o.Raw(sql, status, userId).Exec()
- return
- }
- func GetYanxuanSpecialAuthor(reqUserId, sysUserId int, cond string) (item *CygxYanxuanSpecialAuthorItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT
- a.*,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac INNER JOIN cygx_yanxuan_special as cs ON ac.yanxuan_special_id = cs.id WHERE cs.user_id = a.user_id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf WHERE cf.follow_user_id = a.user_id ) AS follow_num,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special AS ca WHERE ca.user_id = a.user_id AND ca.status = 3 ) AS special_article_num,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf WHERE cf.follow_user_id =? AND cf.user_id = ? ) AS is_follow
- FROM
- cygx_yanxuan_special_author as a WHERE a.user_id=? `
- if cond != "" {
- sql += cond
- }
- err = o.Raw(sql, reqUserId, sysUserId, reqUserId).QueryRow(&item)
- return
- }
- func GetCygxYanxuanSpecialAuthorByUserId(userId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_yanxuan_special_author WHERE user_id = ? `
- err = o.Raw(sql, userId).QueryRow(&item)
- return
- }
- type SaveCygxYanxuanSpecialAuthorReq struct {
- UserId int
- SpecialName string
- Introduction string
- Label string
- NickName string
- BgImg string
- }
- func UpdateYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET special_name=?,introduction=?,label=?,nick_name=?
- ,modify_time=NOW() WHERE user_id = ? `
- _, err = o.Raw(sql, item.SpecialName, item.Introduction, item.Label, item.NickName, item.UserId).Exec()
- return
- }
- func GetCygxYanxuanSpecialAuthorCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_author as a WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- func GetYanxuanSpecialAuthorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialAuthorItem, err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `SELECT
- a.*,
- IFNULL(( SELECT publish_time FROM cygx_yanxuan_special WHERE user_id = a.user_id AND STATUS = 3 ORDER BY publish_time DESC LIMIT 1 ), a.modify_time) AS latest_publish_time
- FROM
- cygx_yanxuan_special_author AS a
- WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type SpecialAuthorListResp struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxYanxuanSpecialAuthorItem
- IsAuthor bool
- }
- type SaveCygxYanxuanSpecialAuthoHeadImgrReq struct {
- UserId int
- HeadImg string
- }
- func UpdateYanxuanSpecialAuthorHeadImg(item *CygxYanxuanSpecialAuthor) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET head_img=?,modify_time=NOW(),has_change_head_img = 1 WHERE user_id = ? `
- _, err = o.Raw(sql, item.HeadImg, item.UserId).Exec()
- return
- }
- func UpdateCygxYanxuanSpecialAuthorPv(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET pv=pv+1 WHERE user_id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateCygxYanxuanSpecialAuthorUv(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET uv=uv+1 WHERE user_id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num +1 WHERE id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorArticleCollectNumReduce(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num - 1 WHERE id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorArticleCollectNum(collectNum, userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = ? WHERE user_id = ? `
- _, err = o.Raw(sql, collectNum, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorFansNumIncrease(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num +1 WHERE id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorFansNumReduce(userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num - 1 WHERE id = ? `
- _, err = o.Raw(sql, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialAuthorFansNum(fansNum, userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET fans_num = ? WHERE user_id = ? `
- _, err = o.Raw(sql, fansNum, userId).Exec()
- return
- }
- func UdpateYanxuanSpecialauthorArticleNum(articleNum, userId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_author SET article_num = ? WHERE user_id = ? `
- _, err = o.Raw(sql, articleNum, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialauthorPvNUm(pv, userId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special_author SET pv = ? WHERE user_id = ? `
- _, err = o.Raw(sql, pv, userId).Exec()
- return
- }
- func UpdateYanxuanSpecialauthorUvUm(pv, userId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE cygx_yanxuan_special_author SET uv = ? WHERE user_id = ? `
- _, err = o.Raw(sql, pv, userId).Exec()
- return
- }
|