summary_manage.go 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "github.com/tealeg/xlsx"
  7. "hongze/hz_crm_api/controllers"
  8. "hongze/hz_crm_api/models"
  9. "hongze/hz_crm_api/models/company"
  10. "hongze/hz_crm_api/models/cygx"
  11. "hongze/hz_crm_api/models/system"
  12. "hongze/hz_crm_api/services"
  13. cygxService "hongze/hz_crm_api/services/cygx"
  14. "hongze/hz_crm_api/services/elastic"
  15. "hongze/hz_crm_api/utils"
  16. "os"
  17. "path/filepath"
  18. "strconv"
  19. "strings"
  20. "time"
  21. )
  22. // 纪要管理
  23. type SummaryManage struct {
  24. controllers.BaseAuthController
  25. }
  26. // @Title 文章内容的保存与发布
  27. // @Description 文章内容的保存与发布接口
  28. // @Param request body cygx.SummaryManageAddRep true "type json string"
  29. // @Success 200 操作成功
  30. // @router /summaryManage/PreserveAndPublish [post]
  31. func (this *SummaryManage) PreserveAndPublish() {
  32. br := new(models.BaseResponse).Init()
  33. defer func() {
  34. this.Data["json"] = br
  35. this.ServeJSON()
  36. }()
  37. AdminUser := this.SysUser
  38. if AdminUser == nil {
  39. br.Msg = "请登录"
  40. br.ErrMsg = "请登录,用户信息为空"
  41. br.Ret = 408
  42. return
  43. }
  44. var req cygx.SummaryManageAddRep
  45. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  46. if err != nil {
  47. br.Msg = "参数解析异常!"
  48. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  49. return
  50. }
  51. if req.Title == "" {
  52. br.Msg = "标题不可为空"
  53. br.ErrMsg = "标题不可为空"
  54. return
  55. }
  56. if req.Abstract == "" {
  57. br.Msg = "摘要不可为空"
  58. br.ErrMsg = "摘要不可为空"
  59. return
  60. }
  61. if req.PublishDate == "" {
  62. br.Msg = "发布时间不可为空"
  63. return
  64. }
  65. var articleIdNew int //最新的文章id
  66. var haveResearch bool
  67. var permissionName string
  68. industryName := req.IndustryName
  69. subjectName := req.SubjectName
  70. publishDate := req.PublishDate
  71. reportLink := req.ReportLink
  72. chartPermissionIds := "31" //31研选
  73. industrialManagementIds := req.IndustrialManagementIds
  74. industrialSubjectIds := req.IndustrialSubjectIds
  75. articleId := req.ArticleId
  76. articleTypeId := req.ArticleTypeId
  77. // 产业ID校验
  78. industryIds := make([]int, 0)
  79. industrialManagementIdList := strings.Split(industrialManagementIds, ",")
  80. for _, v := range industrialManagementIdList {
  81. i, err := strconv.Atoi(v)
  82. if err != nil {
  83. br.Msg = "参数解析异常!"
  84. br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds
  85. return
  86. }
  87. industryIds = append(industryIds, i)
  88. }
  89. if industrialSubjectIds != "" {
  90. industrialSubjectIdList := strings.Split(industrialSubjectIds, ",")
  91. for _, v := range industrialSubjectIdList {
  92. _, err := strconv.Atoi(v)
  93. if err != nil {
  94. br.Msg = "参数解析异常!"
  95. br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds
  96. return
  97. }
  98. }
  99. }
  100. chartPermissionIdsList := strings.Split(chartPermissionIds, ",")
  101. for _, v := range chartPermissionIdsList {
  102. chartPermissionId, err := strconv.Atoi(v)
  103. if err != nil {
  104. br.Msg = "发布失败"
  105. br.ErrMsg = "发布失败,Err:" + err.Error()
  106. return
  107. }
  108. charInfo, errCategory := cygx.GetCategoryInfoById(chartPermissionId)
  109. if errCategory != nil {
  110. br.Msg = "获取品种信息失败"
  111. br.ErrMsg = "获取品种信息失败,Err:" + errCategory.Error()
  112. return
  113. }
  114. if strings.Contains(charInfo.PermissionName, "研选") {
  115. haveResearch = true
  116. }
  117. permissionName += charInfo.PermissionName + ","
  118. }
  119. permissionName = strings.TrimRight(permissionName, ",")
  120. if articleId == 0 {
  121. maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo()
  122. if errMax != nil {
  123. br.Msg = "发布失败"
  124. br.ErrMsg = "发布失败,Err:" + errMax.Error()
  125. return
  126. }
  127. if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId {
  128. articleIdNew = utils.SummaryArticleId
  129. } else {
  130. articleIdNew = maxArticleIdArticleInfo.ArticleId + 1
  131. }
  132. }
  133. //处理文章类型信息
  134. articleTypeInfo, err := cygx.GetCygxArticleTypeDetailById(articleTypeId)
  135. if err != nil {
  136. br.Msg = "请选择报告类型"
  137. br.ErrMsg = "获取报告类型信息失败,Err:" + err.Error()
  138. return
  139. }
  140. //处理作者内容的格式信息
  141. department := req.SellerAndMobile
  142. itemDepartment := new(cygx.CygxArticleDepartment)
  143. if !strings.Contains(department, "-") {
  144. br.Msg = "作者格式错误"
  145. return
  146. }
  147. slice := strings.Split(department, "-")
  148. if len(slice) < 2 {
  149. br.Msg = "作者格式错误"
  150. return
  151. }
  152. strnum := strings.Index(department, "-")
  153. itemDepartment.NickName = department[0:strnum]
  154. itemDepartment.CreateTime = time.Now()
  155. itemDepartment.Remark = department[strnum+1:]
  156. itemDepartment.Content = req.SellerAndMobile
  157. remarks := itemDepartment.Remark
  158. remarks = strings.Replace(remarks, ",", "", -1)
  159. remarks = strings.Replace(remarks, ",", "", -1)
  160. remarks = strings.Replace(remarks, " ", "", -1)
  161. itemDepartment.Remarks = remarks
  162. total, _ := cygx.GetArticleDepartmentCount(itemDepartment.NickName, itemDepartment.Remarks)
  163. var newDepartmentId int64
  164. if total == 0 {
  165. detail, err := cygx.GetCygxConfigDetailByCode("department_img_url")
  166. if err != nil {
  167. br.Msg = "获取失败"
  168. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  169. return
  170. }
  171. sliceDepart := strings.Split(detail.ConfigValue, "{|}")
  172. totalDepart, err := cygx.GetArticleDepartmentCountAll()
  173. if err != nil {
  174. br.Msg = "获取失败"
  175. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  176. return
  177. }
  178. itemDepartment.ImgUrl = sliceDepart[totalDepart%10]
  179. //避免代码冗余,放弃插入事务处理
  180. newDepartmentId, err = cygx.AddCygxArticleDepartment(itemDepartment)
  181. if err != nil {
  182. br.Msg = "发布失败"
  183. br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
  184. return
  185. }
  186. } else {
  187. departmentDetail, err := cygx.GetArticleDepartmentDateil(itemDepartment.NickName, itemDepartment.Remarks)
  188. if err != nil {
  189. br.Msg = "发布失败"
  190. br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
  191. return
  192. }
  193. newDepartmentId = int64(departmentDetail.DepartmentId)
  194. }
  195. expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body)
  196. item := new(cygx.CygxArticle)
  197. item.AdminId = AdminUser.AdminId
  198. item.AdminName = AdminUser.RealName
  199. item.Title = req.Title
  200. item.Body = req.Body
  201. item.BodyText, _ = cygxService.GetReportContentTextSubNew(req.Body)
  202. item.Abstract = req.Abstract
  203. item.CategoryName = permissionName
  204. item.ArticleId = articleId
  205. item.CreateDate = time.Now()
  206. item.LastUpdatedTime = time.Now()
  207. if articleTypeInfo.IsSendEs == 1 {
  208. item.IsSummary = 1
  209. } else {
  210. item.IsReport = 1
  211. }
  212. item.Source = 1
  213. item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew))
  214. item.UpdateFrequency = "unknow"
  215. item.SellerAndMobile = req.SellerAndMobile
  216. item.ExpertBackground = expertContentStr
  217. item.ExpertNumber = expertNumStr
  218. item.InterviewDate = interviewDateStr
  219. item.FileLink = fileLink
  220. item.ChartPermissionIds = chartPermissionIds
  221. item.DepartmentId = int(newDepartmentId)
  222. item.ArticleTypeId = articleTypeId
  223. item.ArticleTypeName = articleTypeInfo.ArticleTypeName
  224. publishDateSlice := strings.Split(publishDate, " ") //过滤前端传过来的时分秒
  225. item.PublishDate = utils.StrTimeToTime(publishDateSlice[0] + " 00:00:00")
  226. item.ReportLink = reportLink
  227. if haveResearch {
  228. item.Department = "机构投资者"
  229. } else {
  230. item.Department = "弘则权益研究"
  231. br.Msg = "请选择研选行业"
  232. return
  233. }
  234. charInfo, err := cygx.GetCategoryInfoByName(utils.CHART_PERMISSION_NAME_MF_YANXUAN)
  235. if err != nil {
  236. br.Msg = "操作失败"
  237. br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error()
  238. return
  239. }
  240. if req.DoType == 1 {
  241. item.PublishStatus = 1
  242. }
  243. //industrialManagementId, _ := strconv.Atoi(industrialManagementIds)
  244. //industrialDetail, _ := cygx.GetIndustrialManagemenDetailById(industrialManagementId)
  245. var errArt error
  246. if articleId == 0 {
  247. item.ArticleId = articleIdNew
  248. //需求修改纪要的新增与修改与报告一致
  249. _, err := cygx.AddAReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, itemDepartment, industrialManagementIds, industrialSubjectIds)
  250. errArt = err
  251. if errArt == nil {
  252. //articleInfo, err := cygx.GetArticleIdInfoBySummaryManageIdEdit(int(artNewId))
  253. if err == nil && req.DoType == 1 {
  254. go cygxService.DoArticleOnenIdWxTemplateMsg(articleIdNew, 1)
  255. }
  256. }
  257. } else {
  258. articleInfo, errInfo := cygx.GetArticleIdInfoByArticleId(articleId)
  259. if articleInfo == nil {
  260. br.Msg = "文章不存在"
  261. return
  262. }
  263. if errInfo != nil {
  264. br.Msg = "发布失败"
  265. br.ErrMsg = "发布失败,Err:" + errInfo.Error()
  266. return
  267. }
  268. if item.PublishStatus == 0 {
  269. item.PublishStatus = articleInfo.PublishStatus
  270. }
  271. item.ArticleId = articleId
  272. err := cygx.EditReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds)
  273. errArt = err
  274. if errArt == nil && req.DoType == 1 {
  275. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  276. }
  277. }
  278. if errArt != nil {
  279. br.Msg = "发布失败"
  280. br.ErrMsg = "发布失败,Err:" + errArt.Error()
  281. return
  282. }
  283. // 查研观向7.4-这里暂时注释掉, 目前article和industry有关联表处理, 此处应该是没有在用了
  284. //var subjectIds string
  285. //subjectIds, _ = cygx.GetSubjectIds(articleId)
  286. //{|1|}表示报告类型,{|2|}表示纪要类型
  287. //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId)
  288. if item.PublishStatus == 1 && articleTypeInfo.IsSendEs == 1 {
  289. services.EsAddOrEditData(item)
  290. }
  291. ////同步数据到最新表
  292. //if req.ArticleId == 0 {
  293. // if item.PublishStatus == 1 {
  294. // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  295. // }
  296. //} else {
  297. // if item.PublishStatus == 1 {
  298. // go cygxService.UpdateResourceData(item.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
  299. // }
  300. // if req.DoType == 1 {
  301. // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  302. // }
  303. //}
  304. if len(industryIds) > 0 {
  305. go cygxService.UpdateIndustryLayoutTime(industryIds, false) // 查研观向7.4-更新产业布局时间
  306. go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
  307. }
  308. go elastic.AddComprehensiveArticle(item.ArticleId) // ES添加文章:报告、纪要
  309. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  310. go cygxService.MakeArticleMomentsImg(item.ArticleId) //生成文章分享到朋友圈的图片
  311. br.Ret = 200
  312. br.Success = true
  313. br.Msg = "操作成功"
  314. br.IsAddLog = true
  315. }
  316. // @Title 文章的发布与取消发布
  317. // @Description 文章的发布与取消发布接口
  318. // @Param request body cygx.SummaryManageIdRep true "type json string"
  319. // @Success 200 操作成功
  320. // @router /summaryManage/PublishAndCancel [post]
  321. func (this *SummaryManage) PublishAndCancel() {
  322. br := new(models.BaseResponse).Init()
  323. defer func() {
  324. this.Data["json"] = br
  325. this.ServeJSON()
  326. }()
  327. AdminUser := this.SysUser
  328. indexName := utils.IndexName
  329. if AdminUser == nil {
  330. br.Msg = "请登录"
  331. br.ErrMsg = "请登录,用户信息为空"
  332. br.Ret = 408
  333. return
  334. }
  335. var req cygx.SummaryManageIdRep
  336. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  337. if err != nil {
  338. br.Msg = "参数解析异常!"
  339. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  340. return
  341. }
  342. articleId := req.ArticleId
  343. item := new(cygx.CygxArticle)
  344. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  345. if articleInfo == nil {
  346. br.Msg = "操作失败"
  347. br.ErrMsg = "纪要ID错误"
  348. return
  349. }
  350. if errInfo != nil {
  351. br.Msg = "操作失败"
  352. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  353. return
  354. }
  355. item.ArticleId = articleId
  356. item.Title = articleInfo.Title
  357. item.BodyText = articleInfo.BodyText
  358. item.Body = articleInfo.Body
  359. item.PublishDate = articleInfo.PublishDate
  360. item.ExpertBackground = articleInfo.ExpertBackground
  361. item.CategoryId = articleInfo.CategoryId
  362. //item.Annotation, _ = GetReportContentTextSubNew(v.Annotation)
  363. //item.Abstract, _ = GetReportContentTextSubNew(v.Abstract)
  364. if articleInfo.PublishStatus == 0 {
  365. item.PublishStatus = 1
  366. item.AdminId = AdminUser.AdminId
  367. item.AdminName = AdminUser.RealName
  368. services.EsAddOrEditData(item)
  369. //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  370. } else {
  371. item.AdminId = articleInfo.AdminId
  372. item.AdminName = articleInfo.AdminName
  373. item.PublishStatus = 0
  374. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  375. //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  376. }
  377. err = cygx.PublishAndCancel(item)
  378. if err != nil {
  379. br.Msg = "操作失败"
  380. br.ErrMsg = "操作失败,Err:" + err.Error()
  381. return
  382. }
  383. //专项调研类型的报告单独走发送
  384. if articleInfo.SubCategoryName == "专项调研" {
  385. if item.PublishStatus == 1 {
  386. cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
  387. }
  388. } else {
  389. if item.PublishStatus == 1 {
  390. articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
  391. if articleIndustrial.ArticleId > 0 {
  392. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  393. }
  394. go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
  395. }
  396. }
  397. go elastic.AddComprehensiveArticle(articleId) // ES添加文章:报告、纪要
  398. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  399. br.Ret = 200
  400. br.Success = true
  401. br.Msg = "操作成功"
  402. br.IsAddLog = true
  403. }
  404. // @Title 文章详情
  405. // @Description 获取文章详情接口
  406. // @Param ArticleId query int true "文章ID"
  407. // @Success Ret=200 {object} cygx.SummaryManageEditDetail
  408. // @router /summaryManage/detail [get]
  409. func (this *SummaryManage) Detail() {
  410. br := new(models.BaseResponse).Init()
  411. defer func() {
  412. this.Data["json"] = br
  413. this.ServeJSON()
  414. }()
  415. AdminUser := this.SysUser
  416. if AdminUser == nil {
  417. br.Msg = "请登录"
  418. br.ErrMsg = "请登录,用户信息为空"
  419. br.Ret = 408
  420. return
  421. }
  422. articleId, _ := this.GetInt("ArticleId")
  423. if articleId < 1 {
  424. br.Msg = "请输入文章ID"
  425. return
  426. }
  427. articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId)
  428. if err != nil {
  429. br.Msg = "文章内容不存在"
  430. br.ErrMsg = "纪要ID错误,Err:" + err.Error()
  431. return
  432. }
  433. detail, _ := cygx.GetArticleDepartmentDateilByDepartmentId(articleInfo.DepartmentId)
  434. industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId)
  435. if err != nil && err.Error() != utils.ErrNoRow() {
  436. br.Msg = "获取信息失败"
  437. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  438. return
  439. }
  440. subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId)
  441. if err != nil && err.Error() != utils.ErrNoRow() {
  442. br.Msg = "获取信息失败"
  443. br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  444. return
  445. }
  446. articleInfo.ListIndustrial = industrialList
  447. articleInfo.ListSubject = subjectList
  448. resp := cygx.ArticleDetailResp{
  449. ArticleId: articleInfo.ArticleId,
  450. Title: articleInfo.Title,
  451. Abstract: articleInfo.Abstract,
  452. Body: articleInfo.Body,
  453. PublishStatus: articleInfo.PublishStatus,
  454. PublishDate: articleInfo.PublishDate,
  455. CreateDate: articleInfo.CreateDate,
  456. LastUpdatedTime: articleInfo.LastUpdatedTime,
  457. ArticleIdMd5: articleInfo.ArticleIdMd5,
  458. SellerAndMobile: articleInfo.SellerAndMobile,
  459. SubjectName: articleInfo.SubjectName,
  460. IndustryName: articleInfo.IndustryName,
  461. DepartmentId: articleInfo.DepartmentId,
  462. ChartPermissionIds: articleInfo.ChartPermissionIds,
  463. ArticleTypeId: articleInfo.ArticleTypeId,
  464. ArticleTypeName: articleInfo.ArticleTypeName,
  465. ListIndustrial: articleInfo.ListIndustrial,
  466. ListSubject: articleInfo.ListSubject,
  467. ReportLink: articleInfo.ReportLink,
  468. ImgUrl: detail.ImgUrl,
  469. NickName: detail.NickName,
  470. }
  471. br.Ret = 200
  472. br.Success = true
  473. br.Msg = "获取成功"
  474. br.Data = resp
  475. }
  476. // @Title 删除纪要
  477. // @Description 删除纪要接口
  478. // @Param request body cygx.SummaryManageIdRep true "type json string"
  479. // @Success Ret=200
  480. // @router /summaryManage/delete [post]
  481. func (this *SummaryManage) Delete() {
  482. br := new(models.BaseResponse).Init()
  483. defer func() {
  484. this.Data["json"] = br
  485. this.ServeJSON()
  486. }()
  487. sysUser := this.SysUser
  488. indexName := utils.IndexName
  489. if sysUser == nil {
  490. br.Msg = "请登录"
  491. br.ErrMsg = "请登录,SysUser Is Empty"
  492. br.Ret = 408
  493. return
  494. }
  495. var req cygx.SummaryManageIdRep
  496. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  497. if err != nil {
  498. br.Msg = "参数解析异常!"
  499. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  500. return
  501. }
  502. articleId := req.ArticleId
  503. if articleId < 1 {
  504. br.Msg = "请输入产业ID"
  505. return
  506. }
  507. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  508. if articleInfo == nil {
  509. br.Msg = "操作失败"
  510. br.ErrMsg = "纪要ID错误"
  511. return
  512. }
  513. if errInfo != nil {
  514. br.Msg = "操作失败"
  515. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  516. return
  517. }
  518. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  519. err = cygx.DeleteArticleReport(articleInfo.ArticleId)
  520. if err != nil {
  521. br.Msg = "删除信息失败"
  522. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  523. return
  524. }
  525. //go cygxService.UpdateResourceData(articleInfo.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  526. go cygxService.UpdateArticleResourceData(articleInfo.ArticleId) //写入首页最新 cygx_resource_data 表
  527. br.Ret = 200
  528. br.Success = true
  529. br.Msg = "已删除"
  530. br.IsAddLog = true
  531. }
  532. // @Title 纪要列表
  533. // @Description 获取纪要列表接口
  534. // @Param PageSize query int true "每页数据条数"
  535. // @Param CurrentIndex query int true "当前页页码,从1开始"
  536. // @Param PublishStatus query int true "发布状态 ,0未发布,1已发布,传2查询所有"
  537. // @Param CategoryName query string true "行业名称"
  538. // @Param StartDate query string true "开始时间 ,列如2021-03-06 "
  539. // @Param EndDate query string true "结束时间,列如2021-03-06 "
  540. // @Param KeyWord query string true "搜索关键词"
  541. // @Param Label query string true "搜索报告标签"
  542. // @Param NickName query string true "作者昵称"
  543. // @Param Departmentİd query int false "作者İd"
  544. // @Param ArticleTypeId query int false `"文章类型ID"
  545. // @Success 200 {object} cygx.GetSummaryManageListRep
  546. // @router /summaryManage/list [get]
  547. func (this *SummaryManage) SummaryManageList() {
  548. br := new(models.BaseResponse).Init()
  549. defer func() {
  550. this.Data["json"] = br
  551. this.ServeJSON()
  552. }()
  553. sysUser := this.SysUser
  554. if sysUser == nil {
  555. br.Msg = "请登录"
  556. br.ErrMsg = "请登录,SysUser Is Empty"
  557. return
  558. }
  559. pageSize, _ := this.GetInt("PageSize")
  560. currentIndex, _ := this.GetInt("CurrentIndex")
  561. publishStatus, _ := this.GetInt("PublishStatus")
  562. categoryName := this.GetString("CategoryName")
  563. startDate := this.GetString("StartDate")
  564. endDate := this.GetString("EndDate")
  565. keyWord := this.GetString("KeyWord")
  566. label := this.GetString("Label")
  567. nickName := this.GetString("NickName")
  568. departmentİd, _ := this.GetInt("Departmentİd")
  569. articleTypeId, _ := this.GetInt("ArticleTypeId")
  570. resp := new(cygx.GetSummaryManageListRep)
  571. var startSize int
  572. if pageSize <= 0 {
  573. pageSize = utils.PageSize20
  574. }
  575. if currentIndex <= 0 {
  576. currentIndex = 1
  577. }
  578. startSize = utils.StartIndex(currentIndex, pageSize)
  579. var condition string
  580. var pars []interface{}
  581. condition += ` WHERE art.article_type_id >0 `
  582. if articleTypeId > 0 {
  583. condition += ` AND art.article_type_id = ` + strconv.Itoa(articleTypeId)
  584. }
  585. if keyWord != "" {
  586. condition += ` AND (art.title LIKE '%` + keyWord + `%' ) `
  587. }
  588. if nickName != "" {
  589. condition += ` AND (art.seller_and_mobile LIKE '%` + nickName + `%' ) `
  590. }
  591. if departmentİd > 0 {
  592. condition += ` AND art.department_id = ` + strconv.Itoa(departmentİd)
  593. }
  594. //行业名称
  595. if categoryName != "" {
  596. condition += ` AND art.category_name LIKE '%` + categoryName + `%' `
  597. }
  598. if startDate != "" {
  599. condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'"
  600. }
  601. if endDate != "" {
  602. condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'"
  603. }
  604. if startDate != "" || endDate != "" {
  605. condition += ` AND art.publish_status =1 `
  606. }
  607. if publishStatus == 0 || publishStatus == 1 {
  608. condition += ` AND art.publish_status = ` + strconv.Itoa(publishStatus)
  609. }
  610. //如果标签列表不为空则作以下关联搜索
  611. if label != "" {
  612. managementIds, err := cygx.GetManagementIdsByNameLike(label)
  613. if err != nil {
  614. br.Msg = "获取信息失败"
  615. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  616. return
  617. }
  618. subjectIds, err := cygx.GetIndustrialSubjectIdsByNameLike(label)
  619. if err != nil {
  620. br.Msg = "获取信息失败"
  621. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  622. return
  623. }
  624. var articleIdmanagement string
  625. var articleIdsubject string
  626. var articleIds string
  627. if managementIds != "" {
  628. articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds)
  629. if err != nil {
  630. br.Msg = "获取信息失败"
  631. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  632. return
  633. }
  634. }
  635. if subjectIds != "" {
  636. articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds)
  637. if err != nil {
  638. br.Msg = "获取信息失败"
  639. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  640. return
  641. }
  642. }
  643. if articleIdmanagement != "" && articleIdsubject != "" {
  644. articleIds = articleIdmanagement + "," + articleIdsubject
  645. } else if articleIdmanagement != "" && articleIdsubject == "" {
  646. articleIds = articleIdmanagement
  647. } else if articleIdmanagement == "" && articleIdsubject != "" {
  648. articleIds = articleIdsubject
  649. }
  650. if articleIds != "" {
  651. condition += ` AND art.article_id IN (` + articleIds + `)`
  652. } else {
  653. // 如果标签关联的报告为空,那么就直接返回空
  654. page := paging.GetPaging(currentIndex, pageSize, 0)
  655. resp.List = make([]*cygx.CygxArticleList, 0)
  656. resp.Paging = page
  657. br.Ret = 200
  658. br.Success = true
  659. br.Msg = "获取成功"
  660. br.Data = resp
  661. return
  662. }
  663. }
  664. total, err := cygx.GetASummaryManageCount(condition, pars)
  665. if err != nil {
  666. br.Msg = "获取失败"
  667. br.ErrMsg = "获取失败,Err:" + err.Error()
  668. return
  669. }
  670. condition += ` GROUP BY art.article_id `
  671. condition += ` ORDER BY art.top_time DESC , art.publish_date DESC `
  672. list, errList := cygx.GetSummaryManageList(condition, pars, startSize, pageSize)
  673. if errList != nil {
  674. br.Msg = "获取失败"
  675. br.ErrMsg = "获取失败,Err:" + errList.Error()
  676. return
  677. }
  678. var articleIdStr string
  679. for _, v := range list {
  680. articleIdStr += strconv.Itoa(v.ArticleId) + ","
  681. }
  682. articleIdStr = strings.TrimRight(articleIdStr, ",")
  683. // 查研观向7.4-报告关联多个产业
  684. mapIndustrial := make(map[int]string)
  685. mapSubject := make(map[string]string)
  686. if articleIdStr != "" {
  687. industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIdStr)
  688. if err != nil {
  689. br.Msg = "获取失败"
  690. br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error()
  691. return
  692. }
  693. subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIdStr)
  694. if err != nil {
  695. br.Msg = "获取失败"
  696. br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error()
  697. return
  698. }
  699. //合并活动对应的多个标的
  700. for _, v := range subjectList {
  701. mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
  702. }
  703. //活动对应的产业
  704. for _, v := range industrialList {
  705. var labelSubject string
  706. labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)]
  707. if labelSubject != "" {
  708. mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
  709. } else {
  710. mapIndustrial[v.ArticleId] += v.IndustryName + ","
  711. }
  712. }
  713. }
  714. for k, v := range list {
  715. if v.PublishStatus == 0 {
  716. list[k].PublishDate = ""
  717. } else {
  718. list[k].PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  719. }
  720. if mapIndustrial[v.ArticleId] != "" {
  721. list[k].IndustryName = strings.TrimRight(mapIndustrial[v.ArticleId], ",")
  722. }
  723. }
  724. page := paging.GetPaging(currentIndex, pageSize, total)
  725. resp.List = list
  726. resp.Paging = page
  727. br.Ret = 200
  728. br.Success = true
  729. br.Msg = "获取成功"
  730. br.Data = resp
  731. }
  732. // @Title 敏捷搜索关键词的列表
  733. // @Description 获取敏捷搜索关键词的列表接口
  734. // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
  735. // @router /summaryManage/fastSearchKeWord [get]
  736. func (this *SummaryManage) FastSearch() {
  737. br := new(models.BaseResponse).Init()
  738. defer func() {
  739. this.Data["json"] = br
  740. this.ServeJSON()
  741. }()
  742. AdminUser := this.SysUser
  743. if AdminUser == nil {
  744. br.Msg = "请登录"
  745. br.ErrMsg = "请登录,用户信息为空"
  746. br.Ret = 408
  747. return
  748. }
  749. resp := new(cygx.SummaryFastsearchKeywordsListResp)
  750. list, err := cygx.GetSummaryFastsearchKeywordsList()
  751. if err != nil {
  752. br.Msg = "获取失败"
  753. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  754. return
  755. }
  756. resp.List = list
  757. br.Ret = 200
  758. br.Success = true
  759. br.Msg = "获取成功"
  760. br.Data = resp
  761. }
  762. // @Title 新增和修改敏捷搜索关键词的列表
  763. // @Description 新增和修改敏捷搜索关键词的列表接口
  764. // @Param request body cygx.SummaryFastsearchKeywordsResp true "type json string"
  765. // @Success Ret=200
  766. // @router /summaryManage/editFastSearchKeWord [post]
  767. func (this *SummaryManage) EditFastSearch() {
  768. br := new(models.BaseResponse).Init()
  769. defer func() {
  770. this.Data["json"] = br
  771. this.ServeJSON()
  772. }()
  773. AdminUser := this.SysUser
  774. if AdminUser == nil {
  775. br.Msg = "请登录"
  776. br.ErrMsg = "请登录,用户信息为空"
  777. br.Ret = 408
  778. return
  779. }
  780. req := new(cygx.SummaryFastsearchKeywordsResp)
  781. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  782. if err != nil {
  783. br.Msg = "参数解析异常!"
  784. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  785. return
  786. }
  787. keyWord := req.KeyWord
  788. slicekeyWord := strings.Split(keyWord, ",")
  789. var items []*cygx.CygxSummaryFastsearchKeywords
  790. for _, v := range slicekeyWord {
  791. var item = new(cygx.CygxSummaryFastsearchKeywords)
  792. item.CreateTime = time.Now()
  793. item.KeyWord = v
  794. items = append(items, item)
  795. fmt.Println(v)
  796. }
  797. _, err = cygx.AddSummaryFastsearchKeywords(items)
  798. if err != nil {
  799. br.Msg = "操作失败"
  800. br.ErrMsg = "操作失败,Err:" + err.Error()
  801. return
  802. }
  803. br.Ret = 200
  804. br.Success = true
  805. br.Msg = "操作成功"
  806. }
  807. // @Title 永续客户是否展示
  808. // @Description 获取永续客户是否展示详情接口
  809. // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
  810. // @router /summaryManage/sustainableDetail [get]
  811. func (this *SummaryManage) Sustainable() {
  812. br := new(models.BaseResponse).Init()
  813. defer func() {
  814. this.Data["json"] = br
  815. this.ServeJSON()
  816. }()
  817. AdminUser := this.SysUser
  818. if AdminUser == nil {
  819. br.Msg = "请登录"
  820. br.ErrMsg = "请登录,用户信息为空"
  821. br.Ret = 408
  822. return
  823. }
  824. detail, err := cygx.GetCygxConfigDetail()
  825. if err != nil {
  826. br.Msg = "获取失败"
  827. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  828. return
  829. }
  830. if detail.ConfigValue == "1" {
  831. detail.OperationButton = true
  832. }
  833. br.Ret = 200
  834. br.Success = true
  835. br.Msg = "获取成功"
  836. br.Data = detail
  837. }
  838. // @Title 修改永续客户是否展示
  839. // @Description 修改永续客户是否展示接口
  840. // @Success Ret=200
  841. // @router /summaryManage/sustainableEdit [post]
  842. func (this *SummaryManage) EditSustainable() {
  843. br := new(models.BaseResponse).Init()
  844. defer func() {
  845. this.Data["json"] = br
  846. this.ServeJSON()
  847. }()
  848. AdminUser := this.SysUser
  849. if AdminUser == nil {
  850. br.Msg = "请登录"
  851. br.ErrMsg = "请登录,SysUser Is Empty"
  852. br.Ret = 408
  853. return
  854. }
  855. var newValue int
  856. detail, err := cygx.GetCygxConfigDetail()
  857. if err != nil {
  858. br.Msg = "获取失败"
  859. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  860. return
  861. }
  862. if detail.ConfigValue == "1" {
  863. newValue = 0
  864. } else {
  865. newValue = 1
  866. }
  867. err = cygx.CygxConfigUpdate(newValue)
  868. if err != nil {
  869. br.Msg = "操作失败"
  870. br.ErrMsg = "操作失败,Err:" + err.Error()
  871. return
  872. }
  873. br.Ret = 200
  874. br.Success = true
  875. br.Msg = "操作成功"
  876. }
  877. // @Title 提问列表详情
  878. // @Description 获取提问列表详情接口
  879. // @Param ArticleId query int true "文章ID"
  880. // @Success 200 {object} cygx.ActivityHelpAskListResp
  881. // @router /summaryManage/askList [get]
  882. func (this *SummaryManage) AskList() {
  883. br := new(models.BaseResponse).Init()
  884. defer func() {
  885. this.Data["json"] = br
  886. this.ServeJSON()
  887. }()
  888. sysUser := this.SysUser
  889. if sysUser == nil {
  890. br.Msg = "请登录"
  891. br.ErrMsg = "请登录,SysUser Is Empty"
  892. return
  893. }
  894. articleId, _ := this.GetInt("ArticleId")
  895. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  896. if articleInfo == nil {
  897. br.Msg = "操作失败"
  898. br.ErrMsg = "报告ID错误"
  899. return
  900. }
  901. list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
  902. resp := new(cygx.ArticleAskListResp)
  903. if err != nil {
  904. br.Msg = "获取失败"
  905. br.ErrMsg = "获取失败,Err:" + err.Error()
  906. return
  907. }
  908. resp.List = list
  909. br.Ret = 200
  910. br.Success = true
  911. br.Msg = "获取成功"
  912. br.Data = resp
  913. }
  914. // @Title 提问详情excel表格下载
  915. // @Description 提问详情excel表格下载接口
  916. // @Param SummaryManageId query int true "纪要ID"
  917. // @Success 200 导出成功
  918. // @router /summaryManage/askListExport [get]
  919. func (this *SummaryManage) AskListExport() {
  920. br := new(models.BaseResponse).Init()
  921. defer func() {
  922. this.Data["json"] = br
  923. this.ServeJSON()
  924. }()
  925. sysUser := this.SysUser
  926. if sysUser == nil {
  927. br.Msg = "请登录"
  928. br.ErrMsg = "请登录,SysUser Is Empty"
  929. return
  930. }
  931. articleId, _ := this.GetInt("ArticleId")
  932. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  933. if articleInfo == nil {
  934. br.Msg = "操作失败"
  935. br.ErrMsg = "报告ID错误"
  936. return
  937. }
  938. list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
  939. if err != nil {
  940. br.Msg = "获取失败"
  941. br.ErrMsg = "获取失败,Err:" + err.Error()
  942. return
  943. }
  944. //创建excel
  945. dir, err := os.Executable()
  946. exPath := filepath.Dir(dir)
  947. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  948. xlsxFile := xlsx.NewFile()
  949. if err != nil {
  950. br.Msg = "生成文件失败"
  951. br.ErrMsg = "生成文件失败"
  952. return
  953. }
  954. style := xlsx.NewStyle()
  955. alignment := xlsx.Alignment{
  956. Horizontal: "center",
  957. Vertical: "center",
  958. WrapText: true,
  959. }
  960. style.Alignment = alignment
  961. style.ApplyAlignment = true
  962. sheet, err := xlsxFile.AddSheet("名单")
  963. if err != nil {
  964. br.Msg = "新增Sheet失败"
  965. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  966. return
  967. }
  968. //标头
  969. rowTitle := sheet.AddRow()
  970. cellA := rowTitle.AddCell()
  971. cellA.Value = "姓名"
  972. cellB := rowTitle.AddCell()
  973. cellB.Value = "公司名称"
  974. cellC := rowTitle.AddCell()
  975. cellC.Value = "问题"
  976. cellD := rowTitle.AddCell()
  977. cellD.Value = "提交时间"
  978. for _, item := range list {
  979. row := sheet.AddRow()
  980. cellA := row.AddCell()
  981. cellA.Value = item.RealName
  982. cellB := row.AddCell()
  983. cellB.Value = item.CompanyName
  984. cellC := row.AddCell()
  985. cellC.Value = item.Content
  986. cellD := row.AddCell()
  987. cellD.Value = item.CreateTime
  988. }
  989. err = xlsxFile.Save(downLoadnFilePath)
  990. if err != nil {
  991. br.Msg = "保存文件失败"
  992. br.ErrMsg = "保存文件失败"
  993. return
  994. }
  995. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  996. downloadFileName := "问题列表" + randStr + ".xlsx"
  997. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  998. defer func() {
  999. os.Remove(downLoadnFilePath)
  1000. }()
  1001. br.Success = true
  1002. br.Ret = 200
  1003. br.Msg = "导出成功"
  1004. }
  1005. // @Title 作者关注详情
  1006. // @Description 获取作者关注详情列表接口
  1007. // @Param DepartmentId query int true "作者ID"
  1008. // @Success 200 {object} cygx.GetFailSignupListRep
  1009. // @router /summaryManage/department/followList [get]
  1010. func (this *SummaryManage) FepartmentfollowList() {
  1011. br := new(models.BaseResponse).Init()
  1012. defer func() {
  1013. this.Data["json"] = br
  1014. this.ServeJSON()
  1015. }()
  1016. sysUser := this.SysUser
  1017. if sysUser == nil {
  1018. br.Msg = "请登录"
  1019. br.ErrMsg = "请登录,SysUser Is Empty"
  1020. return
  1021. }
  1022. departmentId, _ := this.GetInt("DepartmentId")
  1023. detail, _ := cygx.GetArticleDepartmentDateilById(departmentId)
  1024. if detail == nil {
  1025. br.Msg = "作者不存在"
  1026. br.ErrMsg = "获取信息失败,Err:DepartmentId:" + strconv.Itoa(departmentId)
  1027. return
  1028. }
  1029. list, err := cygx.GetCygxDepartmentFllowList(departmentId)
  1030. resp := new(cygx.CygxDepartmentFllowRep)
  1031. if err != nil {
  1032. br.Msg = "获取失败"
  1033. br.ErrMsg = "获取列表失败,Err:" + err.Error()
  1034. return
  1035. }
  1036. resp.NickName = detail.Content
  1037. resp.FllowNum = len(list)
  1038. resp.List = list
  1039. br.Ret = 200
  1040. br.Success = true
  1041. br.Msg = "获取成功"
  1042. br.Data = resp
  1043. }
  1044. // @Title 文章收藏详情
  1045. // @Description 获取文章收藏详情列表接口
  1046. // @Param ArticleId query int true "文章ID"
  1047. // @Success 200 {object} cygx.GetFailSignupListRep
  1048. // @router /summaryManage/articleCollection [get]
  1049. func (this *SummaryManage) ArticleCollection() {
  1050. br := new(models.BaseResponse).Init()
  1051. defer func() {
  1052. this.Data["json"] = br
  1053. this.ServeJSON()
  1054. }()
  1055. sysUser := this.SysUser
  1056. if sysUser == nil {
  1057. br.Msg = "请登录"
  1058. br.ErrMsg = "请登录,SysUser Is Empty"
  1059. return
  1060. }
  1061. articleId, _ := this.GetInt("ArticleId")
  1062. _, err := cygx.GetArticleIdInfoByArticleId(articleId)
  1063. if err != nil {
  1064. br.Msg = "报告不存在"
  1065. br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
  1066. return
  1067. }
  1068. list, err := cygx.GetCygxArticleCollectionList(articleId)
  1069. if err != nil {
  1070. br.Msg = "获取失败"
  1071. br.ErrMsg = "获取列表失败,Err:" + err.Error()
  1072. return
  1073. }
  1074. //获取对应销售名称
  1075. if len(list) > 0 {
  1076. var companyIds []int
  1077. for _, v := range list {
  1078. companyIds = append(companyIds, v.CompanyId)
  1079. }
  1080. listCompanyProduct, err := company.GetCompanyProductListByCompanyIds(companyIds, 2)
  1081. if err != nil {
  1082. br.Msg = "获取失败"
  1083. br.ErrMsg = "获取销售列表失败,Err:" + err.Error()
  1084. return
  1085. }
  1086. mapSellName := make(map[int]string)
  1087. for _, v := range listCompanyProduct {
  1088. mapSellName[v.CompanyId] = v.SellerName
  1089. }
  1090. for _, v := range list {
  1091. v.SellerName = mapSellName[v.CompanyId]
  1092. }
  1093. }
  1094. br.Ret = 200
  1095. br.Success = true
  1096. br.Msg = "获取成功"
  1097. br.Data = list
  1098. }
  1099. // @Title 阅读明细下载
  1100. // @Description 获取阅读明细下载接口
  1101. // @Param ArticleId query int true "文章ID"
  1102. // @Success 200 导出成功
  1103. // @router /summaryManage/articleHistoryExport [get]
  1104. func (this *SummaryManage) ArticleHistoryExport() {
  1105. br := new(models.BaseResponse).Init()
  1106. defer func() {
  1107. this.Data["json"] = br
  1108. this.ServeJSON()
  1109. }()
  1110. AdminUser := this.SysUser
  1111. if AdminUser == nil {
  1112. br.Msg = "请登录"
  1113. br.ErrMsg = "请登录,SysUser Is Empty"
  1114. return
  1115. }
  1116. articleId, _ := this.GetInt("ArticleId")
  1117. articleInfo, err := cygx.GetArticleIdInfoByArticleId(articleId)
  1118. if err != nil {
  1119. br.Msg = "报告不存在"
  1120. br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
  1121. return
  1122. }
  1123. resp := new(cygx.CanDownload)
  1124. adminInfo, errAdmin := system.GetSysUserById(AdminUser.AdminId)
  1125. if errAdmin != nil {
  1126. br.Msg = "获取失败"
  1127. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  1128. return
  1129. }
  1130. if adminInfo.Role == "admin" || adminInfo.Role == "researcher" || adminInfo.RealName == "汪洋" {
  1131. resp.IsCanDownload = true
  1132. }
  1133. var condition string
  1134. if resp.IsCanDownload == false {
  1135. //权益申请销售只能看到自己名下的客户的申请
  1136. companyIds, err := cygxService.GetAdminLookUserCompanyIds(AdminUser)
  1137. if err != nil {
  1138. br.Msg = "获取失败"
  1139. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  1140. return
  1141. }
  1142. var companyIdstr []string
  1143. for _, v := range companyIds {
  1144. companyIdstr = append(companyIdstr, strconv.Itoa(v))
  1145. }
  1146. condition = ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) `
  1147. }
  1148. mapMobileSellWithUser := make(map[string]string)
  1149. if condition != "" {
  1150. mobileList, err := cygx.GetSellerUserMobileList(condition)
  1151. if err != nil && err.Error() != utils.ErrNoRow() {
  1152. br.Msg = "获取失败"
  1153. br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
  1154. return
  1155. }
  1156. if len(mobileList) > 0 {
  1157. for _, v := range mobileList {
  1158. mapMobileSellWithUser[v.Mobile] = v.Mobile
  1159. }
  1160. }
  1161. }
  1162. condition += ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  1163. list, err := cygx.GetArticleHistoryList(articleId, condition)
  1164. if err != nil {
  1165. br.Msg = "获取失败"
  1166. br.ErrMsg = "获取失败,Err:" + err.Error()
  1167. return
  1168. }
  1169. listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId))
  1170. if err != nil && err.Error() != utils.ErrNoRow() {
  1171. br.Msg = "获取失败"
  1172. br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
  1173. return
  1174. }
  1175. var mobilesCl string
  1176. if len(listClPv) > 0 {
  1177. for _, v := range listClPv {
  1178. if v.Mobile != "" {
  1179. mobilesCl += v.Mobile + ","
  1180. }
  1181. }
  1182. }
  1183. mapMobileCompany := make(map[string]string)
  1184. mapMobileSellName := make(map[string]string)
  1185. mobilesCl = strings.TrimRight(mobilesCl, ",")
  1186. if mobilesCl != "" {
  1187. listClCompanyName, err := cygx.GetCygxCelueArticleComapnyName(mobilesCl)
  1188. if err != nil && err.Error() != utils.ErrNoRow() {
  1189. br.Msg = "获取失败"
  1190. br.ErrMsg = "获取策略品台关联查研观向的用户信息失败,Err:" + err.Error()
  1191. return
  1192. }
  1193. if len(listClCompanyName) > 0 {
  1194. for _, v := range listClCompanyName {
  1195. mapMobileCompany[v.Mobile] = v.CompanyName
  1196. mapMobileSellName[v.Mobile] = v.RealName
  1197. }
  1198. }
  1199. }
  1200. for k, v := range listClPv {
  1201. if v.Mobile != "" {
  1202. if mapMobileCompany[v.Mobile] != "" {
  1203. listClPv[k].CompanyName = mapMobileCompany[v.Mobile]
  1204. }
  1205. if mapMobileSellName[v.Mobile] != "" {
  1206. listClPv[k].SellerName = mapMobileSellName[v.Mobile]
  1207. }
  1208. }
  1209. }
  1210. var listClPvPower []*cygx.ArticleHistoryRep
  1211. if len(mapMobileSellWithUser) != 0 {
  1212. for _, v := range listClPv {
  1213. if mapMobileSellWithUser[v.Mobile] != "" {
  1214. listClPvPower = append(listClPvPower, v)
  1215. }
  1216. }
  1217. } else {
  1218. listClPvPower = listClPv
  1219. }
  1220. //创建excel
  1221. dir, err := os.Executable()
  1222. exPath := filepath.Dir(dir)
  1223. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1224. xlsxFile := xlsx.NewFile()
  1225. if err != nil {
  1226. br.Msg = "生成文件失败"
  1227. br.ErrMsg = "生成文件失败"
  1228. return
  1229. }
  1230. style := xlsx.NewStyle()
  1231. alignment := xlsx.Alignment{
  1232. Horizontal: "center",
  1233. Vertical: "center",
  1234. WrapText: true,
  1235. }
  1236. style.Alignment = alignment
  1237. style.ApplyAlignment = true
  1238. for pidIndex := 0; pidIndex <= 1; pidIndex++ {
  1239. var sheetName string
  1240. var listDate []*cygx.ArticleHistoryRep
  1241. if pidIndex == 0 {
  1242. sheetName = "查研观向"
  1243. listDate = list
  1244. } else {
  1245. sheetName = "策略平台"
  1246. listDate = listClPvPower
  1247. }
  1248. sheet, err := xlsxFile.AddSheet(sheetName)
  1249. if err != nil {
  1250. br.Msg = "新增Sheet失败"
  1251. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1252. return
  1253. }
  1254. //标头
  1255. rowTitle := sheet.AddRow()
  1256. cellA := rowTitle.AddCell()
  1257. cellA.Value = "姓名"
  1258. cellB := rowTitle.AddCell()
  1259. cellB.Value = "手机号"
  1260. cellC := rowTitle.AddCell()
  1261. cellC.Value = "公司名称"
  1262. cellD := rowTitle.AddCell()
  1263. cellD.Value = "所属权益销售"
  1264. cellE := rowTitle.AddCell()
  1265. cellE.Value = "阅读时长(秒)"
  1266. cellF := rowTitle.AddCell()
  1267. cellF.Value = "阅读时间"
  1268. for _, item := range listDate {
  1269. row := sheet.AddRow()
  1270. cellA := row.AddCell()
  1271. cellA.Value = item.RealName
  1272. cellB := row.AddCell()
  1273. cellB.Value = item.Mobile
  1274. cellC := row.AddCell()
  1275. cellC.Value = item.CompanyName
  1276. cellD := row.AddCell()
  1277. cellD.Value = item.SellerName
  1278. cellE := row.AddCell()
  1279. cellE.Value = item.StopTime
  1280. cellF := row.AddCell()
  1281. cellF.Value = item.CreateTime
  1282. }
  1283. }
  1284. err = xlsxFile.Save(downLoadnFilePath)
  1285. if err != nil {
  1286. br.Msg = "保存文件失败"
  1287. br.ErrMsg = "保存文件失败"
  1288. return
  1289. }
  1290. //randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1291. downloadFileName := articleInfo.Title + ".xlsx"
  1292. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1293. defer func() {
  1294. os.Remove(downLoadnFilePath)
  1295. }()
  1296. br.Success = true
  1297. br.Ret = 200
  1298. br.Msg = "导出成功"
  1299. }
  1300. // @Title 文章类型列表
  1301. // @Description 文章类型列表接口
  1302. // @Success 200 {object} cygx.ArticleTypeListResp
  1303. // @router /summaryManage/articleType/list [get]
  1304. func (this *ActivityTypeCoAntroller) ArticleTypeList() {
  1305. br := new(models.BaseResponse).Init()
  1306. defer func() {
  1307. this.Data["json"] = br
  1308. this.ServeJSON()
  1309. }()
  1310. sysUser := this.SysUser
  1311. if sysUser == nil {
  1312. br.Msg = "请登录"
  1313. br.ErrMsg = "请登录,SysUser Is Empty"
  1314. br.Ret = 408
  1315. return
  1316. }
  1317. resp := new(cygx.ArticleTypeListResp)
  1318. list, err := cygx.GetCygxArticleTypeList()
  1319. if err != nil {
  1320. br.Msg = "获取失败"
  1321. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1322. return
  1323. }
  1324. typelist, err := cygx.GetArticleTypeAndAbstract()
  1325. if err != nil {
  1326. br.Msg = "获取失败"
  1327. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1328. return
  1329. }
  1330. resp.AbstractList = typelist
  1331. resp.List = list
  1332. br.Ret = 200
  1333. br.Success = true
  1334. br.Msg = "获取成功"
  1335. br.Data = resp
  1336. }
  1337. // @Title 新增文章类型
  1338. // @Description 新增文章类型接口
  1339. // @Param request body cygx.CygxArticleReq true "type json string"
  1340. // @Success Ret=200
  1341. // @router /summaryManage/articleType/add [post]
  1342. func (this *SummaryManage) ArticleTypeListAdd() {
  1343. br := new(models.BaseResponse).Init()
  1344. defer func() {
  1345. this.Data["json"] = br
  1346. this.ServeJSON()
  1347. }()
  1348. AdminUser := this.SysUser
  1349. if AdminUser == nil {
  1350. br.Msg = "请登录"
  1351. br.ErrMsg = "请登录,用户信息为空"
  1352. br.Ret = 408
  1353. return
  1354. }
  1355. req := new(cygx.CygxArticleReq)
  1356. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1357. if err != nil {
  1358. br.Msg = "参数解析异常!"
  1359. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1360. return
  1361. }
  1362. name := req.ArticleTypeName
  1363. if name == "" {
  1364. br.Msg = "内容不能为空!"
  1365. return
  1366. }
  1367. var condition string
  1368. condition = ` AND article_type_name = '` + name + `'`
  1369. count, err := cygx.GetCygxArticleTypeCount(condition)
  1370. if err != nil {
  1371. br.Msg = "操作失败!"
  1372. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  1373. return
  1374. }
  1375. if count > 0 {
  1376. br.Msg = "该类型已存在,请重新填写!"
  1377. return
  1378. }
  1379. count, err = cygx.GetCygxArticleTypeCount("")
  1380. if err != nil {
  1381. br.Msg = "操作失败!"
  1382. br.ErrMsg = "获取已添加的数量失败,Err:" + err.Error()
  1383. return
  1384. }
  1385. item := new(cygx.CygxArticleType)
  1386. item.ArticleTypeName = name
  1387. item.YanxPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN + name
  1388. item.IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1389. item.IcoLinkM = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/FEvPxfalkGKllLIlBMKumm47zhEx.png"
  1390. item.YanxPermissionId = 1001 + count // id 数量从一千开始计算
  1391. item.CreateTime = time.Now()
  1392. item.ModifyTime = time.Now()
  1393. _, err = cygx.AddCygxArticleType(item)
  1394. if err != nil {
  1395. br.Msg = "操作失败"
  1396. br.ErrMsg = "操作失败,Err:" + err.Error()
  1397. return
  1398. }
  1399. br.Ret = 200
  1400. br.Success = true
  1401. br.Msg = "操作成功"
  1402. br.IsAddLog = true
  1403. }
  1404. // @Title 留言列表详情
  1405. // @Description 获取留言列表详情接口
  1406. // @Param ArticleId query int true "文章ID"
  1407. // @Success 200 {object} cygx.ArticleCommentListResp
  1408. // @router /summaryManage/commentList [get]
  1409. func (this *SummaryManage) CommentList() {
  1410. br := new(models.BaseResponse).Init()
  1411. defer func() {
  1412. this.Data["json"] = br
  1413. this.ServeJSON()
  1414. }()
  1415. sysUser := this.SysUser
  1416. if sysUser == nil {
  1417. br.Msg = "请登录"
  1418. br.ErrMsg = "请登录,SysUser Is Empty"
  1419. return
  1420. }
  1421. articleId, _ := this.GetInt("ArticleId")
  1422. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1423. if articleInfo == nil {
  1424. br.Msg = "操作失败"
  1425. br.ErrMsg = "报告ID错误"
  1426. return
  1427. }
  1428. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1429. resp := new(cygx.ArticleCommentListResp)
  1430. if err != nil {
  1431. br.Msg = "获取留言失败"
  1432. br.ErrMsg = "获取留言失败,Err:" + err.Error()
  1433. return
  1434. }
  1435. resp.List = list
  1436. br.Ret = 200
  1437. br.Success = true
  1438. br.Msg = "获取成功"
  1439. br.Data = resp
  1440. }
  1441. // @Title 提问详情excel表格下载
  1442. // @Description 提问详情excel表格下载接口
  1443. // @Param SummaryManageId query int true "纪要ID"
  1444. // @Success 200 导出成功
  1445. // @router /summaryManage/commentListExport [get]
  1446. func (this *SummaryManage) CommentListExport() {
  1447. br := new(models.BaseResponse).Init()
  1448. defer func() {
  1449. this.Data["json"] = br
  1450. this.ServeJSON()
  1451. }()
  1452. sysUser := this.SysUser
  1453. if sysUser == nil {
  1454. br.Msg = "请登录"
  1455. br.ErrMsg = "请登录,SysUser Is Empty"
  1456. return
  1457. }
  1458. articleId, _ := this.GetInt("ArticleId")
  1459. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1460. if articleInfo == nil {
  1461. br.Msg = "操作失败"
  1462. br.ErrMsg = "报告ID错误"
  1463. return
  1464. }
  1465. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1466. if err != nil {
  1467. br.Msg = "获取失败"
  1468. br.ErrMsg = "获取失败,Err:" + err.Error()
  1469. return
  1470. }
  1471. //创建excel
  1472. dir, err := os.Executable()
  1473. exPath := filepath.Dir(dir)
  1474. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1475. xlsxFile := xlsx.NewFile()
  1476. if err != nil {
  1477. br.Msg = "生成文件失败"
  1478. br.ErrMsg = "生成文件失败"
  1479. return
  1480. }
  1481. style := xlsx.NewStyle()
  1482. alignment := xlsx.Alignment{
  1483. Horizontal: "center",
  1484. Vertical: "center",
  1485. WrapText: true,
  1486. }
  1487. style.Alignment = alignment
  1488. style.ApplyAlignment = true
  1489. sheet, err := xlsxFile.AddSheet("名单")
  1490. if err != nil {
  1491. br.Msg = "新增Sheet失败"
  1492. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1493. return
  1494. }
  1495. //标头
  1496. rowTitle := sheet.AddRow()
  1497. cellA := rowTitle.AddCell()
  1498. cellA.Value = "姓名"
  1499. cellB := rowTitle.AddCell()
  1500. cellB.Value = "公司名称"
  1501. cellC := rowTitle.AddCell()
  1502. cellC.Value = "留言"
  1503. cellD := rowTitle.AddCell()
  1504. cellD.Value = "提交时间"
  1505. for _, item := range list {
  1506. row := sheet.AddRow()
  1507. cellA := row.AddCell()
  1508. cellA.Value = item.RealName
  1509. cellB := row.AddCell()
  1510. cellB.Value = item.CompanyName
  1511. cellC := row.AddCell()
  1512. cellC.Value = item.Content
  1513. cellD := row.AddCell()
  1514. cellD.Value = item.CreateTime
  1515. }
  1516. err = xlsxFile.Save(downLoadnFilePath)
  1517. if err != nil {
  1518. br.Msg = "保存文件失败"
  1519. br.ErrMsg = "保存文件失败"
  1520. return
  1521. }
  1522. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1523. downloadFileName := "留言列表" + randStr + ".xlsx"
  1524. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1525. defer func() {
  1526. os.Remove(downLoadnFilePath)
  1527. }()
  1528. br.Success = true
  1529. br.Ret = 200
  1530. br.Msg = "导出成功"
  1531. }
  1532. // @Title 文章的见范围修改
  1533. // @Description 文章的见范围修改接口
  1534. // @Param request body cygx.SummaryManageIdRep true "type json string"
  1535. // @Success 200 操作成功
  1536. // @router /summaryManage/visibleRange [post]
  1537. func (this *SummaryManage) VisibleRange() {
  1538. br := new(models.BaseResponse).Init()
  1539. defer func() {
  1540. this.Data["json"] = br
  1541. this.ServeJSON()
  1542. }()
  1543. AdminUser := this.SysUser
  1544. indexName := utils.IndexName
  1545. if AdminUser == nil {
  1546. br.Msg = "请登录"
  1547. br.ErrMsg = "请登录,用户信息为空"
  1548. br.Ret = 408
  1549. return
  1550. }
  1551. var req cygx.SummaryManageIdRep
  1552. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1553. if err != nil {
  1554. br.Msg = "参数解析异常!"
  1555. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1556. return
  1557. }
  1558. articleId := req.ArticleId
  1559. item := new(cygx.CygxArticle)
  1560. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  1561. if articleInfo == nil {
  1562. br.Msg = "操作失败"
  1563. br.ErrMsg = "纪要ID错误"
  1564. return
  1565. }
  1566. if errInfo != nil {
  1567. br.Msg = "操作失败"
  1568. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1569. return
  1570. }
  1571. item.ArticleId = articleId
  1572. item.Title = articleInfo.Title
  1573. item.BodyText = articleInfo.BodyText
  1574. item.Body = articleInfo.Body
  1575. item.PublishDate = articleInfo.PublishDate
  1576. item.ExpertBackground = articleInfo.ExpertBackground
  1577. item.CategoryId = articleInfo.CategoryId
  1578. if articleInfo.VisibleRange == 0 {
  1579. item.VisibleRange = 1
  1580. item.AdminId = AdminUser.AdminId
  1581. item.AdminName = AdminUser.RealName
  1582. services.EsAddOrEditData(item)
  1583. //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  1584. } else {
  1585. item.AdminId = articleInfo.AdminId
  1586. item.AdminName = articleInfo.AdminName
  1587. item.PublishStatus = 0
  1588. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  1589. //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  1590. }
  1591. err = cygx.ArticleVisibleRange(item)
  1592. if err != nil {
  1593. br.Msg = "操作失败"
  1594. br.ErrMsg = "操作失败,Err:" + err.Error()
  1595. return
  1596. }
  1597. //专项调研类型的报告单独走发送
  1598. if articleInfo.SubCategoryName == "专项调研" {
  1599. if item.PublishStatus == 1 {
  1600. cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
  1601. }
  1602. } else {
  1603. if item.PublishStatus == 1 {
  1604. articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
  1605. if articleIndustrial.ArticleId > 0 {
  1606. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  1607. }
  1608. }
  1609. }
  1610. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  1611. br.Ret = 200
  1612. br.Success = true
  1613. br.Msg = "操作成功"
  1614. br.IsAddLog = true
  1615. }
  1616. // @Title 文章的置顶与取消置顶
  1617. // @Description 活动的发布与取消发布接口
  1618. // @Param request body cygx.ActivityIdRep true "type json string"
  1619. // @Success 200 操作成功
  1620. // @router /summaryManage/top_change [post]
  1621. func (this *SummaryManage) TopeChange() {
  1622. br := new(models.BaseResponse).Init()
  1623. defer func() {
  1624. this.Data["json"] = br
  1625. this.ServeJSON()
  1626. }()
  1627. AdminUser := this.SysUser
  1628. if AdminUser == nil {
  1629. br.Msg = "请登录"
  1630. br.ErrMsg = "请登录,用户信息为空"
  1631. br.Ret = 408
  1632. return
  1633. }
  1634. var req cygx.SummaryManageIdRep
  1635. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1636. if err != nil {
  1637. br.Msg = "参数解析异常!"
  1638. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1639. return
  1640. }
  1641. articleId := req.ArticleId
  1642. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  1643. if articleInfo == nil {
  1644. br.Msg = "操作失败"
  1645. br.ErrMsg = "纪要ID错误"
  1646. return
  1647. }
  1648. if errInfo != nil {
  1649. br.Msg = "操作失败"
  1650. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1651. return
  1652. }
  1653. var topTime int
  1654. //如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间
  1655. if articleInfo.TopTime == 0 {
  1656. topTime = int(time.Now().Unix())
  1657. }
  1658. err = cygx.UpdateArticleTopTime(articleId, topTime)
  1659. if err != nil {
  1660. br.Msg = "操作失败"
  1661. br.ErrMsg = "操作失败,Err:" + err.Error()
  1662. return
  1663. }
  1664. br.Ret = 200
  1665. br.Success = true
  1666. br.Msg = "操作成功"
  1667. br.IsAddLog = true
  1668. }