article.go 18 KB

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