cygx_yanxuan_special.go 4.6 KB

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