cygx_yanxuan_special.go 5.5 KB

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