article.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/services"
  6. "hongze/hongze_cygx/utils"
  7. "html"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. type ArticleController struct {
  13. BaseAuthController
  14. }
  15. type ArticleCommonController struct {
  16. BaseCommonController
  17. }
  18. // @Title 获取报告详情
  19. // @Description 获取报告详情接口
  20. // @Param ArticleId query int true "报告ID"
  21. // @Success 200 {object} models.ArticleDetailResp
  22. // @router /detail [get]
  23. func (this *ArticleController) Detail() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. user := this.User
  30. if user == nil {
  31. br.Msg = "请登录"
  32. br.ErrMsg = "请登录,用户信息为空"
  33. br.Ret = 408
  34. return
  35. }
  36. uid := user.UserId
  37. articleId, err := this.GetInt("ArticleId")
  38. if articleId <= 0 {
  39. br.Msg = "参数错误"
  40. br.ErrMsg = "参数错误"
  41. return
  42. }
  43. detail := new(models.ArticleDetail)
  44. hasPermission := 0
  45. hasFree := 0
  46. //判断是否已经申请过
  47. applyCount, err := models.GetApplyRecordCount(uid)
  48. if err != nil && err.Error() != utils.ErrNoRow() {
  49. br.Msg = "获取信息失败"
  50. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  51. return
  52. }
  53. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  54. if user.CompanyId > 1 {
  55. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  56. if err != nil {
  57. br.Msg = "获取信息失败"
  58. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  59. return
  60. }
  61. detail, err = models.GetArticleDetailById(articleId)
  62. if err != nil {
  63. br.Msg = "获取信息失败"
  64. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  65. return
  66. }
  67. detail.Body = html.UnescapeString(detail.Body)
  68. detail.Abstract = html.UnescapeString(detail.Abstract)
  69. if companyPermission == "" {
  70. if applyCount > 0 {
  71. hasPermission = 5
  72. } else {
  73. hasPermission = 2
  74. }
  75. hasFree = 2
  76. goto Loop
  77. } else {
  78. hasFree = 1
  79. // 原有的权限校验 更改于 2021-05-18
  80. //articlePermission, err := models.GetArticlePermission(detail.SubCategoryName)
  81. //fmt.Println(articlePermission)
  82. //fmt.Println(detail.SubCategoryName)
  83. //if err != nil {
  84. // br.Msg = "获取信息失败"
  85. // br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  86. // return
  87. //}
  88. //if articlePermission == nil {
  89. // br.Msg = "获取信息失败"
  90. // br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  91. // return
  92. //}
  93. //for _, p := range articlePermission {
  94. // if strings.Contains(companyPermission, p.PermissionName) {
  95. // hasPermission = 1
  96. // historyRecord := new(models.CygxArticleHistoryRecord)
  97. // historyRecord.UserId = uid
  98. // historyRecord.ArticleId = articleId
  99. // historyRecord.CreateTime = time.Now()
  100. // historyRecord.Mobile = user.Mobile
  101. // historyRecord.Email = user.Email
  102. // historyRecord.CompanyId = user.CompanyId
  103. // historyRecord.CompanyName = user.CompanyName
  104. // go models.AddCygxArticleHistoryRecord(historyRecord)
  105. // break
  106. // } else { //无该行业权限
  107. // hasPermission = 3
  108. // }
  109. //}
  110. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  111. if err != nil {
  112. br.Msg = "获取信息失败"
  113. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  114. return
  115. }
  116. if articlePermission == nil {
  117. br.Msg = "获取信息失败"
  118. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  119. return
  120. }
  121. if strings.Contains(companyPermission, articlePermission.PermissionName) {
  122. hasPermission = 1
  123. historyRecord := new(models.CygxArticleHistoryRecord)
  124. historyRecord.UserId = uid
  125. historyRecord.ArticleId = articleId
  126. historyRecord.CreateTime = time.Now()
  127. historyRecord.Mobile = user.Mobile
  128. historyRecord.Email = user.Email
  129. historyRecord.CompanyId = user.CompanyId
  130. historyRecord.CompanyName = user.CompanyName
  131. go models.AddCygxArticleHistoryRecord(historyRecord)
  132. } else { //无该行业权限
  133. hasPermission = 3
  134. }
  135. if hasPermission == 1 {
  136. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  137. if !utils.Rc.IsExist(key) {
  138. //新增浏览记录
  139. record := new(models.CygxArticleViewRecord)
  140. record.UserId = uid
  141. record.ArticleId = articleId
  142. record.CreateTime = time.Now()
  143. record.Mobile = user.Mobile
  144. record.Email = user.Email
  145. record.CompanyId = user.CompanyId
  146. record.CompanyName = user.CompanyName
  147. go models.AddCygxArticleViewRecord(record)
  148. utils.Rc.Put(key, 1, 5*time.Second)
  149. models.ModifyReportLastViewTime(uid)
  150. }
  151. }
  152. }
  153. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  154. if err != nil && err.Error() != utils.ErrNoRow() {
  155. br.Msg = "获取信息失败"
  156. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  157. return
  158. }
  159. if collectCount > 0 {
  160. detail.IsCollect = true
  161. }
  162. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  163. if err != nil && err.Error() != utils.ErrNoRow() {
  164. br.Msg = "获取信息失败"
  165. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  166. return
  167. }
  168. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  169. detail.IsInterviewApply = true
  170. detail.InterviewApplyStatus = interviewApplyItem.Status
  171. }
  172. //获取销售手机号
  173. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  174. if err != nil {
  175. br.Msg = "获取信息失败"
  176. br.ErrMsg = "获取销售数据失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  177. return
  178. }
  179. if sellerItem != nil {
  180. detail.SellerMobile = sellerItem.Mobile
  181. detail.SellerName = sellerItem.RealName
  182. }
  183. sellerList, err := models.GetSellerList(articleId)
  184. if err != nil {
  185. br.Msg = "获取信息失败"
  186. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  187. return
  188. }
  189. detail.SellerList = sellerList
  190. } else { //潜在客户
  191. if applyCount > 0 {
  192. hasPermission = 5
  193. } else {
  194. hasPermission = 4
  195. }
  196. }
  197. Loop:
  198. if hasPermission != 1 {
  199. detail.Body = ""
  200. detail.BodyText = ""
  201. }
  202. resp := new(models.ArticleDetailResp)
  203. resp.HasPermission = hasPermission
  204. resp.HasFree = hasFree
  205. resp.Detail = detail
  206. br.Ret = 200
  207. br.Success = true
  208. br.Msg = "获取成功"
  209. br.Data = resp
  210. }
  211. // @Title 收藏
  212. // @Description 收藏
  213. // @Param request body models.ArticleCollectReq true "type json string"
  214. // @Success 200 {object} models.FontsCollectResp
  215. // @router /collect [post]
  216. func (this *ArticleController) ArticleCollect() {
  217. br := new(models.BaseResponse).Init()
  218. defer func() {
  219. this.Data["json"] = br
  220. this.ServeJSON()
  221. }()
  222. user := this.User
  223. if user == nil {
  224. br.Msg = "请重新登录"
  225. br.Ret = 408
  226. return
  227. }
  228. uid := user.UserId
  229. var req models.ArticleCollectReq
  230. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  231. if err != nil {
  232. br.Msg = "参数解析异常!"
  233. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  234. return
  235. }
  236. count, err := models.GetArticleCollectCount(uid, req.ArticleId)
  237. if err != nil {
  238. br.Msg = "获取数据失败!"
  239. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  240. return
  241. }
  242. resp := new(models.ArticleCollectResp)
  243. if count <= 0 {
  244. item := new(models.CygxArticleCollect)
  245. item.ArticleId = req.ArticleId
  246. item.UserId = uid
  247. item.CreateTime = time.Now()
  248. _, err = models.AddCygxArticleCollect(item)
  249. if err != nil {
  250. br.Msg = "收藏失败"
  251. br.ErrMsg = "收藏失败,Err:" + err.Error()
  252. return
  253. }
  254. br.Msg = "收藏成功"
  255. resp.Status = 1
  256. } else {
  257. err = models.RemoveArticleCollect(uid, req.ArticleId)
  258. if err != nil {
  259. br.Msg = "取消收藏失败"
  260. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  261. return
  262. }
  263. br.Msg = "已取消收藏"
  264. resp.Status = 2
  265. }
  266. collectTotal, err := models.GetArticleCollectUsersCount(req.ArticleId)
  267. if err != nil {
  268. br.Msg = "获取数据失败"
  269. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  270. return
  271. }
  272. resp.CollectCount = collectTotal
  273. br.Ret = 200
  274. br.Success = true
  275. br.Data = resp
  276. }
  277. // @Title 访谈申请
  278. // @Description 访谈申请
  279. // @Param request body models.ArticleInterviewApplyReq true "type json string"
  280. // @Success 200 {object} models.FontsCollectResp
  281. // @router /interview/apply [post]
  282. func (this *ArticleController) InterviewApply() {
  283. br := new(models.BaseResponse).Init()
  284. defer func() {
  285. this.Data["json"] = br
  286. this.ServeJSON()
  287. }()
  288. user := this.User
  289. if user == nil {
  290. br.Msg = "请重新登录"
  291. br.Ret = 408
  292. return
  293. }
  294. uid := user.UserId
  295. var req models.ArticleInterviewApplyReq
  296. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  297. if err != nil {
  298. br.Msg = "参数解析异常!"
  299. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  300. return
  301. }
  302. article, err := models.GetArticleDetailById(req.ArticleId)
  303. if err != nil {
  304. br.Msg = "获取纪要失败!"
  305. br.ErrMsg = "获取纪要失败,Err:" + err.Error()
  306. return
  307. }
  308. count, err := models.GetArticleInterviewApplyCount(uid, req.ArticleId)
  309. if err != nil {
  310. br.Msg = "获取数据失败!"
  311. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  312. return
  313. }
  314. resp := new(models.ArticleInterviewApplyResp)
  315. if count <= 0 {
  316. item := new(models.CygxInterviewApply)
  317. item.ArticleId = req.ArticleId
  318. item.UserId = uid
  319. item.CompanyId = user.CompanyId
  320. item.Status = "待邀请"
  321. item.Sort = 1
  322. item.ArticleTitle = article.Title
  323. item.CreateTime = time.Now()
  324. item.ModifyTime = time.Now()
  325. item.ArticleIdMd5 = article.ArticleIdMd5
  326. _, err = models.AddCygxInterviewApply(item)
  327. if err != nil {
  328. br.Msg = "申请失败"
  329. br.ErrMsg = "申请失败,Err:" + err.Error()
  330. return
  331. }
  332. br.Msg = "申请成功"
  333. resp.Status = 1
  334. //发送模板消息
  335. if user.CompanyId > 1 {
  336. mobile := user.Mobile
  337. if mobile == "" {
  338. mobile = user.Email
  339. }
  340. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  341. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  342. openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
  343. if openIpItem != nil && openIpItem.OpenId != "" {
  344. go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
  345. }
  346. }
  347. }
  348. } else {
  349. err = models.RemoveArticleInterviewApply(uid, req.ArticleId)
  350. if err != nil {
  351. br.Msg = "取消申请失败"
  352. br.ErrMsg = "取消申请失败,Err:" + err.Error()
  353. return
  354. }
  355. br.Msg = "已取消申请"
  356. resp.Status = 2
  357. if user.CompanyId > 1 {
  358. mobile := user.Mobile
  359. if mobile == "" {
  360. mobile = user.Email
  361. }
  362. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  363. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  364. openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
  365. if openIpItem != nil && openIpItem.OpenId != "" {
  366. go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
  367. }
  368. }
  369. }
  370. }
  371. br.Ret = 200
  372. br.Success = true
  373. br.Data = resp
  374. }
  375. // @Title 获取报告详情
  376. // @Description 获取报告详情接口
  377. // @Param ArticleIdMd5 query int true "报告ID"
  378. // @Success 200 {object} models.ArticleDetailResp
  379. // @router /look/detail [get]
  380. func (this *ArticleCommonController) Detail() {
  381. br := new(models.BaseResponse).Init()
  382. defer func() {
  383. this.Data["json"] = br
  384. this.ServeJSON()
  385. }()
  386. articleIdMd5 := this.GetString("ArticleIdMd5")
  387. if articleIdMd5 == "" {
  388. br.Msg = "参数错误"
  389. br.ErrMsg = "参数错误"
  390. return
  391. }
  392. resp := new(models.ArticleDetailResp)
  393. detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
  394. if err != nil && err.Error() != utils.ErrNoRow() {
  395. br.Msg = "获取信息失败"
  396. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  397. return
  398. }
  399. if detail == nil {
  400. resp.HasPermission = 2
  401. } else {
  402. resp.HasPermission = 1
  403. }
  404. if detail != nil {
  405. detail.Body = html.UnescapeString(detail.Body)
  406. detail.Abstract = html.UnescapeString(detail.Abstract)
  407. }
  408. sellerList, err := models.GetSellerList(detail.ArticleId)
  409. if err != nil {
  410. br.Msg = "获取信息失败"
  411. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(detail.ArticleId)
  412. return
  413. }
  414. detail.SellerList = sellerList
  415. resp.Detail = detail
  416. br.Ret = 200
  417. br.Success = true
  418. br.Msg = "获取成功"
  419. br.Data = resp
  420. }
  421. // @Title 获取报告同步
  422. // @Description 获取报告详情接口
  423. // @Param ArticleIdMd5 query int true "报告ID"
  424. // @Success 200 {object} models.ArticleDetailResp
  425. // @router /tongbu [get]
  426. //func (this *ArticleCommonController) Tongbu() {
  427. // br := new(models.BaseResponse).Init()
  428. // defer func() {
  429. // this.Data["json"] = br
  430. // this.ServeJSON()
  431. // }()
  432. //
  433. // fmt.Println("同步数据")
  434. // indexName := utils.IndexName
  435. // fmt.Println(indexName)
  436. // endDate := time.Now().AddDate(0, 0, -7).Format(utils.FormatDate)
  437. // list, err := models.GetTacticsList(endDate)
  438. // //list, err := models.GetTacticsListAll2()
  439. // if err != nil {
  440. // fmt.Println("GetTacticsList Err:", err.Error())
  441. // return
  442. // }
  443. // fmt.Println("list len:", len(list))
  444. //
  445. // summaryCategoryIds := "28,32,45,50,57,62,72,74,79,84,86,88,90,95,96" //纪要库的文章类型ID
  446. // listSummarys := strings.Split(summaryCategoryIds, ",")
  447. // fmt.Println(listSummarys)
  448. // for _, v := range listSummarys {
  449. // vs, _ := strconv.Atoi(v)
  450. // fmt.Printf("n 的类型 %T", vs)
  451. // }
  452. //
  453. // for _, v := range list {
  454. // for _, vs := range listSummarys {
  455. // vint, _ := strconv.Atoi(vs)
  456. // //fmt.Printf("vint 的类型 %T", vint)
  457. // //fmt.Println("————————————")
  458. // //fmt.Printf("vCategoryId 的类型 %T", v.CategoryId)
  459. // //fmt.Println("————————————")
  460. //
  461. // if v.CategoryId == vint {
  462. //
  463. // }
  464. // }
  465. // }
  466. //
  467. // br.Msg = "测试!"
  468. // br.ErrMsg = "参数解析失败,Err:"
  469. // return
  470. //listSummary, errsu := models.GetReportMappingCategoryID()
  471. //if errsu != nil {
  472. // fmt.Println("GetTacticsList Err:", errsu.Error())
  473. // return
  474. //}
  475. //
  476. //listPermission, errper := models.GetPermissionMappingCategoryID()
  477. //if errper != nil {
  478. // fmt.Println("GetTacticsList Err:", errper.Error())
  479. // return
  480. //}
  481. //for k, v := range list {
  482. //
  483. // //是否属于纪要库
  484. // //countSummary, err := models.GetPermissionMappingById(v.CategoryId)
  485. // //if err != nil && err.Error() != utils.ErrNoRow() {
  486. // // br.Msg = "参数解析异常!"
  487. // // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  488. // // return
  489. // //}
  490. // //if countSummary > 0 {
  491. // // v.IsSummary = 1
  492. // //}
  493. // for _, vSum := range listSummary {
  494. // if v.CategoryId == vSum.CategoryId {
  495. // v.IsSummary = 1
  496. // }
  497. // }
  498. // //是否属于报告
  499. // //countReport, err := models.GetReportMappingById(v.CategoryId)
  500. // //if err != nil && err.Error() != utils.ErrNoRow() {
  501. // // br.Msg = "参数解析异常!"
  502. // // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  503. // // return
  504. // //}
  505. // for _, vPer := range listPermission {
  506. // if v.CategoryId == vPer.CategoryId {
  507. // v.IsReport = 1
  508. // }
  509. // }
  510. // if v.IsReport > 0 {
  511. // //是否属于策略 策略自动归类
  512. // //是否属于行业报告 行业报告自动归类
  513. // if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 || v.CategoryId == 64 || v.CategoryId == 80 || v.CategoryId == 87 {
  514. // v.IsClass = 1
  515. // }
  516. // if v.CategoryId == 64 || v.CategoryId == 87 || v.CategoryId == 80 {
  517. // v.ReportType = 2 //是否属于行业报告
  518. // } else {
  519. // v.ReportType = 1 //是否属于产业报告
  520. // }
  521. // }
  522. // v.Department = "弘则权益研究"
  523. // fmt.Println(k, v.ArticleId)
  524. // hh, _ := time.ParseDuration("8h")
  525. // //pDate := publishDate.Add(hh)
  526. // v.PublishDate = v.PublishDate.Add(hh)
  527. // //判断是否已经存在
  528. // if v.ArticleId < 0 {
  529. // if err != nil {
  530. // br.Msg = "参数解析异常!"
  531. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  532. // return
  533. // }
  534. // }
  535. // count, err := models.GetArticleCountById(v.ArticleId)
  536. // if err != nil && err.Error() != utils.ErrNoRow() {
  537. // br.Msg = "参数解析异常!"
  538. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  539. // return
  540. // }
  541. // fmt.Println(v.IsClass)
  542. // v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
  543. // expertNumStr, expertContentStr, interviewDateStr := services.BodyAnalysis(v.Body)
  544. // if count > 0 {
  545. // fmt.Println(k, v.ArticleId, "edit")
  546. // //articleInfo, err := models.GetArticleDetailById(v.ArticleId)
  547. // //if err != nil {
  548. // // br.Msg = "同步失败!文章ID:" + strconv.Itoa(v.ArticleId)
  549. // // br.ErrMsg = "同步失败,Err:" + err.Error()
  550. // // return
  551. // //}
  552. // //if articleInfo.IsClass == 1 {
  553. // // v.IsClass = 1
  554. // //}
  555. // bodyText, _ := services.GetReportContentTextSub(v.Body)
  556. // updateParams := make(map[string]interface{})
  557. // updateParams["Title"] = v.Title
  558. // updateParams["TitleEn"] = v.TitleEn
  559. // updateParams["UpdateFrequency"] = v.UpdateFrequency
  560. // updateParams["CreateDate"] = v.CreateDate
  561. // updateParams["PublishDate"] = v.PublishDate
  562. // updateParams["Body"] = html.EscapeString(v.Body)
  563. // updateParams["BodyText"] = bodyText
  564. // updateParams["Abstract"] = html.EscapeString(v.Abstract)
  565. // updateParams["CategoryName"] = v.CategoryName
  566. // updateParams["SubCategoryName"] = v.SubCategoryName
  567. // updateParams["CategoryId"] = v.CategoryId
  568. // updateParams["PublishStatus"] = v.PublishStatus
  569. // updateParams["ExpertBackground"] = expertContentStr
  570. // updateParams["ExpertNumber"] = expertNumStr
  571. // updateParams["InterviewDate"] = interviewDateStr
  572. // updateParams["IsClass"] = v.IsClass
  573. // updateParams["IsSummary"] = v.IsSummary
  574. // updateParams["IsReport"] = v.IsReport
  575. // updateParams["ReportType"] = v.ReportType
  576. // if v.Department != "弘则权益研究" {
  577. // v.Department = "弘则权益研究"
  578. // }
  579. // updateParams["Department"] = v.Department
  580. // whereParam := map[string]interface{}{"article_id": v.ArticleId}
  581. // err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
  582. // if err != nil {
  583. // fmt.Println("UpdateByExpr Err:" + err.Error())
  584. // }
  585. // } else {
  586. // fmt.Println(k, v.ArticleId, "add")
  587. // item := new(models.CygxArticle)
  588. // articleIdInt := v.ArticleId
  589. // item.ArticleId = articleIdInt
  590. // item.Title = v.Title
  591. // item.TitleEn = v.TitleEn
  592. // item.UpdateFrequency = v.UpdateFrequency
  593. // item.CreateDate = v.CreateDate
  594. // item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
  595. // item.Body = html.EscapeString(v.Body)
  596. // item.Abstract = html.EscapeString(v.Abstract)
  597. // item.CategoryName = v.CategoryName
  598. // item.SubCategoryName = v.SubCategoryName
  599. // item.CategoryId = v.CategoryId
  600. // item.PublishStatus = v.PublishStatus
  601. // item.ExpertBackground = expertContentStr
  602. // item.ExpertNumber = expertNumStr
  603. // item.InterviewDate = interviewDateStr
  604. // item.Department = v.Department
  605. // item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdInt))
  606. // item.IsClass = v.IsClass
  607. // item.IsSummary = v.IsSummary
  608. // item.IsReport = v.IsReport
  609. // item.ReportType = v.ReportType
  610. // _, err = models.AddCygxArticles(item)
  611. // if err != nil {
  612. // fmt.Println("AddCygxArticle Err:", err.Error())
  613. // br.Msg = "参数解析异常!"
  614. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  615. // return
  616. // }
  617. // }
  618. // //纪要库的数据同步到Es
  619. // if v.IsSummary == 1 {
  620. // content := html.UnescapeString(v.Body)
  621. // doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
  622. // if err != nil {
  623. // fmt.Println("create doc err:", err.Error())
  624. // br.Msg = "参数解析异常!"
  625. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  626. // return
  627. // }
  628. // doc.Find("a").Each(func(i int, a *goquery.Selection) {
  629. // a.Remove()
  630. // })
  631. // bodyText := doc.Text()
  632. // item := new(services.ElasticTestArticleDetail)
  633. // item.ArticleId = v.ArticleId
  634. // item.Title = v.Title
  635. // item.BodyText = bodyText
  636. // item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
  637. // services.EsAddOrEditData(indexName, strconv.Itoa(v.ArticleId), item)
  638. // }
  639. //}
  640. //br.Ret = 200
  641. //br.Success = true
  642. //br.Msg = "同步成功"
  643. //}