cygx_yanxuan_special.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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
  68. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id WHERE 1= 1 `
  69. if condition != "" {
  70. sqlCount += condition
  71. }
  72. err = o.Raw(sqlCount, pars).QueryRow(&count)
  73. return
  74. }
  75. func GetYanxuanSpecialList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpeciaResplItem, err error) {
  76. o := orm.NewOrmUsingDB("hz_cygx")
  77. sql := ``
  78. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
  79. FROM cygx_yanxuan_special AS a
  80. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  81. WHERE 1=1 `
  82. if condition != "" {
  83. sql += condition
  84. }
  85. sql += ` LIMIT ?,? `
  86. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  87. return
  88. }
  89. func GetYanxuanSpecialListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpeciaResplItem, err error) {
  90. o := orm.NewOrmUsingDB("hz_cygx")
  91. sql := ``
  92. sql = `SELECT a.*
  93. FROM cygx_yanxuan_special AS a
  94. WHERE 1=1 `
  95. if condition != "" {
  96. sql += condition
  97. }
  98. sql += ` LIMIT ?,? `
  99. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  100. return
  101. }
  102. type EnableCygxYanxuanSpecialReq struct {
  103. Id int // 文章id
  104. Status int // 1通过2驳回
  105. Reason string //理由
  106. }
  107. func EnableYanxuanSpecial(id, status int, reason, adminName string) (err error) {
  108. o := orm.NewOrmUsingDB("hz_cygx")
  109. sql := ``
  110. sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,admin_name = ? , publish_time=NOW() WHERE id = ? `
  111. _, err = o.Raw(sql, status, reason, adminName, id).Exec()
  112. return
  113. }
  114. type CygxYanxuanSpecialItem struct {
  115. Id int `orm:"column(id);pk"`
  116. UserId int // 用户ID
  117. CreateTime string // 创建时间
  118. ModifyTime string // 修改时间
  119. PublishTime string // 提审过审或驳回时间
  120. Content string // 内容
  121. Tags string // 标签
  122. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  123. ImgUrl string // 图片链接
  124. DocUrl string // 文档链接
  125. SpecialName string // 专栏名称
  126. Introduction string // 介绍
  127. Label string // 标签
  128. NickName string // 昵称
  129. RealName string // 姓名
  130. Mobile string // 手机号
  131. HeadImg string // 头像
  132. BgImg string // 背景图
  133. Reason string // 理由
  134. Title string // 标题
  135. Type int // 类型1:笔记,2:观点
  136. CollectNum int
  137. MyCollectNum int
  138. IsCollect int
  139. CompanyTags string
  140. IndustryTags string
  141. ContentHasImg int //正文是否包含图片 1包含 0不包含
  142. Docs []Doc
  143. }
  144. func GetYanxuanSpecialFollowUserById(specialId int) (items []int, err error) {
  145. o := orm.NewOrmUsingDB("hz_cygx")
  146. sql := ``
  147. sql = `SELECT b.user_id
  148. FROM cygx_yanxuan_special AS a
  149. JOIN cygx_yanxuan_special_follow AS b ON a.user_id = b.follow_user_id
  150. WHERE a.id=? `
  151. _, err = o.Raw(sql, specialId).QueryRows(&items)
  152. return
  153. }
  154. func GetYanxuanSpecialItemById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
  155. o := orm.NewOrmUsingDB("hz_cygx")
  156. sql := ``
  157. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
  158. b.nick_name,b.real_name,b.special_name
  159. FROM cygx_yanxuan_special AS a
  160. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  161. WHERE a.id=? `
  162. err = o.Raw(sql, specialId).QueryRow(&item)
  163. return
  164. }
  165. // 获取数量
  166. func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
  167. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special WHERE 1= 1 `
  168. if condition != "" {
  169. sqlCount += condition
  170. }
  171. o := orm.NewOrmUsingDB("hz_cygx")
  172. err = o.Raw(sqlCount, pars).QueryRow(&count)
  173. return
  174. }
  175. type CygxYanxuanSpecialShowButton struct {
  176. IsShowYanXuanSpecial bool // 研选专栏文章管理按钮是否展示
  177. IsShowSpecialAuthor bool // 作者管理的按钮是否展示
  178. }
  179. func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem, err error) {
  180. o := orm.NewOrmUsingDB("hz_cygx")
  181. sql := ``
  182. sql = `SELECT a.* FROM cygx_yanxuan_special AS a WHERE a.id=? `
  183. err = o.Raw(sql, specialId).QueryRow(&item)
  184. return
  185. }
  186. func GetYanxuanSpecialListBycondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecial, err error) {
  187. o := orm.NewOrmUsingDB("hz_cygx")
  188. sql := `SELECT a.* FROM cygx_yanxuan_special AS a WHERE 1=1 `
  189. if condition != "" {
  190. sql += condition
  191. }
  192. if startSize+pageSize > 0 {
  193. sql += ` LIMIT ?,? `
  194. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  195. } else {
  196. _, err = o.Raw(sql, pars).QueryRows(&items)
  197. }
  198. return
  199. }