summary_manage.go 51 KB

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