cygx_yanxuan_special_user.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. MobileInit string // 初始化手机号(没有脱敏的)
  17. CreateTime time.Time // 创建时间
  18. ModifyTime time.Time // 修改时间
  19. HeadImg string // 头像
  20. BgImg string // 背景图上部分
  21. BgImgDown string // 背景图下部分
  22. BgImgPc string // pc背景图
  23. Status int // 1启用2禁用
  24. CompanyId int `description:"公司id"`
  25. CompanyName string `description:"公司名称"`
  26. }
  27. type CygxYanxuanSpecialAuthorItem struct {
  28. Id int `orm:"column(id);pk"`
  29. UserId int // 用户ID
  30. CompanyName string // 公司名
  31. CompanyId int // 公Id
  32. SpecialName string // 专栏名称
  33. Introduction string // 介绍
  34. Label string // 标签
  35. NickName string // 昵称
  36. RealName string // 姓名
  37. Mobile string // 手机号
  38. MobileInit string // 初始化手机号(没有脱敏的)
  39. CreateTime string // 创建时间
  40. ModifyTime string // 修改时间
  41. HeadImg string // 头像
  42. BgImg string // 背景图
  43. Status int // 1启用2禁用
  44. Pv int // Pv
  45. Uv int // Uv
  46. ArticleNum int // 已发布的文章数量
  47. ArticlePublishTime string // 最近发布文章的时间
  48. FansNum int // 粉丝数量
  49. ArticleCollectNum int // 文章收藏数量
  50. SpecialAuthorId int //cygx_yanxuan_special_author 表主键ID 作者专栏ID
  51. }
  52. func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
  53. o := orm.NewOrmUsingDB("hz_cygx")
  54. lastId, err = o.Insert(item)
  55. return
  56. }
  57. type AddCygxYanxuanSpecialAuthorReq struct {
  58. UserId int // 用户ID
  59. RealName string // 姓名
  60. Mobile string // 手机号
  61. }
  62. type EnableCygxYanxuanSpecialAuthorReq struct {
  63. UserId int // 用户ID
  64. Status int // 1启用2禁用
  65. }
  66. // 启用禁用作者
  67. func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
  68. o := orm.NewOrmUsingDB("hz_cygx")
  69. sql := ``
  70. sql = `UPDATE cygx_yanxuan_special_author SET status=? WHERE user_id = ? `
  71. _, err = o.Raw(sql, status, userId).Exec()
  72. return
  73. }
  74. // 获取数量
  75. func GetYanxuanSpecialAuthorCount(condition string, pars []interface{}) (count int, err error) {
  76. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_author as art WHERE 1= 1 `
  77. if condition != "" {
  78. sqlCount += condition
  79. }
  80. o := orm.NewOrmUsingDB("hz_cygx")
  81. err = o.Raw(sqlCount, pars).QueryRow(&count)
  82. return
  83. }
  84. type GetCygxYanxuanSpecialAuthorItemResp struct {
  85. Paging *paging.PagingItem `description:"分页数据"`
  86. List []*CygxYanxuanSpecialAuthorItem
  87. }
  88. // 列表
  89. func GetYanxuanSpecialAuthorList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialAuthorItem, err error) {
  90. o := orm.NewOrmUsingDB("hz_cygx")
  91. sql := `SELECT * FROM cygx_yanxuan_special_author as art WHERE 1= 1 `
  92. if condition != "" {
  93. sql += condition
  94. }
  95. sql += ` LIMIT ?,? `
  96. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  97. return
  98. }
  99. // 启用禁用作者
  100. func UpdateSpecialAuthorComapony(userId, CompanyId int, CompanyName string) (err error) {
  101. o := orm.NewOrmUsingDB("hz_cygx")
  102. sql := ``
  103. sql = `UPDATE cygx_yanxuan_special_author SET company_id=?,company_name = ? WHERE user_id = ? `
  104. _, err = o.Raw(sql, CompanyId, CompanyName, userId).Exec()
  105. return
  106. }
  107. // 通过ID获取详情
  108. func GetCygxYanxuanSpecialAuthorItemById(id int) (item *CygxYanxuanSpecialAuthorItem, err error) {
  109. o := orm.NewOrmUsingDB("hz_cygx")
  110. sql := `SELECT * FROM cygx_yanxuan_special_author WHERE id=? `
  111. err = o.Raw(sql, id).QueryRow(&item)
  112. return
  113. }
  114. // 根据用户ID获取专栏详情
  115. func GetCygxYanxuanSpecialAuthorByUserId(userId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
  116. o := orm.NewOrmUsingDB("hz_cygx")
  117. sql := `SELECT * FROM cygx_yanxuan_special_author WHERE user_id = ? `
  118. err = o.Raw(sql, userId).QueryRow(&item)
  119. return
  120. }
  121. type CygxYanxuanSpecialCenterAuthorResp struct {
  122. Id int //研选专栏ID
  123. UserId int // 用户ID
  124. PublishTime string // 提审过审或驳回时间
  125. Title string // 标题
  126. }
  127. // 启用禁用作者
  128. func UpdateSpecialAuthormobile_init(mobile_init string, userId int) (err error) {
  129. o := orm.NewOrmUsingDB("hz_cygx")
  130. sql := ``
  131. sql = `UPDATE cygx_yanxuan_special_author SET mobile_init = ? WHERE user_id = ? `
  132. _, err = o.Raw(sql, mobile_init, userId).Exec()
  133. return
  134. }