cygx_yanxuan_special_user.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxYanxuanSpecialAuthor struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int // 用户ID
  10. SpecialName string // 专栏名称
  11. Introduction string // 介绍
  12. Label string // 标签
  13. NickName string // 昵称
  14. RealName string // 姓名
  15. Mobile string // 手机号
  16. CreateTime time.Time // 创建时间
  17. ModifyTime time.Time // 修改时间
  18. HeadImg string // 头像
  19. BgImg string // 背景图上部分
  20. BgImgDown string // 背景图下部分
  21. BgImgPc string // pc背景图
  22. Status int // 1启用2禁用
  23. CompanyId int `description:"公司id"`
  24. CompanyName string `description:"公司名称"`
  25. }
  26. type CygxYanxuanSpecialAuthorItem struct {
  27. Id int `orm:"column(id);pk"`
  28. UserId int // 用户ID
  29. CompanyName string // 公司名
  30. SpecialName string // 专栏名称
  31. Introduction string // 介绍
  32. Label string // 标签
  33. NickName string // 昵称
  34. RealName string // 姓名
  35. Mobile string // 手机号
  36. CreateTime string // 创建时间
  37. ModifyTime string // 修改时间
  38. HeadImg string // 头像
  39. BgImg string // 背景图
  40. Status int // 1启用2禁用
  41. Pv int // Pv
  42. Uv int // Uv
  43. ArticleNum int // 已发布的文章数量
  44. ArticlePublishTime int // 最近发布文章的时间
  45. FansNum int // 粉丝数量
  46. ArticleCollectNum int // 文章收藏数量
  47. }
  48. func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
  49. o := orm.NewOrmUsingDB("hz_cygx")
  50. lastId, err = o.Insert(item)
  51. return
  52. }
  53. type AddCygxYanxuanSpecialAuthorReq struct {
  54. UserId int // 用户ID
  55. RealName string // 姓名
  56. Mobile string // 手机号
  57. }
  58. type EnableCygxYanxuanSpecialAuthorReq struct {
  59. UserId int // 用户ID
  60. Status int // 1启用2禁用
  61. }
  62. // 启用禁用作者
  63. func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
  64. o := orm.NewOrmUsingDB("hz_cygx")
  65. sql := ``
  66. sql = `UPDATE cygx_yanxuan_special_author SET status=? WHERE user_id = ? `
  67. _, err = o.Raw(sql, status, userId).Exec()
  68. return
  69. }
  70. // 获取数量
  71. func GetYanxuanSpecialAuthorCount(condition string, pars []interface{}) (count int, err error) {
  72. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_author as art WHERE 1= 1 `
  73. if condition != "" {
  74. sqlCount += condition
  75. }
  76. o := orm.NewOrmUsingDB("hz_cygx")
  77. err = o.Raw(sqlCount, pars).QueryRow(&count)
  78. return
  79. }
  80. type GetCygxYanxuanSpecialAuthorItemResp struct {
  81. Paging *paging.PagingItem `description:"分页数据"`
  82. List []*CygxYanxuanSpecialAuthorItem
  83. }
  84. // 列表
  85. func GetYanxuanSpecialAuthorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialAuthorItem, err error) {
  86. o := orm.NewOrmUsingDB("hz_cygx")
  87. sql := `SELECT * FROM cygx_yanxuan_special_author as art WHERE 1= 1 `
  88. if condition != "" {
  89. sql += condition
  90. }
  91. sql += ` LIMIT ?,? `
  92. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  93. return
  94. }
  95. // 启用禁用作者
  96. func UpdateSpecialAuthorComapony(userId, CompanyId int, CompanyName string) (err error) {
  97. o := orm.NewOrmUsingDB("hz_cygx")
  98. sql := ``
  99. sql = `UPDATE cygx_yanxuan_special_author SET company_id=?,company_name = ? WHERE user_id = ? `
  100. _, err = o.Raw(sql, CompanyId, CompanyName, userId).Exec()
  101. return
  102. }
  103. // 通过ID获取详情
  104. func GetCygxYanxuanSpecialAuthorItemById(id int) (item *CygxYanxuanSpecialAuthorItem, err error) {
  105. o := orm.NewOrmUsingDB("hz_cygx")
  106. sql := `SELECT * FROM cygx_yanxuan_special_author WHERE id=? `
  107. err = o.Raw(sql, id).QueryRow(&item)
  108. return
  109. }