cygx_yanxuan_special_user.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecialAuthor struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int // 用户ID
  9. SpecialName string // 专栏名称
  10. Introduction string // 介绍
  11. Label string // 标签
  12. NickName string // 昵称
  13. RealName string // 姓名
  14. Mobile string // 手机号
  15. CreateTime time.Time // 创建时间
  16. ModifyTime time.Time // 修改时间
  17. HeadImg string // 头像
  18. BgImg string // 背景图
  19. Status int // 1启用2禁用
  20. }
  21. type CygxYanxuanSpecialAuthorItem struct {
  22. Id int `orm:"column(id);pk"`
  23. UserId int // 用户ID
  24. CompanyName string // 公司名
  25. SpecialName string // 专栏名称
  26. Introduction string // 介绍
  27. Label string // 标签
  28. NickName string // 昵称
  29. RealName string // 姓名
  30. Mobile string // 手机号
  31. CreateTime string // 创建时间
  32. ModifyTime string // 修改时间
  33. HeadImg string // 头像
  34. BgImg string // 背景图
  35. Status int // 1启用2禁用
  36. }
  37. func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
  38. o := orm.NewOrm()
  39. lastId, err = o.Insert(item)
  40. return
  41. }
  42. type AddCygxYanxuanSpecialAuthorReq struct {
  43. UserId int // 用户ID
  44. RealName string // 姓名
  45. Mobile string // 手机号
  46. }
  47. type EnableCygxYanxuanSpecialAuthorReq struct {
  48. UserId int // 用户ID
  49. Status int // 1启用2禁用
  50. }
  51. // 启用禁用作者
  52. func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
  53. o := orm.NewOrm()
  54. sql := ``
  55. sql = `UPDATE cygx_yanxuan_special_author SET status=?,modify_time=NOW() WHERE user_id = ? `
  56. _, err = o.Raw(sql, status, userId).Exec()
  57. return
  58. }
  59. func GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) {
  60. o := orm.NewOrm()
  61. sql := ``
  62. sql = `SELECT
  63. a.*,c.company_name
  64. FROM
  65. cygx_yanxuan_special_author as a
  66. INNER JOIN wx_user AS u ON u.user_id = a.user_id
  67. INNER JOIN company AS c ON c.company_id = u.company_id ORDER BY create_time DESC `
  68. _, err = o.Raw(sql).QueryRows(&items)
  69. return
  70. }