cygx_yanxuan_special.go 6.3 KB

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