cygx_yanxuan_special.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecial struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int // 用户ID
  9. CreateTime time.Time // 创建时间
  10. ModifyTime time.Time // 修改时间
  11. PublishTime time.Time // 提审过审或驳回时间
  12. Content string // 内容
  13. Tags string // 标签
  14. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  15. ImgUrl string // 图片链接
  16. DocUrl string // 文档链接
  17. Reason string // 理由
  18. Title string // 标题
  19. Type int // 类型1:笔记,2:观点
  20. CompanyTags string // 公司标签
  21. IndustryTags string // 行业标签
  22. }
  23. type CygxYanxuanSpecialItem struct {
  24. Id int `orm:"column(id);pk"`
  25. UserId int // 用户ID
  26. CreateTime string // 创建时间
  27. ModifyTime string // 修改时间
  28. PublishTime string // 提审过审或驳回时间
  29. Content string // 内容
  30. Tags string // 标签
  31. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  32. ImgUrl string // 图片链接
  33. DocUrl string // 文档链接
  34. SpecialName string // 专栏名称
  35. Introduction string // 介绍
  36. Label string // 标签
  37. NickName string // 昵称
  38. RealName string // 姓名
  39. Mobile string // 手机号
  40. HeadImg string // 头像
  41. BgImg string // 背景图
  42. Reason string // 理由
  43. Title string // 标题
  44. Type int // 类型1:笔记,2:观点
  45. CollectNum int
  46. MyCollectNum int
  47. IsCollect int
  48. CompanyTags string
  49. IndustryTags string
  50. ContentHasImg int //正文是否包含图片 1包含 0不包含
  51. Docs []Doc
  52. }
  53. type CygxYanxuanSpecialResp struct {
  54. CygxYanxuanSpecialItem
  55. Docs []Doc
  56. CompanyTags []string
  57. IndustryTags []string
  58. }
  59. type CygxYanxuanSpecialCenterResp struct {
  60. Id int `orm:"column(id);pk"`
  61. UserId int // 用户ID
  62. CreateTime string // 创建时间
  63. ModifyTime string // 修改时间
  64. PublishTime string // 提审过审或驳回时间
  65. Content string // 内容
  66. Tags string // 标签
  67. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  68. ImgUrl string // 图片链接
  69. DocUrl string // 文档链接
  70. SpecialName string // 专栏名称
  71. Introduction string // 介绍
  72. Label string // 标签
  73. NickName string // 昵称
  74. RealName string // 姓名
  75. Mobile string // 手机号
  76. HeadImg string // 头像
  77. BgImg string // 背景图
  78. Reason string // 理由
  79. Title string // 标题
  80. Type int // 类型1:笔记,2:观点
  81. CollectNum int
  82. MyCollectNum int
  83. IsCollect int
  84. CompanyTags string
  85. IndustryTags string
  86. ContentHasImg int //正文是否包含图片 1包含 0不包含
  87. ContentHasStyle bool //正文是否包含格式
  88. Docs []Doc
  89. }
  90. type Doc struct {
  91. DocName string
  92. DocSuffix string
  93. DocUrl string
  94. DocIcon string
  95. }
  96. func GetYanxuanSpecialList(userId int, condition string, pars []interface{}) (items []*CygxYanxuanSpecialCenterResp, err error) {
  97. o := orm.NewOrm()
  98. sql := ``
  99. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,
  100. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  101. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
  102. FROM cygx_yanxuan_special AS a
  103. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  104. WHERE 1=1 `
  105. if condition != "" {
  106. sql += condition
  107. }
  108. sql += `ORDER BY a.publish_time DESC `
  109. _, err = o.Raw(sql, userId, pars).QueryRows(&items)
  110. return
  111. }
  112. type EnableCygxYanxuanSpecialReq struct {
  113. Id int // 文章id
  114. Status int // 1通过2驳回
  115. Reason string //理由
  116. }
  117. func EnableYanxuanSpecial(id, status int, reason string) (err error) {
  118. o := orm.NewOrm()
  119. sql := ``
  120. sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
  121. _, err = o.Raw(sql, status, reason, id).Exec()
  122. return
  123. }
  124. type SpecialListResp struct {
  125. List []*CygxYanxuanSpecialCenterResp
  126. IsAuthor bool
  127. }
  128. func GetYanxuanSpecialById(specialId, userId int) (item *CygxYanxuanSpecialItem, err error) {
  129. o := orm.NewOrm()
  130. sql := ``
  131. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
  132. b.nick_name,b.real_name,b.special_name,
  133. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  134. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
  135. FROM cygx_yanxuan_special AS a
  136. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  137. WHERE a.id=? `
  138. err = o.Raw(sql, userId, specialId).QueryRow(&item)
  139. return
  140. }
  141. type CygxYanxuanSpecialReq struct {
  142. Id int `orm:"column(id);pk"`
  143. Content string // 内容
  144. Tags string // 标签
  145. DoType int // 1保存 2发布
  146. ImgUrl string // 图片链接
  147. DocUrl string // 文档链接
  148. Title string // 标题
  149. Type int // 类型1:笔记,2:观点
  150. IndustryTags string // 行业标签
  151. CompanyTags string // 公司标签
  152. }
  153. func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
  154. o := orm.NewOrm()
  155. lastId, err = o.Insert(item)
  156. return
  157. }
  158. func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
  159. o := orm.NewOrm()
  160. sql := ``
  161. sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,tags=?,img_url=?,doc_url=?,type=?,status=?,
  162. modify_time=NOW(),publish_time=NOW() WHERE id = ? `
  163. _, err = o.Raw(sql, item.Title, item.Content, item.Tags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
  164. return
  165. }
  166. func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
  167. o := orm.NewOrm()
  168. sql := ``
  169. if keyword == "" {
  170. sql = `SELECT industry_name FROM cygx_yanxuan_special_industry `
  171. } else {
  172. sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%` + keyword + `%' `
  173. }
  174. _, err = o.Raw(sql).QueryRows(&IndustryNames)
  175. return
  176. }
  177. type CancelPublishCygxYanxuanSpecialReq struct {
  178. Id int // 文章id
  179. }
  180. func CancelPublishYanxuanSpecial(id int) (err error) {
  181. o := orm.NewOrm()
  182. sql := ``
  183. sql = `UPDATE cygx_yanxuan_special SET status=1,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
  184. _, err = o.Raw(sql, id).Exec()
  185. return
  186. }
  187. type DelCygxYanxuanSpecialReq struct {
  188. Id int // 文章id
  189. }
  190. func DelYanxuanSpecial(id int) (err error) {
  191. o := orm.NewOrm()
  192. sql := ``
  193. sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
  194. _, err = o.Raw(sql, id).Exec()
  195. return
  196. }
  197. type CygxYanxuanSpecialCheckReq struct {
  198. Content string // 内容
  199. ImgUrl []string // 图片
  200. }