article.go 19 KB

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