cygx_yanxuan_special_user.go 2.5 KB

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