article.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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:" + err.Error() + 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. resp.Detail = detail
  383. br.Ret = 200
  384. br.Success = true
  385. br.Msg = "获取成功"
  386. br.Data = resp
  387. }
  388. // @Title 获取报告同步
  389. // @Description 获取报告详情接口
  390. // @Param ArticleIdMd5 query int true "报告ID"
  391. // @Success 200 {object} models.ArticleDetailResp
  392. // @router /tongbu [get]
  393. //func (this *ArticleCommonController) Tongbu() {
  394. // br := new(models.BaseResponse).Init()
  395. // defer func() {
  396. // this.Data["json"] = br
  397. // this.ServeJSON()
  398. // }()
  399. //
  400. // fmt.Println("同步数据")
  401. // indexName := utils.IndexName
  402. // fmt.Println(indexName)
  403. // endDate := time.Now().AddDate(0, 0, -7).Format(utils.FormatDate)
  404. // list, err := models.GetTacticsList(endDate)
  405. // //list, err := models.GetTacticsListAll2()
  406. // if err != nil {
  407. // fmt.Println("GetTacticsList Err:", err.Error())
  408. // return
  409. // }
  410. // fmt.Println("list len:", len(list))
  411. //
  412. // summaryCategoryIds := "28,32,45,50,57,62,72,74,79,84,86,88,90,95,96" //纪要库的文章类型ID
  413. // listSummarys := strings.Split(summaryCategoryIds, ",")
  414. // fmt.Println(listSummarys)
  415. // for _, v := range listSummarys {
  416. // vs, _ := strconv.Atoi(v)
  417. // fmt.Printf("n 的类型 %T", vs)
  418. // }
  419. //
  420. // for _, v := range list {
  421. // for _, vs := range listSummarys {
  422. // vint, _ := strconv.Atoi(vs)
  423. // //fmt.Printf("vint 的类型 %T", vint)
  424. // //fmt.Println("————————————")
  425. // //fmt.Printf("vCategoryId 的类型 %T", v.CategoryId)
  426. // //fmt.Println("————————————")
  427. //
  428. // if v.CategoryId == vint {
  429. //
  430. // }
  431. // }
  432. // }
  433. //
  434. // br.Msg = "测试!"
  435. // br.ErrMsg = "参数解析失败,Err:"
  436. // return
  437. //listSummary, errsu := models.GetReportMappingCategoryID()
  438. //if errsu != nil {
  439. // fmt.Println("GetTacticsList Err:", errsu.Error())
  440. // return
  441. //}
  442. //
  443. //listPermission, errper := models.GetPermissionMappingCategoryID()
  444. //if errper != nil {
  445. // fmt.Println("GetTacticsList Err:", errper.Error())
  446. // return
  447. //}
  448. //for k, v := range list {
  449. //
  450. // //是否属于纪要库
  451. // //countSummary, err := models.GetPermissionMappingById(v.CategoryId)
  452. // //if err != nil && err.Error() != utils.ErrNoRow() {
  453. // // br.Msg = "参数解析异常!"
  454. // // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  455. // // return
  456. // //}
  457. // //if countSummary > 0 {
  458. // // v.IsSummary = 1
  459. // //}
  460. // for _, vSum := range listSummary {
  461. // if v.CategoryId == vSum.CategoryId {
  462. // v.IsSummary = 1
  463. // }
  464. // }
  465. // //是否属于报告
  466. // //countReport, err := models.GetReportMappingById(v.CategoryId)
  467. // //if err != nil && err.Error() != utils.ErrNoRow() {
  468. // // br.Msg = "参数解析异常!"
  469. // // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  470. // // return
  471. // //}
  472. // for _, vPer := range listPermission {
  473. // if v.CategoryId == vPer.CategoryId {
  474. // v.IsReport = 1
  475. // }
  476. // }
  477. // if v.IsReport > 0 {
  478. // //是否属于策略 策略自动归类
  479. // //是否属于行业报告 行业报告自动归类
  480. // if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 52 || v.CategoryId == 64 || v.CategoryId == 80 || v.CategoryId == 87 {
  481. // v.IsClass = 1
  482. // }
  483. // if v.CategoryId == 64 || v.CategoryId == 87 || v.CategoryId == 80 {
  484. // v.ReportType = 2 //是否属于行业报告
  485. // } else {
  486. // v.ReportType = 1 //是否属于产业报告
  487. // }
  488. // }
  489. // v.Department = "弘则权益研究"
  490. // fmt.Println(k, v.ArticleId)
  491. // hh, _ := time.ParseDuration("8h")
  492. // //pDate := publishDate.Add(hh)
  493. // v.PublishDate = v.PublishDate.Add(hh)
  494. // //判断是否已经存在
  495. // if v.ArticleId < 0 {
  496. // if err != nil {
  497. // br.Msg = "参数解析异常!"
  498. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  499. // return
  500. // }
  501. // }
  502. // count, err := models.GetArticleCountById(v.ArticleId)
  503. // if err != nil && err.Error() != utils.ErrNoRow() {
  504. // br.Msg = "参数解析异常!"
  505. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  506. // return
  507. // }
  508. // fmt.Println(v.IsClass)
  509. // v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
  510. // expertNumStr, expertContentStr, interviewDateStr := services.BodyAnalysis(v.Body)
  511. // if count > 0 {
  512. // fmt.Println(k, v.ArticleId, "edit")
  513. // //articleInfo, err := models.GetArticleDetailById(v.ArticleId)
  514. // //if err != nil {
  515. // // br.Msg = "同步失败!文章ID:" + strconv.Itoa(v.ArticleId)
  516. // // br.ErrMsg = "同步失败,Err:" + err.Error()
  517. // // return
  518. // //}
  519. // //if articleInfo.IsClass == 1 {
  520. // // v.IsClass = 1
  521. // //}
  522. // bodyText, _ := services.GetReportContentTextSub(v.Body)
  523. // updateParams := make(map[string]interface{})
  524. // updateParams["Title"] = v.Title
  525. // updateParams["TitleEn"] = v.TitleEn
  526. // updateParams["UpdateFrequency"] = v.UpdateFrequency
  527. // updateParams["CreateDate"] = v.CreateDate
  528. // updateParams["PublishDate"] = v.PublishDate
  529. // updateParams["Body"] = html.EscapeString(v.Body)
  530. // updateParams["BodyText"] = bodyText
  531. // updateParams["Abstract"] = html.EscapeString(v.Abstract)
  532. // updateParams["CategoryName"] = v.CategoryName
  533. // updateParams["SubCategoryName"] = v.SubCategoryName
  534. // updateParams["CategoryId"] = v.CategoryId
  535. // updateParams["PublishStatus"] = v.PublishStatus
  536. // updateParams["ExpertBackground"] = expertContentStr
  537. // updateParams["ExpertNumber"] = expertNumStr
  538. // updateParams["InterviewDate"] = interviewDateStr
  539. // updateParams["IsClass"] = v.IsClass
  540. // updateParams["IsSummary"] = v.IsSummary
  541. // updateParams["IsReport"] = v.IsReport
  542. // updateParams["ReportType"] = v.ReportType
  543. // if v.Department != "弘则权益研究" {
  544. // v.Department = "弘则权益研究"
  545. // }
  546. // updateParams["Department"] = v.Department
  547. // whereParam := map[string]interface{}{"article_id": v.ArticleId}
  548. // err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
  549. // if err != nil {
  550. // fmt.Println("UpdateByExpr Err:" + err.Error())
  551. // }
  552. // } else {
  553. // fmt.Println(k, v.ArticleId, "add")
  554. // item := new(models.CygxArticle)
  555. // articleIdInt := v.ArticleId
  556. // item.ArticleId = articleIdInt
  557. // item.Title = v.Title
  558. // item.TitleEn = v.TitleEn
  559. // item.UpdateFrequency = v.UpdateFrequency
  560. // item.CreateDate = v.CreateDate
  561. // item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
  562. // item.Body = html.EscapeString(v.Body)
  563. // item.Abstract = html.EscapeString(v.Abstract)
  564. // item.CategoryName = v.CategoryName
  565. // item.SubCategoryName = v.SubCategoryName
  566. // item.CategoryId = v.CategoryId
  567. // item.PublishStatus = v.PublishStatus
  568. // item.ExpertBackground = expertContentStr
  569. // item.ExpertNumber = expertNumStr
  570. // item.InterviewDate = interviewDateStr
  571. // item.Department = v.Department
  572. // item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdInt))
  573. // item.IsClass = v.IsClass
  574. // item.IsSummary = v.IsSummary
  575. // item.IsReport = v.IsReport
  576. // item.ReportType = v.ReportType
  577. // _, err = models.AddCygxArticles(item)
  578. // if err != nil {
  579. // fmt.Println("AddCygxArticle Err:", err.Error())
  580. // br.Msg = "参数解析异常!"
  581. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  582. // return
  583. // }
  584. // }
  585. // //纪要库的数据同步到Es
  586. // if v.IsSummary == 1 {
  587. // content := html.UnescapeString(v.Body)
  588. // doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
  589. // if err != nil {
  590. // fmt.Println("create doc err:", err.Error())
  591. // br.Msg = "参数解析异常!"
  592. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  593. // return
  594. // }
  595. // doc.Find("a").Each(func(i int, a *goquery.Selection) {
  596. // a.Remove()
  597. // })
  598. // bodyText := doc.Text()
  599. // item := new(services.ElasticTestArticleDetail)
  600. // item.ArticleId = v.ArticleId
  601. // item.Title = v.Title
  602. // item.BodyText = bodyText
  603. // item.PublishDate = v.PublishDate.Format(utils.FormatDateTime)
  604. // services.EsAddOrEditData(indexName, strconv.Itoa(v.ArticleId), item)
  605. // }
  606. //}
  607. //br.Ret = 200
  608. //br.Success = true
  609. //br.Msg = "同步成功"
  610. //}