cygx_yanxuan_special_user.go 2.2 KB

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