cygx_yanxuan_special.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_mfyx/models/order"
  6. "time"
  7. )
  8. type CygxYanxuanSpecial struct {
  9. Id int `orm:"column(id);pk"`
  10. UserId int // 用户ID
  11. CreateTime time.Time // 创建时间
  12. ModifyTime time.Time // 修改时间
  13. PublishTime time.Time // 提审过审或驳回时间
  14. Content string // 内容
  15. Tags string // 标签
  16. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  17. ImgUrl string // 图片链接
  18. DocUrl string // 文档链接
  19. Reason string // 理由
  20. Title string // 标题
  21. Type int // 类型1:笔记,2:观点
  22. CompanyTags string // 公司标签
  23. IndustryTags string // 行业标签
  24. AdminName string // 审核人员姓名
  25. }
  26. type CygxYanxuanSpecialItem struct {
  27. Id int `orm:"column(id);pk"`
  28. UserId int // 用户ID
  29. CreateTime string // 创建时间
  30. ModifyTime string // 修改时间
  31. PublishTime string // 提审过审或驳回时间
  32. Content string // 内容
  33. Tags string // 标签
  34. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  35. ImgUrl string // 图片链接
  36. DocUrl string // 文档链接
  37. SpecialName string // 专栏名称
  38. Introduction string // 介绍
  39. Label string // 标签
  40. NickName string // 昵称
  41. RealName string // 姓名
  42. Mobile string // 手机号
  43. HeadImg string // 头像
  44. BgImg string // 背景图
  45. Reason string // 理由
  46. Title string // 标题
  47. Type int // 类型1:笔记,2:观点
  48. CollectNum int
  49. MyCollectNum int
  50. IsCollect int
  51. CompanyTags string
  52. IndustryTags string
  53. ContentHasImg int //正文是否包含图片 1包含 0不包含
  54. ContentHasStyle bool //正文是否包含格式
  55. Docs []Doc
  56. Pv int `description:"Pv"`
  57. Uv int `description:"Uv"`
  58. HzPv int `description:"HzPv"`
  59. MomentsImg string `description:"分享到朋友圈的封面图片"`
  60. LikeCount int `comment:"点赞数量"`
  61. IsLikeCount bool `comment:"是否点赞"`
  62. }
  63. type CygxYanxuanSpecialResp struct {
  64. CygxYanxuanSpecialItem
  65. Docs []Doc
  66. CompanyTags []string
  67. IndustryTags []string
  68. HasPermission int `description:"1:正常展示,2:不展示"`
  69. ExamineStatus int `description:"1:未发布,2:审核中 3:已发布 4:驳回"`
  70. IsShowExamine bool `description:"是否展示审核状态按钮"`
  71. PopupPriceMsg string `description:"价格弹窗信息"`
  72. IsShowWxPay bool `description:"是否展示微信支付"`
  73. IsCompanyApply bool `description:"机构是否申请过试用"`
  74. IsNeedBusinessCard bool `description:"是否需要上传名片"`
  75. GoodsList []*order.CygxGoodsResp `description:"商品信息"`
  76. }
  77. type CygxYanxuanSpecialCenterResp struct {
  78. Id int `orm:"column(id);pk"`
  79. UserId int // 用户ID
  80. CreateTime string // 创建时间
  81. ModifyTime string // 修改时间
  82. PublishTime string // 提审过审或驳回时间
  83. Content string // 内容
  84. Tags string // 标签
  85. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  86. ImgUrl string // 图片链接
  87. DocUrl string // 文档链接
  88. SpecialName string // 专栏名称
  89. Introduction string // 介绍
  90. Label string // 标签
  91. NickName string // 昵称
  92. RealName string // 姓名
  93. Mobile string // 手机号
  94. HeadImg string // 头像
  95. BgImg string // 背景图
  96. Reason string // 理由
  97. Title string // 标题
  98. Type int // 类型1:笔记,2:观点
  99. CollectNum int
  100. MyCollectNum int
  101. IsCollect int
  102. CompanyTags string
  103. IndustryTags string
  104. ContentHasImg int //正文是否包含图片 1包含 0不包含
  105. ContentHasStyle bool //正文是否包含格式
  106. Docs []Doc
  107. Annotation string `description:"核心观点"`
  108. Source string `description:"来源"`
  109. Pv int `description:"Pv"`
  110. Uv int `description:"Uv"`
  111. HzPv int `description:"HzPv"`
  112. PublishDate string // 提审过审或驳回时间 string `description:"核心观点"`
  113. BodyHighlight []string `description:"搜索高亮展示结果"`
  114. LabelKeyword string `description:"标签关键词"`
  115. LabelKeywordImgLink string `description:"标签关键词ico"`
  116. LikeCount int `comment:"点赞数量"`
  117. IsLikeCount bool `comment:"是否点赞"`
  118. }
  119. type Doc struct {
  120. DocName string
  121. DocSuffix string
  122. DocUrl string
  123. DocIcon string
  124. }
  125. func GetYanxuanSpecialList(userId int, condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialCenterResp, err error) {
  126. o := orm.NewOrm()
  127. sql := ``
  128. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,
  129. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  130. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
  131. FROM cygx_yanxuan_special AS a
  132. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  133. WHERE 1=1 `
  134. if condition != "" {
  135. sql += condition
  136. }
  137. sql += `ORDER BY a.publish_time DESC `
  138. if startSize+pageSize > 0 {
  139. sql += ` LIMIT ?,? `
  140. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  141. } else {
  142. _, err = o.Raw(sql, userId, pars).QueryRows(&items)
  143. }
  144. return
  145. }
  146. func GetYanxuanSpecialListBycondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialCenterResp, err error) {
  147. o := orm.NewOrm()
  148. sql := `SELECT a.* FROM cygx_yanxuan_special AS a WHERE 1=1 `
  149. if condition != "" {
  150. sql += condition
  151. }
  152. if startSize+pageSize > 0 {
  153. sql += ` LIMIT ?,? `
  154. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  155. } else {
  156. _, err = o.Raw(sql, pars).QueryRows(&items)
  157. }
  158. return
  159. }
  160. type EnableCygxYanxuanSpecialReq struct {
  161. Id int // 文章id
  162. Status int // 1通过2驳回
  163. Reason string //理由
  164. }
  165. func EnableYanxuanSpecial(id, status int, reason, adminName string) (err error) {
  166. o := orm.NewOrm()
  167. sql := ``
  168. sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,admin_name = ? , publish_time=NOW() WHERE id = ? `
  169. _, err = o.Raw(sql, status, reason, adminName, id).Exec()
  170. return
  171. }
  172. type SpecialListResp struct {
  173. IsAuthor bool `description:"是否开通了研选专栏"`
  174. IsImproveInformation bool `description:"作者信息是否完善"`
  175. Paging *paging.PagingItem `description:"分页数据"`
  176. List []*CygxYanxuanSpecialCenterResp
  177. }
  178. func GetYanxuanSpecialById(specialId, userId int) (item *CygxYanxuanSpecialItem, err error) {
  179. o := orm.NewOrm()
  180. sql := ``
  181. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
  182. b.nick_name,b.real_name,b.special_name,
  183. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  184. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num
  185. FROM cygx_yanxuan_special AS a
  186. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  187. WHERE a.id=? `
  188. err = o.Raw(sql, userId, specialId).QueryRow(&item)
  189. return
  190. }
  191. func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem, err error) {
  192. o := orm.NewOrm()
  193. sql := ``
  194. sql = `SELECT a.*
  195. FROM cygx_yanxuan_special AS a
  196. WHERE a.id=? `
  197. err = o.Raw(sql, specialId).QueryRow(&item)
  198. return
  199. }
  200. type CygxYanxuanSpecialReq struct {
  201. Id int `orm:"column(id);pk"`
  202. Content string // 内容
  203. Tags string // 标签
  204. DoType int // 1保存 2发布
  205. ImgUrl string // 图片链接
  206. DocUrl string // 文档链接
  207. Title string // 标题
  208. Type int // 类型1:笔记,2:观点
  209. IndustryTags string // 行业标签
  210. CompanyTags string // 公司标签
  211. IsApprovalPersonnel bool // 是否是审批人员操作
  212. }
  213. func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
  214. o := orm.NewOrm()
  215. lastId, err = o.Insert(item)
  216. return
  217. }
  218. func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
  219. o := orm.NewOrm()
  220. sql := ``
  221. sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,company_tags=?,industry_tags=?,img_url=?,doc_url=?,type=?,status=?,
  222. modify_time=NOW(),publish_time=NOW(),admin_name = ? WHERE id = ? `
  223. _, err = o.Raw(sql, item.Title, item.Content, item.CompanyTags, item.IndustryTags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.AdminName, item.Id).Exec()
  224. return
  225. }
  226. func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
  227. o := orm.NewOrm()
  228. sql := ``
  229. if keyword == "" {
  230. sql = `SELECT industry_name FROM cygx_yanxuan_special_industry `
  231. } else {
  232. sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%` + keyword + `%' `
  233. }
  234. _, err = o.Raw(sql).QueryRows(&IndustryNames)
  235. return
  236. }
  237. type CancelPublishCygxYanxuanSpecialReq struct {
  238. Id int // 文章id
  239. }
  240. func CancelPublishYanxuanSpecial(id int) (err error) {
  241. o := orm.NewOrm()
  242. sql := ``
  243. sql = `UPDATE cygx_yanxuan_special SET status=1,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
  244. _, err = o.Raw(sql, id).Exec()
  245. return
  246. }
  247. type DelCygxYanxuanSpecialReq struct {
  248. Id int // 文章id
  249. }
  250. func DelYanxuanSpecial(id int) (err error) {
  251. o := orm.NewOrm()
  252. sql := ``
  253. sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
  254. _, err = o.Raw(sql, id).Exec()
  255. return
  256. }
  257. type CygxYanxuanSpecialCheckReq struct {
  258. Content string // 内容
  259. ImgUrl []string // 图片
  260. }
  261. func GetYanxuanSpecialFollowUserById(specialId int) (items []int, err error) {
  262. o := orm.NewOrm()
  263. sql := ``
  264. sql = `SELECT b.user_id
  265. FROM cygx_yanxuan_special AS a
  266. JOIN cygx_yanxuan_special_follow AS b ON a.user_id = b.follow_user_id
  267. WHERE a.id=? `
  268. _, err = o.Raw(sql, specialId).QueryRows(&items)
  269. return
  270. }
  271. func GetYanxuanSpecialItemById(specialId int) (item *CygxYanxuanSpecialItem, err error) {
  272. o := orm.NewOrm()
  273. sql := ``
  274. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
  275. b.nick_name,b.real_name,b.special_name
  276. FROM cygx_yanxuan_special AS a
  277. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  278. WHERE a.id=? `
  279. err = o.Raw(sql, specialId).QueryRow(&item)
  280. return
  281. }
  282. // 获取数量
  283. func GetCygxYanxuanSpecialCount(condition string, pars []interface{}) (count int, err error) {
  284. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special as a WHERE 1= 1 `
  285. if condition != "" {
  286. sqlCount += condition
  287. }
  288. o := orm.NewOrm()
  289. err = o.Raw(sqlCount, pars).QueryRow(&count)
  290. return
  291. }
  292. // UpdateYanxuanSpecialPv 修改研选专栏的阅读Pv
  293. func UpdateYanxuanSpecialPv(id int) (err error) {
  294. o := orm.NewOrm()
  295. sql := `UPDATE cygx_yanxuan_special SET pv=pv+1 WHERE id = ? `
  296. _, err = o.Raw(sql, id).Exec()
  297. return
  298. }
  299. // UpdateYanxuanSpecialHzPv 修改研选专栏的阅读弘则Pv
  300. func UpdateYanxuanSpecialHzPv(id int) (err error) {
  301. o := orm.NewOrm()
  302. sql := `UPDATE cygx_yanxuan_special SET hz_pv=hz_pv+1 WHERE id = ? `
  303. _, err = o.Raw(sql, id).Exec()
  304. return
  305. }
  306. // UpdateYanxuanSpecialUv 修改研选专栏的阅读Uv
  307. func UpdateYanxuanSpecialUv(id int) (err error) {
  308. o := orm.NewOrm()
  309. sql := `UPDATE cygx_yanxuan_special SET uv=uv+1 WHERE id = ? `
  310. _, err = o.Raw(sql, id).Exec()
  311. return
  312. }
  313. // UpdateYanxuanSpecialHzUv 修改研选专栏的阅读弘则Uv
  314. func UpdateYanxuanSpecialHzUv(id int) (err error) {
  315. o := orm.NewOrm()
  316. sql := `UPDATE cygx_yanxuan_special SET hz_uv=hz_uv+1 WHERE id = ? `
  317. _, err = o.Raw(sql, id).Exec()
  318. return
  319. }
  320. func UpdateYanxuanSpecialPvNUm(pv, id int) (err error) {
  321. o := orm.NewOrm()
  322. sql := `UPDATE cygx_yanxuan_special SET pv = ? WHERE id = ? `
  323. _, err = o.Raw(sql, pv, id).Exec()
  324. return
  325. }
  326. func UpdateYanxuanSpecialUvUm(pv, id int) (err error) {
  327. o := orm.NewOrm()
  328. sql := `UPDATE cygx_yanxuan_special SET uv = ? WHERE id = ? `
  329. _, err = o.Raw(sql, pv, id).Exec()
  330. return
  331. }
  332. // 增加收藏数量
  333. func UpdateYanxuanSpecialarticleCollectNumIncrease(id int) (err error) {
  334. o := orm.NewOrm()
  335. sql := ``
  336. sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num +1 WHERE id = ? `
  337. _, err = o.Raw(sql, id).Exec()
  338. return
  339. }
  340. // 减少收藏数量
  341. func UpdateYanxuanSpecialarticleCollectNumReduce(id int) (err error) {
  342. o := orm.NewOrm()
  343. sql := ``
  344. sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num - 1 WHERE id = ? `
  345. _, err = o.Raw(sql, id).Exec()
  346. return
  347. }
  348. // 更新收藏数量
  349. func UpdateYanxuanSpecialarticleCollectNum(collectNum, id int) (err error) {
  350. o := orm.NewOrm()
  351. sql := ``
  352. sql = `UPDATE cygx_yanxuan_special SET article_collect_num = ? WHERE id = ? `
  353. _, err = o.Raw(sql, collectNum, id).Exec()
  354. return
  355. }