cygx_yanxuan_special.go 13 KB

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