cygx_yanxuan_special_user.go 5.4 KB

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