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 // 背景图上部分 BgImgDown 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.NewOrmUsingDB("hz_cygx") 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.NewOrmUsingDB("hz_cygx") sql := `` sql = `UPDATE cygx_yanxuan_special_author SET status=? WHERE user_id = ? ` _, err = o.Raw(sql, status, userId).Exec() return } func GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) { o := orm.NewOrmUsingDB("hz_cygx") sql := `` sql = `SELECT a.* FROM cygx_yanxuan_special_author as a ORDER BY create_time DESC ` _, err = o.Raw(sql).QueryRows(&items) return }