package cygx import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxYanxuanSpecialAuthor struct { Id int `orm:"column(id);pk"` UserId int // 用户ID SpecialName string // 专栏名称 Introduction string // 介绍 Label string // 标签 NickName string // 昵称 RealName string // 姓名 Mobile string // 手机号 CreateTime time.Time // 创建时间 ModifyTime time.Time // 修改时间 HeadImg string // 头像 BgImg string // 背景图 BgImgPc string // pc背景图 Status int // 1启用2禁用 } type CygxYanxuanSpecialAuthorItem struct { Id int `orm:"column(id);pk"` UserId int // 用户ID CompanyName string // 公司名 SpecialName string // 专栏名称 Introduction string // 介绍 Label string // 标签 NickName string // 昵称 RealName string // 姓名 Mobile string // 手机号 CreateTime string // 创建时间 ModifyTime string // 修改时间 HeadImg string // 头像 BgImg string // 背景图 Status int // 1启用2禁用 } func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } type AddCygxYanxuanSpecialAuthorReq struct { UserId int // 用户ID RealName string // 姓名 Mobile string // 手机号 } type EnableCygxYanxuanSpecialAuthorReq struct { UserId int // 用户ID Status int // 1启用2禁用 } // 启用禁用作者 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 GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) { o := orm.NewOrm() sql := `` sql = `SELECT a.*,c.company_name FROM cygx_yanxuan_special_author as a INNER JOIN wx_user AS u ON u.user_id = a.user_id INNER JOIN company AS c ON c.company_id = u.company_id ORDER BY create_time DESC ` _, err = o.Raw(sql).QueryRows(&items) return }