cygx_yanxuan_special.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 CygxYanxuanSpecial struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int // 用户ID
  10. CreateTime time.Time // 创建时间
  11. ModifyTime time.Time // 修改时间
  12. PublishTime time.Time // 提审过审或驳回时间
  13. Content string // 内容
  14. Tags string // 标签
  15. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  16. ImgUrl string // 图片链接
  17. DocUrl string // 文档链接
  18. Reason string // 理由
  19. Title string // 标题
  20. Type string // 类型1:笔记,2:观点
  21. }
  22. type CygxYanxuanSpeciaResplItem struct {
  23. Id int `orm:"column(id);pk"`
  24. UserId int // 用户ID
  25. CreateTime string // 创建时间
  26. ModifyTime string // 修改时间
  27. PublishTime string // 提审过审或驳回时间
  28. Content string // 内容
  29. Tags string // 标签
  30. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  31. ImgUrl string // 图片链接
  32. DocUrl string // 文档链接
  33. SpecialName string // 专栏名称
  34. Introduction string // 介绍
  35. Label string // 标签
  36. NickName string // 昵称
  37. RealName string // 姓名
  38. Mobile string // 手机号
  39. HeadImg string // 头像
  40. BgImg string // 背景图
  41. Reason string // 理由
  42. Title string // 标题
  43. CompanyTags string
  44. IndustryTags string
  45. Type int // 类型1:笔记,2:观点
  46. ContentHasImg int //正文是否包含图片 1包含 0不包含
  47. Docs []Doc
  48. Pv string `description:"Pv"`
  49. Uv string `description:"Uv"`
  50. ArticleCollectNum int // 文章收藏数量
  51. AdminName string // 审核人员姓名
  52. SpecialAuthorId int //cygx_yanxuan_special_author 表主键ID 作者专栏ID
  53. }
  54. type Doc struct {
  55. DocName string
  56. DocSuffix string
  57. DocUrl string
  58. DocIcon string
  59. }
  60. type GetCygxYanxuanSpeciaResplItemResp struct {
  61. Paging *paging.PagingItem `description:"分页数据"`
  62. List []*CygxYanxuanSpeciaResplItem
  63. }
  64. // 获取数量
  65. func GetGetYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
  66. o := orm.NewOrmUsingDB("hz_cygx")
  67. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special as a WHERE 1= 1 `
  68. if condition != "" {
  69. sqlCount += condition
  70. }
  71. err = o.Raw(sqlCount, pars).QueryRow(&count)
  72. return
  73. }
  74. func GetYanxuanSpecialList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpeciaResplItem, err error) {
  75. o := orm.NewOrmUsingDB("hz_cygx")
  76. sql := ``
  77. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
  78. FROM cygx_yanxuan_special AS a
  79. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  80. WHERE 1=1 `
  81. if condition != "" {
  82. sql += condition
  83. }
  84. sql += ` LIMIT ?,? `
  85. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  86. return
  87. }
  88. type EnableCygxYanxuanSpecialReq struct {
  89. Id int // 文章id
  90. Status int // 1通过2驳回
  91. Reason string //理由
  92. }
  93. func EnableYanxuanSpecial(id, status int, reason string) (err error) {
  94. o := orm.NewOrmUsingDB("hz_cygx")
  95. sql := ``
  96. sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW() WHERE id = ? `
  97. _, err = o.Raw(sql, status, reason, id).Exec()
  98. return
  99. }
  100. type CygxYanxuanSpecialItem struct {
  101. Id int `orm:"column(id);pk"`
  102. UserId int // 用户ID
  103. CreateTime string // 创建时间
  104. ModifyTime string // 修改时间
  105. PublishTime string // 提审过审或驳回时间
  106. Content string // 内容
  107. Tags string // 标签
  108. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  109. ImgUrl string // 图片链接
  110. DocUrl string // 文档链接
  111. SpecialName string // 专栏名称
  112. Introduction string // 介绍
  113. Label string // 标签
  114. NickName string // 昵称
  115. RealName string // 姓名
  116. Mobile string // 手机号
  117. HeadImg string // 头像
  118. BgImg string // 背景图
  119. Reason string // 理由
  120. Title string // 标题
  121. Type int // 类型1:笔记,2:观点
  122. CollectNum int
  123. MyCollectNum int
  124. IsCollect int
  125. CompanyTags string
  126. IndustryTags string
  127. ContentHasImg int //正文是否包含图片 1包含 0不包含
  128. Docs []Doc
  129. }
  130. func GetYanxuanSpecialFollowUserById(specialId int) (items []int, err error) {
  131. o := orm.NewOrmUsingDB("hz_cygx")
  132. sql := ``
  133. sql = `SELECT b.user_id
  134. FROM cygx_yanxuan_special AS a
  135. JOIN cygx_yanxuan_special_follow AS b ON a.user_id = b.follow_user_id
  136. WHERE a.id=? `
  137. _, err = o.Raw(sql, specialId).QueryRows(&items)
  138. return
  139. }
  140. func GetYanxuanSpecialItemById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
  141. o := orm.NewOrmUsingDB("hz_cygx")
  142. sql := ``
  143. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
  144. b.nick_name,b.real_name,b.special_name
  145. FROM cygx_yanxuan_special AS a
  146. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  147. WHERE a.id=? `
  148. err = o.Raw(sql, specialId).QueryRow(&item)
  149. return
  150. }
  151. // 获取数量
  152. func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
  153. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special WHERE 1= 1 `
  154. if condition != "" {
  155. sqlCount += condition
  156. }
  157. o := orm.NewOrmUsingDB("hz_cygx")
  158. err = o.Raw(sqlCount, pars).QueryRow(&count)
  159. return
  160. }
  161. type CygxYanxuanSpecialShowButton struct {
  162. IsShowSpecialAuthor bool // 作者管理的按钮是否
  163. }