report_chapter.go 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/models"
  5. "eta/eta_api/models/report"
  6. "eta/eta_api/models/system"
  7. "eta/eta_api/services"
  8. "eta/eta_api/services/data"
  9. "eta/eta_api/utils"
  10. "html"
  11. "os"
  12. "path"
  13. "strconv"
  14. "strings"
  15. "sync"
  16. "time"
  17. )
  18. // AddChapter
  19. // @Title 新增晨周报章节内容
  20. // @Description 新增晨周报章节内容
  21. // @Param request body models.AddReportChapterReq true "type json string"
  22. // @Success 200 Ret=200 保存成功
  23. // @router /chapter/add [post]
  24. func (this *ReportController) AddChapter() {
  25. br := new(models.BaseResponse).Init()
  26. defer func() {
  27. this.Data["json"] = br
  28. this.ServeJSON()
  29. }()
  30. sysUser := this.SysUser
  31. if sysUser == nil {
  32. br.Msg = "请登录"
  33. br.ErrMsg = "请登录,SysUser Is Empty"
  34. br.Ret = 408
  35. return
  36. }
  37. var req models.AddReportChapterReq
  38. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  39. if err != nil {
  40. br.Msg = "参数解析异常!"
  41. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  42. return
  43. }
  44. if req.ReportId <= 0 {
  45. br.Msg = "报告ID有误"
  46. return
  47. }
  48. req.Title = strings.TrimSpace(req.Title)
  49. if req.Title == `` {
  50. br.Msg = "章节名称不能为空"
  51. return
  52. }
  53. // 获取报告详情
  54. reportInfo, err := models.GetReportByReportId(req.ReportId)
  55. if err != nil {
  56. br.Msg = "报告信息有误"
  57. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  58. return
  59. }
  60. if reportInfo.State == 2 {
  61. br.Msg = "该报告已发布,不允许新增"
  62. br.ErrMsg = "该报告已发布,不允许新增"
  63. return
  64. }
  65. //newContent := req.Content
  66. //// 更新章节及指标
  67. //contentSub := ""
  68. //if req.Content != "" {
  69. // e := utils.ContentXssCheck(req.Content)
  70. // if e != nil {
  71. // br.Msg = "存在非法标签"
  72. // br.ErrMsg = "存在非法标签, Err: " + e.Error()
  73. // return
  74. // }
  75. // contentClean, e := services.FilterReportContentBr(req.Content)
  76. // if e != nil {
  77. // br.Msg = "内容去除前后空格失败"
  78. // br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
  79. // return
  80. // }
  81. // req.Content = contentClean
  82. //
  83. // contentSub, err = services.GetReportContentSub(req.Content)
  84. // if err != nil {
  85. // br.Msg = "内容分段解析失败"
  86. // br.ErrMsg = "编辑报告章节-解析 ContentSub 失败, Err: " + err.Error()
  87. // return
  88. // }
  89. //}
  90. //if req.Content == "" {
  91. // req.Content = newContent
  92. //}
  93. // 最小单元的分类
  94. var minClassifyId int
  95. var minClassifyName string
  96. if reportInfo.ClassifyIdThird > 0 {
  97. minClassifyId = reportInfo.ClassifyIdThird
  98. minClassifyName = reportInfo.ClassifyNameThird
  99. } else if reportInfo.ClassifyIdSecond > 0 {
  100. minClassifyId = reportInfo.ClassifyIdSecond
  101. minClassifyName = reportInfo.ClassifyNameSecond
  102. } else {
  103. minClassifyId = reportInfo.ClassifyIdFirst
  104. minClassifyName = reportInfo.ClassifyNameFirst
  105. }
  106. // 判断名称是否重复
  107. {
  108. var condition string
  109. var pars []interface{}
  110. condition += " AND report_id = ? AND title=? "
  111. pars = append(pars, req.ReportId, req.Title)
  112. count, err := models.GetCountReportChapterByCondition(condition, pars)
  113. if err != nil {
  114. br.Msg = "新增失败"
  115. br.ErrMsg = "判断章节名称是否存在失败,Err:" + err.Error()
  116. return
  117. }
  118. if count > 0 {
  119. br.Msg = "章节名称不允许重复"
  120. br.ErrMsg = "章节名称不允许重复"
  121. br.IsSendEmail = false
  122. return
  123. }
  124. }
  125. reportChapterInfo := new(models.ReportChapter)
  126. reportChapterInfo.ReportId = reportInfo.Id
  127. reportChapterInfo.ClassifyIdFirst = minClassifyId
  128. reportChapterInfo.ClassifyNameFirst = minClassifyName
  129. reportChapterInfo.Title = req.Title
  130. reportChapterInfo.AddType = 1
  131. reportChapterInfo.PublishState = 1
  132. //reportChapterInfo.Author = req.Author
  133. //reportChapterInfo.Content = html.EscapeString(req.Content)
  134. //reportChapterInfo.ContentSub = html.EscapeString(contentSub)
  135. reportChapterInfo.IsEdit = 1
  136. //reportChapterInfo.CreateTime = req.CreateTime
  137. reportChapterInfo.CreateTime = reportInfo.CreateTime
  138. reportChapterInfo.ModifyTime = time.Now()
  139. reportChapterInfo.ReportCreateTime = time.Now()
  140. reportChapterInfo.VideoKind = 2
  141. reportChapterInfo.Stage = reportInfo.Stage
  142. reportChapterInfo.LastModifyAdminId = sysUser.AdminId
  143. reportChapterInfo.LastModifyAdminName = sysUser.RealName
  144. reportChapterInfo.ContentModifyTime = time.Now()
  145. //reportChapterInfo.ContentStruct = html.EscapeString(req.ContentStruct)
  146. //reportChapterInfo.CanvasColor = req.CanvasColor
  147. //reportChapterInfo.HeadResourceId = req.HeadResourceId
  148. //reportChapterInfo.EndResourceId = req.EndResourceId
  149. err, errMsg := services.AddChapterBaseInfoAndPermission(reportInfo, reportChapterInfo, req.PermissionIdList, req.AdminIdList)
  150. if err != nil {
  151. br.Msg = "保存失败"
  152. if errMsg != "" {
  153. br.Msg = errMsg
  154. }
  155. br.ErrMsg = "保存失败,Err:" + err.Error()
  156. return
  157. }
  158. br.Ret = 200
  159. br.Success = true
  160. br.Msg = "保存成功"
  161. }
  162. // EditChapterBaseInfoAndPermission
  163. // @Title 修改报告章节的基础信息、授权用户权限、品种权限
  164. // @Description 修改报告章节的基础信息、授权用户权限、品种权限
  165. // @Param request body models.EditReportChapterReq true "type json string"
  166. // @Success 200 Ret=200 保存成功
  167. // @router /chapter/base_info/edit [post]
  168. func (this *ReportController) EditChapterBaseInfoAndPermission() {
  169. br := new(models.BaseResponse).Init()
  170. defer func() {
  171. this.Data["json"] = br
  172. this.ServeJSON()
  173. }()
  174. sysUser := this.SysUser
  175. if sysUser == nil {
  176. br.Msg = "请登录"
  177. br.ErrMsg = "请登录,SysUser Is Empty"
  178. br.Ret = 408
  179. return
  180. }
  181. var req models.EditReportChapterBaseInfoAndPermissionReq
  182. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  183. if err != nil {
  184. br.Msg = "参数解析异常!"
  185. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  186. return
  187. }
  188. reportChapterId := req.ReportChapterId
  189. if reportChapterId <= 0 {
  190. br.Msg = "报告章节ID有误"
  191. return
  192. }
  193. req.Title = strings.TrimSpace(req.Title)
  194. if req.Title == `` {
  195. br.Msg = "章节名称不能为空"
  196. return
  197. }
  198. // 获取章节详情
  199. reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
  200. if err != nil {
  201. br.Msg = "报告章节信息有误"
  202. br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
  203. return
  204. }
  205. // 判断名称是否重复
  206. {
  207. var condition string
  208. var pars []interface{}
  209. condition += " AND report_id = ? AND title=? AND report_chapter_id != ? "
  210. pars = append(pars, reportChapterInfo.ReportId, req.Title, reportChapterId)
  211. count, err := models.GetCountReportChapterByCondition(condition, pars)
  212. if err != nil {
  213. br.Msg = "新增失败"
  214. br.ErrMsg = "判断章节名称是否存在失败,Err:" + err.Error()
  215. return
  216. }
  217. if count > 0 {
  218. br.Msg = "章节名称不允许重复"
  219. br.ErrMsg = "章节名称不允许重复"
  220. br.IsSendEmail = false
  221. return
  222. }
  223. }
  224. // 获取报告详情
  225. reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
  226. if err != nil {
  227. br.Msg = "报告信息有误"
  228. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  229. return
  230. }
  231. if reportInfo.State == 2 {
  232. br.Msg = "该报告已发布,不允许编辑"
  233. br.ErrMsg = "该报告已发布,不允许编辑"
  234. br.IsSendEmail = false
  235. return
  236. }
  237. // 报告的最后编辑人
  238. reportInfo.LastModifyAdminId = sysUser.AdminId
  239. reportInfo.LastModifyAdminName = sysUser.RealName
  240. reportInfo.ModifyTime = time.Now()
  241. err, errMsg := services.EditChapterBaseInfoAndPermission(reportInfo, reportChapterInfo, req.Title, req.PermissionIdList, req.AdminIdList)
  242. if err != nil {
  243. br.Msg = "保存失败"
  244. if errMsg != "" {
  245. br.Msg = errMsg
  246. }
  247. br.ErrMsg = "保存失败,Err:" + err.Error()
  248. return
  249. }
  250. br.Ret = 200
  251. br.Success = true
  252. br.Msg = "保存成功"
  253. }
  254. // EditDayWeekChapter
  255. // @Title 编辑晨周报章节内容
  256. // @Description 编辑晨周报章节内容
  257. // @Param request body models.EditReportChapterReq true "type json string"
  258. // @Success 200 Ret=200 保存成功
  259. // @router /editDayWeekChapter [post]
  260. func (this *ReportController) EditDayWeekChapter() {
  261. br := new(models.BaseResponse).Init()
  262. defer func() {
  263. this.Data["json"] = br
  264. this.ServeJSON()
  265. }()
  266. sysUser := this.SysUser
  267. if sysUser == nil {
  268. br.Msg = "请登录"
  269. br.ErrMsg = "请登录,SysUser Is Empty"
  270. br.Ret = 408
  271. return
  272. }
  273. var req models.EditReportChapterReq
  274. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  275. if err != nil {
  276. br.Msg = "参数解析异常!"
  277. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  278. return
  279. }
  280. reportChapterId := req.ReportChapterId
  281. if reportChapterId <= 0 {
  282. br.Msg = "报告章节ID有误"
  283. return
  284. }
  285. if req.Content == "" {
  286. br.Msg = "请输入内容"
  287. return
  288. }
  289. // 获取章节详情
  290. reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
  291. if err != nil {
  292. br.Msg = "报告章节信息有误"
  293. br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
  294. return
  295. }
  296. // 获取报告详情
  297. reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
  298. if err != nil {
  299. br.Msg = "报告信息有误"
  300. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  301. return
  302. }
  303. // 操作权限校验
  304. hasAuth, msg, errMsg, isSendEmail := checkOpPermission(sysUser, reportInfo, reportChapterInfo, true, this.Lang)
  305. if !hasAuth {
  306. br.Msg = msg
  307. br.ErrMsg = errMsg
  308. br.IsSendEmail = isSendEmail
  309. return
  310. }
  311. if reportInfo.State == 2 {
  312. br.Msg = "该报告已发布,不允许编辑"
  313. br.ErrMsg = "该报告已发布,不允许编辑"
  314. br.IsSendEmail = false
  315. return
  316. }
  317. if reportChapterInfo.PublishState == 2 {
  318. br.Msg = "该报告章节已发布,不允许编辑"
  319. br.ErrMsg = "该报告章节已发布,不允许编辑"
  320. br.IsSendEmail = false
  321. return
  322. }
  323. // 报告的最后编辑人
  324. reportInfo.LastModifyAdminId = sysUser.AdminId
  325. reportInfo.LastModifyAdminName = sysUser.RealName
  326. reportInfo.ModifyTime = time.Now()
  327. updateCols := make([]string, 0)
  328. reqTickerList := req.TickerList
  329. // 更新章节及指标
  330. contentSub := ""
  331. if req.Content != "" {
  332. // 处理关联excel的表格id
  333. req.Content = services.HandleReportContentTable(reportInfo.Id, req.Content)
  334. req.Content = services.HandleReportContent(req.Content, "del", nil)
  335. e := utils.ContentXssCheck(req.Content)
  336. if e != nil {
  337. br.Msg = "存在非法标签"
  338. br.ErrMsg = "存在非法标签, Err: " + e.Error()
  339. return
  340. }
  341. contentClean, e := services.FilterReportContentBr(req.Content)
  342. if e != nil {
  343. br.Msg = "内容去除前后空格失败"
  344. br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
  345. return
  346. }
  347. req.Content = contentClean
  348. contentSub, err = services.GetReportContentSub(req.Content)
  349. if err != nil {
  350. br.Msg = "内容分段解析失败"
  351. br.ErrMsg = "编辑报告章节-解析 ContentSub 失败, Err: " + err.Error()
  352. return
  353. }
  354. }
  355. if req.Title != "" {
  356. reportChapterInfo.Title = req.Title
  357. updateCols = append(updateCols, "Title")
  358. }
  359. //reportChapterInfo.AddType = req.AddType
  360. reportChapterInfo.Author = req.Author
  361. reportChapterInfo.Content = html.EscapeString(req.Content)
  362. reportChapterInfo.ContentSub = html.EscapeString(contentSub)
  363. reportChapterInfo.IsEdit = 1
  364. reportChapterInfo.ModifyTime = time.Now()
  365. if req.CreateTime != `` {
  366. reportChapterInfo.CreateTime = req.CreateTime
  367. updateCols = append(updateCols, "CreateTime")
  368. }
  369. reportChapterInfo.LastModifyAdminId = sysUser.AdminId
  370. reportChapterInfo.LastModifyAdminName = sysUser.RealName
  371. reportChapterInfo.ContentModifyTime = time.Now()
  372. if req.ContentStruct != `` {
  373. req.ContentStruct = services.HandleReportContentStructTable(reportChapterInfo.ReportId, req.ContentStruct)
  374. req.ContentStruct = services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  375. }
  376. reportChapterInfo.ContentStruct = html.EscapeString(req.ContentStruct)
  377. updateCols = append(updateCols, "Author", "Content", "ContentSub", "IsEdit", "ModifyTime")
  378. updateCols = append(updateCols, "LastModifyAdminId", "LastModifyAdminName", "ContentModifyTime", "ContentStruct")
  379. // 章节报告更新指标
  380. tickerList := make([]*models.ReportChapterTicker, 0)
  381. if len(reqTickerList) > 0 {
  382. nowTime := time.Now()
  383. for i := 0; i < len(reqTickerList); i++ {
  384. tickerList = append(tickerList, &models.ReportChapterTicker{
  385. ReportChapterId: reportChapterInfo.ReportChapterId,
  386. Sort: reqTickerList[i].Sort,
  387. Ticker: reqTickerList[i].Ticker,
  388. CreateTime: nowTime,
  389. UpdateTime: nowTime,
  390. })
  391. }
  392. }
  393. if reportInfo.ReportLayout == 3 {
  394. //对自由布局的数据做一个处理
  395. //自由布局更新每页的数据
  396. ormList := report.ToOrmViewList(req.FreeLayoutContentPages, true, reportInfo.Id, reportChapterId)
  397. var wg sync.WaitGroup
  398. wg.Add(len(ormList))
  399. for _, v := range ormList {
  400. go func(v *report.ReportFreeLayout) {
  401. defer wg.Done()
  402. content := v.Content
  403. if content != "" {
  404. e := utils.ContentXssCheck(content)
  405. if e != nil {
  406. br.Msg = "存在非法标签"
  407. br.ErrMsg = "存在非法标签, Err: " + e.Error()
  408. return
  409. }
  410. contentClean, e := services.FilterReportContentBr(content)
  411. if e != nil {
  412. br.Msg = "内容去除前后空格失败"
  413. br.ErrMsg = "内容去除前后空格失败, Err: " + e.Error()
  414. return
  415. }
  416. content = contentClean
  417. if v.ContentStruct != `` {
  418. v.ContentStruct = services.HandleReportContentStructTable(reportChapterInfo.ReportId, req.ContentStruct)
  419. v.ContentStruct = services.HandleReportContentStruct(req.ContentStruct, "del", nil)
  420. }
  421. v.Content = html.EscapeString(content)
  422. v.ContentStruct = html.EscapeString(v.ContentStruct)
  423. }
  424. }(v)
  425. }
  426. wg.Wait()
  427. err = models.UpdateChapterFreeLayoutContentPage(reportInfo, reportChapterInfo, updateCols, tickerList, ormList)
  428. if err != nil {
  429. br.Msg = "保存失败"
  430. br.ErrMsg = "保存失败,Err:" + err.Error()
  431. return
  432. }
  433. } else {
  434. err = models.UpdateChapterAndTicker(reportInfo, reportChapterInfo, updateCols, tickerList)
  435. if err != nil {
  436. br.Msg = "保存失败"
  437. br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
  438. return
  439. }
  440. }
  441. // 标记更新中
  442. {
  443. markStatus, err := services.UpdateReportEditMark(reportChapterInfo.ReportId, reportChapterInfo.ReportChapterId, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
  444. if err != nil {
  445. br.Msg = err.Error()
  446. return
  447. }
  448. if markStatus.Status == 1 {
  449. br.Msg = markStatus.Msg
  450. return
  451. }
  452. }
  453. // 备份关键数据
  454. chapters := make([]*models.ReportChapter, 0)
  455. chapters = append(chapters, reportChapterInfo)
  456. go services.SaveReportLogs(nil, chapters, sysUser.AdminId, sysUser.RealName)
  457. br.Ret = 200
  458. br.Success = true
  459. br.Msg = "保存成功"
  460. }
  461. // DelChapter
  462. // @Title 编辑晨周报章节内容
  463. // @Description 编辑晨周报章节内容
  464. // @Param request body models.EditReportChapterReq true "type json string"
  465. // @Success 200 Ret=200 保存成功
  466. // @router /chapter/del [post]
  467. func (this *ReportController) DelChapter() {
  468. br := new(models.BaseResponse).Init()
  469. defer func() {
  470. this.Data["json"] = br
  471. this.ServeJSON()
  472. }()
  473. sysUser := this.SysUser
  474. if sysUser == nil {
  475. br.Msg = "请登录"
  476. br.ErrMsg = "请登录,SysUser Is Empty"
  477. br.Ret = 408
  478. return
  479. }
  480. var req models.DelReportChapterReq
  481. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  482. if err != nil {
  483. br.Msg = "参数解析异常!"
  484. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  485. return
  486. }
  487. reportChapterId := req.ReportChapterId
  488. if reportChapterId <= 0 {
  489. br.Msg = "报告章节ID有误"
  490. return
  491. }
  492. // 获取章节详情
  493. reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
  494. if err != nil {
  495. br.Msg = "报告章节信息有误"
  496. br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
  497. return
  498. }
  499. // 获取报告详情
  500. reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
  501. if err != nil {
  502. br.Msg = "报告信息有误"
  503. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  504. return
  505. }
  506. // 操作权限校验
  507. hasAuth, msg, errMsg, isSendEmail := checkOpPermission(sysUser, reportInfo, reportChapterInfo, true, this.Lang)
  508. if !hasAuth {
  509. br.Msg = msg
  510. br.ErrMsg = errMsg
  511. br.IsSendEmail = isSendEmail
  512. return
  513. }
  514. if reportInfo.State == 2 {
  515. br.Msg = "该报告已发布,不允许编辑"
  516. br.ErrMsg = "该报告已发布,不允许编辑"
  517. br.IsSendEmail = false
  518. return
  519. }
  520. // 删除章节
  521. err, errMsg = services.DelChapter(reportInfo, reportChapterInfo, sysUser)
  522. if err != nil {
  523. br.Msg = "删除失败"
  524. if errMsg != "" {
  525. br.Msg = errMsg
  526. }
  527. br.ErrMsg = "删除失败,Err:" + err.Error()
  528. return
  529. }
  530. // 备份关键数据
  531. chapters := make([]*models.ReportChapter, 0)
  532. chapters = append(chapters, reportChapterInfo)
  533. go services.SaveReportLogs(nil, chapters, sysUser.AdminId, sysUser.RealName)
  534. br.Ret = 200
  535. br.Success = true
  536. br.Msg = "删除成功"
  537. }
  538. // GetReportChapterList
  539. // @Title 获取报告章节列表
  540. // @Description 获取报告章节列表
  541. // @Param ReportId query string true "报告ID"
  542. // @Success 200 {object} company.CompanyListResp
  543. // @router /getReportChapterList [get]
  544. func (this *ReportController) GetReportChapterList() {
  545. br := new(models.BaseResponse).Init()
  546. defer func() {
  547. this.Data["json"] = br
  548. this.ServeJSON()
  549. }()
  550. sysUser := this.SysUser
  551. if sysUser == nil {
  552. br.Msg = "请登录"
  553. br.ErrMsg = "请登录,SysUser Is Empty"
  554. br.Ret = 408
  555. return
  556. }
  557. reqReportId := this.GetString("ReportId")
  558. reportId, _ := strconv.Atoi(reqReportId)
  559. if reportId <= 0 {
  560. br.Msg = "报告ID有误"
  561. return
  562. }
  563. // 获取报告信息
  564. reportInfo, err := models.GetReportByReportId(reportId)
  565. if err != nil {
  566. br.Msg = "获取报告信息失败"
  567. br.ErrMsg = "获取报告信息失败, Err: " + err.Error()
  568. return
  569. }
  570. // 权限校验
  571. isAuth, err := services.CheckReportAuthByReportId(sysUser, reportInfo.AdminId, reportId)
  572. if err != nil {
  573. br.Msg = "获取报告权限失败"
  574. br.ErrMsg = "获取报告权限失败,Err:" + err.Error()
  575. return
  576. }
  577. if !isAuth {
  578. br.Msg = "无操作权限"
  579. br.ErrMsg = "无操作权限"
  580. return
  581. }
  582. // 获取章节列表
  583. chapterList, err := models.GetChapterListByReportId(reportId)
  584. if err != nil {
  585. br.Msg = "获取章节列表失败"
  586. br.ErrMsg = "获取章节列表失败, Err: " + err.Error()
  587. return
  588. }
  589. typeList, err := models.GetReportChapterTypeList()
  590. if err != nil {
  591. br.Msg = "获取章节类型列表失败"
  592. br.ErrMsg = "获取章节类型列表失败, Err: " + err.Error()
  593. return
  594. }
  595. typeIdImg := make(map[int]string)
  596. for i := 0; i < len(typeList); i++ {
  597. typeIdImg[typeList[i].ReportChapterTypeId] = typeList[i].EditImgUrl
  598. }
  599. resp := make([]models.ReportChapterResp, 0)
  600. if len(chapterList) > 0 {
  601. chapterIdList := make([]int, 0)
  602. // 章节id授权用户列表map
  603. chapterIdGrandListMap := make(map[int][]int)
  604. // 章节id关联品种id列表map
  605. chapterIdPermissionListMap := make(map[int][]int)
  606. for _, v := range chapterList {
  607. chapterIdList = append(chapterIdList, v.ReportChapterId)
  608. }
  609. // 处理章节id授权用户列表
  610. {
  611. chapterGrantObj := report.ReportChapterGrant{}
  612. chapterGrantList, tmpErr := chapterGrantObj.GetGrantListByIdList(chapterIdList)
  613. if tmpErr != nil {
  614. br.Msg = "获取章节id授权用户列表失败"
  615. br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
  616. return
  617. }
  618. for _, v := range chapterGrantList {
  619. tmpChapterIdGrandList, ok := chapterIdGrandListMap[v.ReportChapterId]
  620. if !ok {
  621. tmpChapterIdGrandList = make([]int, 0)
  622. }
  623. chapterIdGrandListMap[v.ReportChapterId] = append(tmpChapterIdGrandList, v.AdminId)
  624. }
  625. }
  626. // 处理章节id关联品种id列表
  627. {
  628. obj := report.ReportChapterPermissionMapping{}
  629. chapterPermissionList, tmpErr := obj.GetPermissionListByIdList(chapterIdList)
  630. if tmpErr != nil {
  631. br.Msg = "获取章节id关联品种列表失败"
  632. br.ErrMsg = "获取章节id关联品种列表失败, Err: " + tmpErr.Error()
  633. return
  634. }
  635. for _, v := range chapterPermissionList {
  636. tmpChapterIdPermissionList, ok := chapterIdPermissionListMap[v.ReportChapterId]
  637. if !ok {
  638. tmpChapterIdPermissionList = make([]int, 0)
  639. }
  640. chapterIdPermissionListMap[v.ReportChapterId] = append(tmpChapterIdPermissionList, v.ChartPermissionId)
  641. }
  642. }
  643. // 章节类型的字段
  644. for _, item := range chapterList {
  645. // 授权的用户列表
  646. tmpChapterIdGrandList, ok := chapterIdGrandListMap[item.ReportChapterId]
  647. if !ok {
  648. tmpChapterIdGrandList = make([]int, 0)
  649. }
  650. // 关联的品种列表
  651. tmpChapterIdPermissionList, ok := chapterIdPermissionListMap[item.ReportChapterId]
  652. if !ok {
  653. tmpChapterIdPermissionList = make([]int, 0)
  654. }
  655. tmpChapterItem := models.ReportChapterResp{
  656. ReportChapterId: item.ReportChapterId,
  657. ReportId: item.ReportId,
  658. ReportType: item.ReportType,
  659. TypeId: item.TypeId,
  660. TypeName: item.TypeName,
  661. TypeEditImg: typeIdImg[item.TypeId],
  662. Title: item.Title,
  663. IsEdit: item.IsEdit,
  664. Trend: item.Trend,
  665. Sort: item.Sort,
  666. PublishState: item.PublishState,
  667. VideoUrl: item.VideoUrl,
  668. VideoName: item.VideoName,
  669. VideoPlaySeconds: item.VideoPlaySeconds,
  670. VideoSize: item.VideoSize,
  671. VideoKind: item.VideoKind,
  672. ModifyTime: item.ModifyTime.Format(utils.FormatDate),
  673. GrandAdminIdList: tmpChapterIdGrandList,
  674. PermissionIdList: tmpChapterIdPermissionList,
  675. }
  676. markStatus, err := services.UpdateReportEditMark(item.ReportId, item.ReportChapterId, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
  677. if err != nil {
  678. br.Msg = "查询标记状态失败"
  679. br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
  680. return
  681. }
  682. if markStatus.Status == 0 {
  683. tmpChapterItem.CanEdit = true
  684. } else {
  685. tmpChapterItem.Editor = markStatus.Editor
  686. }
  687. // 报告章节的操作权限
  688. tmpChapterItem.IsAuth = services.CheckChapterAuthByAdminIdList(sysUser, reportInfo.AdminId, tmpChapterIdGrandList)
  689. resp = append(resp, tmpChapterItem)
  690. }
  691. }
  692. br.Ret = 200
  693. br.Success = true
  694. br.Msg = "获取成功"
  695. br.Data = resp
  696. }
  697. // GetDayWeekChapter
  698. // @Title 获取晨周报章节信息
  699. // @Description 获取晨周报章节信息
  700. // @Param ReportChapterId query int true "报告章节ID"
  701. // @Success 200 Ret=200 保存成功
  702. // @router /getDayWeekChapter [get]
  703. func (this *ReportController) GetDayWeekChapter() {
  704. br := new(models.BaseResponse).Init()
  705. defer func() {
  706. this.Data["json"] = br
  707. this.ServeJSON()
  708. }()
  709. sysUser := this.SysUser
  710. if sysUser == nil {
  711. br.Msg = "请登录"
  712. br.ErrMsg = "请登录,SysUser Is Empty"
  713. br.Ret = 408
  714. return
  715. }
  716. reportChapterId, _ := this.GetInt("ReportChapterId")
  717. if reportChapterId <= 0 {
  718. br.Msg = "参数有误"
  719. return
  720. }
  721. chapterItem, err := models.GetReportChapterItemById(reportChapterId)
  722. if err != nil {
  723. br.Msg = "获取章节信息失败"
  724. br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
  725. return
  726. }
  727. // 获取报告详情
  728. reportInfo, err := models.GetReportById(chapterItem.ReportId)
  729. if err != nil {
  730. br.Msg = "获取报告信息失败"
  731. br.ErrMsg = "获取报告信息失败, Err: " + err.Error()
  732. return
  733. }
  734. // 权限校验
  735. isAuth, err := services.CheckReportAuthByReportId(sysUser, reportInfo.AdminId, reportInfo.Id)
  736. if err != nil {
  737. br.Msg = "获取报告权限失败"
  738. br.ErrMsg = "获取报告权限失败,Err:" + err.Error()
  739. return
  740. }
  741. if !isAuth {
  742. br.Msg = "无操作权限"
  743. br.ErrMsg = "无操作权限"
  744. return
  745. }
  746. var pages []*report.ContentPage
  747. if reportInfo.ReportLayout == 3 {
  748. pages, err = report.GetSingleFreeLayoutChapterPagesByReportId(reportInfo.Id, reportChapterId)
  749. if err != nil {
  750. br.Msg = "获取自由布局页面列表"
  751. br.ErrMsg = "获取自由布局页面列表,Err:" + err.Error()
  752. return
  753. }
  754. for _, page := range pages {
  755. page.Content = html.UnescapeString(page.Content)
  756. page.ContentStruct = html.UnescapeString(page.ContentStruct)
  757. page.Content = services.HandleReportContentTable(page.ReportId, chapterItem.Content)
  758. page.ContentStruct = services.HandleReportContentStructTable(page.ReportId, chapterItem.ContentStruct)
  759. }
  760. }
  761. chapterItem.Content = html.UnescapeString(chapterItem.Content)
  762. chapterItem.ContentSub = html.UnescapeString(chapterItem.ContentSub)
  763. chapterItem.ContentStruct = html.UnescapeString(chapterItem.ContentStruct)
  764. chapterItem.Content = services.HandleReportContentTable(chapterItem.ReportId, chapterItem.Content)
  765. chapterItem.ContentStruct = services.HandleReportContentStructTable(chapterItem.ReportId, chapterItem.ContentStruct)
  766. businessConf, err := models.GetBusinessConfByKey(models.BusinessConfIsOpenChartExpired)
  767. if err != nil {
  768. br.Msg = "获取失败"
  769. br.ErrMsg = "获取配置失败,Err:" + err.Error()
  770. return
  771. }
  772. if businessConf.ConfVal == `true` {
  773. tokenMap := make(map[string]string)
  774. chapterItem.Content = services.HandleReportContent(chapterItem.Content, "add", tokenMap)
  775. chapterItem.ContentStruct = services.HandleReportContentStruct(chapterItem.ContentStruct, "add", tokenMap)
  776. if reportInfo.ReportLayout == 3 {
  777. for _, page := range pages {
  778. page.Content = services.HandleReportContent(page.Content, "add", tokenMap)
  779. page.ContentStruct = services.HandleReportContentStruct(page.ContentStruct, "add", tokenMap)
  780. }
  781. }
  782. }
  783. // 授权用户列表map
  784. chapterGrantIdList := make([]int, 0)
  785. // 关联品种id列表map
  786. chapterPermissionIdList := make([]int, 0)
  787. // 处理章节id授权用户列表
  788. {
  789. chapterGrantObj := report.ReportChapterGrant{}
  790. chapterGrantList, tmpErr := chapterGrantObj.GetGrantListById(chapterItem.ReportChapterId)
  791. if tmpErr != nil {
  792. br.Msg = "获取章节id授权用户列表失败"
  793. br.ErrMsg = "获取章节id授权用户列表失败, Err: " + tmpErr.Error()
  794. return
  795. }
  796. for _, v := range chapterGrantList {
  797. chapterGrantIdList = append(chapterGrantIdList, v.AdminId)
  798. }
  799. }
  800. // 处理章节id关联品种id列表
  801. {
  802. obj := report.ReportChapterPermissionMapping{}
  803. chapterPermissionList, tmpErr := obj.GetPermissionListById(chapterItem.ReportChapterId)
  804. if tmpErr != nil {
  805. br.Msg = "获取章节id关联品种列表失败"
  806. br.ErrMsg = "获取章节id关联品种列表失败, Err: " + tmpErr.Error()
  807. return
  808. }
  809. for _, v := range chapterPermissionList {
  810. chapterPermissionIdList = append(chapterPermissionIdList, v.ChartPermissionId)
  811. }
  812. }
  813. resp := models.ReportChapterItemResp{
  814. FreeLayoutPages: pages,
  815. ReportChapterItem: *chapterItem,
  816. GrandAdminIdList: chapterGrantIdList,
  817. PermissionIdList: chapterPermissionIdList,
  818. }
  819. // 获取当前编辑状态
  820. {
  821. markStatus, err := services.UpdateReportEditMark(chapterItem.ReportId, chapterItem.ReportChapterId, this.SysUser.AdminId, 2, this.SysUser.RealName, this.Lang)
  822. if err != nil {
  823. br.Msg = "查询标记状态失败"
  824. br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
  825. return
  826. }
  827. if markStatus.Status == 0 {
  828. resp.CanEdit = true
  829. } else {
  830. resp.Editor = markStatus.Editor
  831. }
  832. }
  833. br.Ret = 200
  834. br.Success = true
  835. br.Msg = "获取成功"
  836. br.Data = resp
  837. }
  838. // ChapterMove
  839. // @Title 移动章节类型
  840. // @Description 移动章节类型
  841. // @Param request body models.PermissionMoveReq true "type json string"
  842. // @Success 200 Ret=200 操作成功
  843. // @router /chapter/move [post]
  844. func (this *ReportController) ChapterMove() {
  845. br := new(models.BaseResponse).Init()
  846. defer func() {
  847. if br.ErrMsg == "" {
  848. br.IsSendEmail = false
  849. }
  850. this.Data["json"] = br
  851. this.ServeJSON()
  852. }()
  853. sysUser := this.SysUser
  854. if sysUser == nil {
  855. br.Msg = "请登录"
  856. br.ErrMsg = "请登录,SysUser Is Empty"
  857. br.Ret = 408
  858. return
  859. }
  860. var req models.ReportChapterMoveReq
  861. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  862. br.Msg = "参数解析异常!"
  863. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  864. return
  865. }
  866. if req.ReportChapterId == 0 {
  867. br.Msg = "请选择要移动的章节"
  868. return
  869. }
  870. e, msg := services.MoveReportChapter(&req)
  871. if e != nil {
  872. br.Msg = msg
  873. br.ErrMsg = "移动品种失败, Err: " + e.Error()
  874. return
  875. }
  876. br.Ret = 200
  877. br.Success = true
  878. br.Msg = "操作成功"
  879. }
  880. // EditChapterTrendTag
  881. // @Title 编辑章节趋势标签
  882. // @Description 编辑章节趋势标签
  883. // @Param request body models.EditReportChapterReq true "type json string"
  884. // @Success 200 Ret=200 保存成功
  885. // @router /editChapterTrendTag [post]
  886. func (this *ReportController) EditChapterTrendTag() {
  887. br := new(models.BaseResponse).Init()
  888. defer func() {
  889. this.Data["json"] = br
  890. this.ServeJSON()
  891. }()
  892. sysUser := this.SysUser
  893. if sysUser == nil {
  894. br.Msg = "请登录"
  895. br.ErrMsg = "请登录,SysUser Is Empty"
  896. br.Ret = 408
  897. return
  898. }
  899. var req models.EditChapterTrendTagReq
  900. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  901. if err != nil {
  902. br.Msg = "参数解析异常!"
  903. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  904. return
  905. }
  906. if req.ReportChapterId <= 0 {
  907. br.Msg = "章节ID有误"
  908. return
  909. }
  910. if req.Trend == "" {
  911. br.Msg = "请输入标签"
  912. return
  913. }
  914. chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
  915. if err != nil {
  916. br.Msg = "获取章节信息失败"
  917. br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
  918. return
  919. }
  920. // 获取报告详情
  921. reportInfo, err := models.GetReportByReportId(chapterInfo.ReportId)
  922. if err != nil {
  923. br.Msg = "报告信息有误"
  924. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  925. return
  926. }
  927. // 操作权限校验
  928. hasAuth, msg, errMsg, isSendEmail := checkOpPermission(sysUser, reportInfo, chapterInfo, false, this.Lang)
  929. if !hasAuth {
  930. br.Msg = msg
  931. br.ErrMsg = errMsg
  932. br.IsSendEmail = isSendEmail
  933. return
  934. }
  935. // 更新章节标签
  936. chapterInfo.Trend = req.Trend
  937. updateCols := make([]string, 0)
  938. updateCols = append(updateCols, "Trend")
  939. if err = chapterInfo.UpdateChapter(updateCols); err != nil {
  940. br.Msg = "更新标签失败"
  941. br.ErrMsg = "更新标签失败, Err: " + err.Error()
  942. return
  943. }
  944. // 添加关键词
  945. if err = models.AddTrendTagKeyWord(req.Trend); err != nil {
  946. br.Msg = "添加标签关键词失败"
  947. br.ErrMsg = "添加标签关键词失败, Err: " + err.Error()
  948. return
  949. }
  950. br.Ret = 200
  951. br.Success = true
  952. br.Msg = "保存成功"
  953. }
  954. // GetSunCode 获取太阳码
  955. // @Title 公共模块
  956. // @Description 获取分享海报
  957. // @Param request body models.SunCodeReq true "type json string"
  958. // @Success 200 {object} string "获取成功"
  959. // @failure 400 {string} string "获取失败"
  960. // @router /getSunCode [post]
  961. func (this *ReportController) GetSunCode() {
  962. br := new(models.BaseResponse).Init()
  963. defer func() {
  964. this.Data["json"] = br
  965. this.ServeJSON()
  966. }()
  967. sysUser := this.SysUser
  968. if sysUser == nil {
  969. br.Msg = "请登录"
  970. br.ErrMsg = "请登录,SysUser Is Empty"
  971. br.Ret = 408
  972. return
  973. }
  974. var req models.SunCodeReq
  975. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  976. if err != nil {
  977. br.Msg = "参数解析异常!"
  978. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  979. return
  980. }
  981. var sunCodeUrl string
  982. //先查,查不到再去生成上传
  983. item, err := models.GetYbPcSunCode(req.CodeScene, req.CodePage)
  984. if err != nil && !utils.IsErrNoRow(err) {
  985. br.Msg = "查询太阳码失败!"
  986. br.ErrMsg = "查询太阳码失败,Err:" + err.Error()
  987. return
  988. }
  989. if item != nil {
  990. sunCodeUrl = item.SuncodeUrl
  991. }
  992. if sunCodeUrl == "" {
  993. sunCodeUrl, err = services.PcCreateAndUploadSunCode(req.CodeScene, req.CodePage)
  994. if err != nil {
  995. br.Msg = "生成太阳码失败!"
  996. br.ErrMsg = "生成太阳码失败,Err:" + err.Error()
  997. return
  998. }
  999. }
  1000. br.Data = sunCodeUrl
  1001. br.Ret = 200
  1002. br.Success = true
  1003. br.Msg = "操作成功"
  1004. }
  1005. // VoiceUpload
  1006. // @Title 音频上传
  1007. // @Description 音频上传接口
  1008. // @Param file query file true "文件"
  1009. // @Param ReportChapterId query int true "报告章节ID"
  1010. // @Success Ret=200 上传成功
  1011. // @router /chapter/voice/upload [post]
  1012. func (this *ReportController) VoiceUpload() {
  1013. br := new(models.BaseResponse).Init()
  1014. defer func() {
  1015. this.Data["json"] = br
  1016. this.ServeJSON()
  1017. }()
  1018. f, h, err := this.GetFile("file")
  1019. if err != nil {
  1020. br.Msg = "获取资源信息失败"
  1021. br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
  1022. return
  1023. }
  1024. // 报告章节id
  1025. reportChapterId, err := this.GetInt("ReportChapterId", 0)
  1026. if err != nil {
  1027. br.Msg = "报告章节ID异常"
  1028. br.ErrMsg = "报告章节ID异常,Err:" + err.Error()
  1029. return
  1030. }
  1031. // 报告章节信息
  1032. reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
  1033. if err != nil {
  1034. br.Msg = "获取报告章节信息失败"
  1035. br.ErrMsg = "获取报告章节信息失败,Err:" + err.Error()
  1036. return
  1037. }
  1038. // 报告信息
  1039. reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
  1040. if err != nil {
  1041. br.Msg = "获取报告信息失败"
  1042. br.ErrMsg = "获取报告信息失败,Err:" + err.Error()
  1043. return
  1044. }
  1045. // 权限校验
  1046. isAuth, err := services.CheckChapterAuthByReportChapterInfo(this.SysUser, reportInfo.AdminId, reportChapterInfo)
  1047. if err != nil {
  1048. br.Msg = "获取报告权限失败"
  1049. br.ErrMsg = "获取报告权限失败,Err:" + err.Error()
  1050. return
  1051. }
  1052. if !isAuth {
  1053. br.Msg = "无操作权限"
  1054. br.ErrMsg = "无操作权限"
  1055. return
  1056. }
  1057. ext := path.Ext(h.Filename)
  1058. dateDir := time.Now().Format("20060102")
  1059. uploadDir := utils.STATIC_DIR + "hongze/" + dateDir
  1060. err = os.MkdirAll(uploadDir, utils.DIR_MOD)
  1061. if err != nil {
  1062. br.Msg = "存储目录创建失败"
  1063. br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
  1064. return
  1065. }
  1066. randStr := utils.GetRandStringNoSpecialChar(28)
  1067. fileName := randStr + ext
  1068. fPath := uploadDir + "/" + fileName
  1069. defer f.Close() //关闭上传文件
  1070. err = this.SaveToFile("file", fPath)
  1071. if err != nil {
  1072. br.Msg = "文件上传失败"
  1073. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1074. return
  1075. }
  1076. resourceUrl := ``
  1077. //上传到阿里云 和 minio
  1078. //if utils.ObjectStorageClient == "minio" {
  1079. // resourceUrl, err = services.UploadAudioToMinIo(fileName, fPath)
  1080. // if err != nil {
  1081. // br.Msg = "文件上传失败"
  1082. // br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1083. // return
  1084. // }
  1085. //} else {
  1086. // resourceUrl, err = services.UploadAudioAliyun(fileName, fPath)
  1087. // if err != nil {
  1088. // br.Msg = "文件上传失败"
  1089. // br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1090. // return
  1091. // }
  1092. //}
  1093. ossClient := services.NewOssClient()
  1094. if ossClient == nil {
  1095. br.Msg = "上传失败"
  1096. br.ErrMsg = "初始化OSS服务失败"
  1097. return
  1098. }
  1099. resourceUrl, err = ossClient.UploadFile(fileName, fPath, "")
  1100. if err != nil {
  1101. br.Msg = "文件上传失败"
  1102. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1103. return
  1104. }
  1105. defer func() {
  1106. os.Remove(fPath)
  1107. }()
  1108. item := new(models.Resource)
  1109. item.ResourceUrl = resourceUrl
  1110. item.ResourceType = 2
  1111. item.CreateTime = time.Now()
  1112. newId, err := models.AddResource(item)
  1113. if err != nil {
  1114. br.Msg = "资源上传失败"
  1115. br.ErrMsg = "资源上传失败,Err:" + err.Error()
  1116. return
  1117. }
  1118. //var playSeconds float64
  1119. //playSeconds, err = mp3duration.Calculate(fPath)
  1120. //if playSeconds <= 0 {
  1121. // playSeconds, err = utils.GetVideoPlaySeconds(fPath)
  1122. // if err != nil {
  1123. // br.Msg = "获取音频时间失败"
  1124. // br.ErrMsg = "获取音频时间失败,Err:" + err.Error()
  1125. // return
  1126. // }
  1127. //}
  1128. playSecondsStr, err := utils.GetDuration(fPath) //mp3duration.Calculate(fPath)
  1129. if err != nil {
  1130. utils.FileLog.Info("获取音频时间失败,Err:" + err.Error())
  1131. }
  1132. fileBody, err := os.ReadFile(fPath)
  1133. videoSize := len(fileBody)
  1134. sizeFloat := (float64(videoSize) / float64(1024)) / float64(1024)
  1135. sizeStr := utils.SubFloatToFloatStr(sizeFloat, 2)
  1136. {
  1137. reportChapterCreateTime, err := time.Parse(utils.FormatDateTime, reportChapterInfo.CreateTime)
  1138. if err != nil {
  1139. br.Msg = "上传失败"
  1140. br.ErrMsg = "上传失败,Err:" + err.Error()
  1141. return
  1142. }
  1143. createTimeStr := reportChapterCreateTime.Format("0102")
  1144. videoName := reportChapterInfo.Title + "(" + createTimeStr + ")"
  1145. reportChapterInfo.VideoUrl = resourceUrl
  1146. reportChapterInfo.VideoName = videoName
  1147. reportChapterInfo.VideoPlaySeconds = playSecondsStr //fmt.Sprint(playSeconds)
  1148. reportChapterInfo.VideoSize = sizeStr
  1149. reportChapterInfo.VideoKind = 1
  1150. reportChapterInfo.LastModifyAdminId = this.SysUser.AdminId
  1151. reportChapterInfo.LastModifyAdminName = this.SysUser.RealName
  1152. reportInfo.VoiceGenerateType = 1
  1153. reportChapterInfo.ModifyTime = time.Now()
  1154. err = reportChapterInfo.UpdateChapter([]string{"VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "VideoKind", "LastModifyAdminId", "LastModifyAdminName", "VoiceGenerateType", "ModifyTime"})
  1155. if err != nil {
  1156. br.Msg = "上传失败"
  1157. br.ErrMsg = "修改报告章节的音频信息失败,Err:" + err.Error()
  1158. return
  1159. }
  1160. // 修改报告的最近更新人信息
  1161. reportInfo.LastModifyAdminId = this.SysUser.AdminId
  1162. reportInfo.LastModifyAdminName = this.SysUser.RealName
  1163. reportInfo.ModifyTime = time.Now()
  1164. err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"})
  1165. if err != nil {
  1166. br.Msg = "上传失败"
  1167. br.ErrMsg = "修改报告最后更新人信息失败,Err:" + err.Error()
  1168. return
  1169. }
  1170. }
  1171. // 处理报告中的音频文件分贝
  1172. go services.HandleVideoDecibel(reportChapterInfo)
  1173. resp := new(models.ResourceResp)
  1174. resp.Id = newId
  1175. resp.ResourceUrl = resourceUrl
  1176. br.Msg = "上传成功"
  1177. br.Ret = 200
  1178. br.Success = true
  1179. br.Data = resp
  1180. return
  1181. }
  1182. // PublishDayWeekReportChapter
  1183. // @Title 发布章节
  1184. // @Description 发布章节
  1185. // @Param request body models.PublishReportChapterReq true "type json string"
  1186. // @Success 200 Ret=200 操作成功
  1187. // @router /publishDayWeekReportChapter [post]
  1188. func (this *ReportController) PublishDayWeekReportChapter() {
  1189. br := new(models.BaseResponse).Init()
  1190. defer func() {
  1191. this.Data["json"] = br
  1192. this.ServeJSON()
  1193. }()
  1194. sysUser := this.SysUser
  1195. if sysUser == nil {
  1196. br.Msg = "请登录"
  1197. br.ErrMsg = "请登录,SysUser Is Empty"
  1198. br.Ret = 408
  1199. return
  1200. }
  1201. var req models.PublishReportChapterReq
  1202. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1203. if err != nil {
  1204. br.Msg = "参数解析异常!"
  1205. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1206. return
  1207. }
  1208. if req.ReportChapterId <= 0 {
  1209. br.Msg = "参数有误"
  1210. return
  1211. }
  1212. // 获取报告详情
  1213. chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
  1214. if err != nil {
  1215. br.Msg = "章节信息有误"
  1216. br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
  1217. return
  1218. }
  1219. reportInfo, err := models.GetReportByReportId(chapterInfo.ReportId)
  1220. if err != nil {
  1221. br.Msg = "查询报告有误"
  1222. br.ErrMsg = "查询报告信息失败, Err: " + err.Error()
  1223. return
  1224. }
  1225. if reportInfo.State == 2 {
  1226. br.Msg = "该报告已发布,不允许编辑"
  1227. br.ErrMsg = "该报告已发布,不允许编辑"
  1228. br.IsSendEmail = false
  1229. return
  1230. }
  1231. // 图表刷新状态
  1232. refreshResult := data.CheckBatchChartRefreshResult("report", chapterInfo.ReportId, chapterInfo.ReportChapterId)
  1233. if !refreshResult {
  1234. br.Msg = "图表刷新未完成,请稍后操作"
  1235. br.ErrMsg = "图表刷新未完成,请稍后操作"
  1236. br.IsSendEmail = false
  1237. return
  1238. }
  1239. // 如果是系统章节,那么需要校验下是否已经停更
  1240. if chapterInfo.TypeId > 0 {
  1241. // 获取规则配置
  1242. reportChapterTypeRule, err := models.GetReportChapterTypeById(chapterInfo.TypeId)
  1243. if err != nil {
  1244. br.Msg = "获取配置信息异常"
  1245. br.ErrMsg = "获取配置信息异常, Err: " + err.Error()
  1246. return
  1247. }
  1248. if reportChapterTypeRule.Enabled == 0 {
  1249. br.Msg = "该章节已永久停更"
  1250. br.ErrMsg = "该章节已永久停更 "
  1251. br.IsSendEmail = false
  1252. return
  1253. }
  1254. }
  1255. var publishTime time.Time
  1256. if reportInfo.MsgIsSend == 1 && reportInfo.PublishTime.IsZero() { //如果报告曾经发布过,并且已经发送过模版消息,则章节的发布时间为报告的发布时间
  1257. publishTime = reportInfo.PublishTime
  1258. } else {
  1259. publishTime = time.Now()
  1260. }
  1261. // 更新报告的最后编辑人
  1262. reportInfo.LastModifyAdminId = sysUser.AdminId
  1263. reportInfo.LastModifyAdminName = sysUser.RealName
  1264. reportInfo.ModifyTime = time.Now()
  1265. err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"})
  1266. if err != nil {
  1267. br.Msg = "发布失败"
  1268. br.ErrMsg = "报告最后编辑人保存失败, Err: " + err.Error()
  1269. return
  1270. }
  1271. // 更新章节信息
  1272. chapterInfo.IsEdit = 1
  1273. chapterInfo.PublishState = 2
  1274. chapterInfo.PublishTime = publishTime
  1275. chapterInfo.LastModifyAdminId = this.SysUser.AdminId
  1276. chapterInfo.LastModifyAdminName = this.SysUser.RealName
  1277. chapterInfo.ModifyTime = time.Now()
  1278. updateCols := make([]string, 0)
  1279. updateCols = append(updateCols, "IsEdit", "PublishState", "PublishTime", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime")
  1280. err = chapterInfo.UpdateChapter(updateCols)
  1281. if err != nil {
  1282. br.Msg = "发布失败"
  1283. br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
  1284. return
  1285. }
  1286. // 修改报告的最近更新人信息
  1287. go func() {
  1288. reportInfo.LastModifyAdminId = this.SysUser.AdminId
  1289. reportInfo.LastModifyAdminName = this.SysUser.RealName
  1290. reportInfo.ModifyTime = time.Now()
  1291. err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"})
  1292. if err != nil {
  1293. br.Msg = "上传失败"
  1294. br.ErrMsg = "修改报告最后更新人信息失败,Err:" + err.Error()
  1295. return
  1296. }
  1297. }()
  1298. // 生成音频
  1299. go services.UpdateChaptersVideo([]int{chapterInfo.ReportChapterId})
  1300. // 更新章节ES
  1301. {
  1302. go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
  1303. }
  1304. // 同时发布报告
  1305. //if req.PublishReport == 1 {
  1306. // if _, e := services.PublishDayWeekReport(chapterInfo.ReportId); e != nil {
  1307. // br.Msg = "章节发布成功,报告发布失败,请手动发布报告"
  1308. // br.ErrMsg = "发布晨/周报失败, Err: " + e.Error()
  1309. // return
  1310. // }
  1311. //}
  1312. br.Ret = 200
  1313. br.Success = true
  1314. br.Msg = "操作成功"
  1315. }
  1316. // GetUnPublishReportChapterList
  1317. // @Title 获取报告中未发布的章节数
  1318. // @Description 获取报告中未发布的章节数
  1319. // @Param ReportId query int true "报告ID"
  1320. // @Success 200 Ret=200 获取成功
  1321. // @router /chapter/un_publish/list [get]
  1322. func (this *ReportController) GetUnPublishReportChapterList() {
  1323. br := new(models.BaseResponse).Init()
  1324. defer func() {
  1325. this.Data["json"] = br
  1326. this.ServeJSON()
  1327. }()
  1328. sysUser := this.SysUser
  1329. if sysUser == nil {
  1330. br.Msg = "请登录"
  1331. br.ErrMsg = "请登录,SysUser Is Empty"
  1332. br.Ret = 408
  1333. return
  1334. }
  1335. reportId, _ := this.GetInt("ReportId")
  1336. if reportId <= 0 {
  1337. br.Msg = "参数有误"
  1338. br.IsSendEmail = false
  1339. return
  1340. }
  1341. reportInfo, err := models.GetReportById(reportId)
  1342. if err != nil {
  1343. br.Msg = "报告有误"
  1344. br.ErrMsg = "报告有误, Err: " + err.Error()
  1345. return
  1346. }
  1347. if reportInfo.HasChapter == 0 {
  1348. br.Msg = "报告未包含章节"
  1349. br.IsSendEmail = false
  1350. return
  1351. }
  1352. // 获取未发布的章节列表
  1353. unPublishedList, err := models.GetUnPublishedChapterList(reportInfo.Id)
  1354. if err != nil {
  1355. br.Msg = "获取未发布的章节数失败"
  1356. br.ErrMsg = "获取未发布的章节数失败, Err: " + err.Error()
  1357. return
  1358. }
  1359. br.Ret = 200
  1360. br.Success = true
  1361. br.Msg = "获取成功"
  1362. br.Data = unPublishedList
  1363. }
  1364. // EditChapterTitle
  1365. // @Title 编辑章节标题
  1366. // @Description 编辑章节标题
  1367. // @Param request body models.EditReportChapterReq true "type json string"
  1368. // @Success 200 Ret=200 保存成功
  1369. // @router /chapter/title/edit [post]
  1370. func (this *ReportController) EditChapterTitle() {
  1371. br := new(models.BaseResponse).Init()
  1372. defer func() {
  1373. this.Data["json"] = br
  1374. this.ServeJSON()
  1375. }()
  1376. sysUser := this.SysUser
  1377. if sysUser == nil {
  1378. br.Msg = "请登录"
  1379. br.ErrMsg = "请登录,SysUser Is Empty"
  1380. br.Ret = 408
  1381. return
  1382. }
  1383. var req models.EditReportChapterReq
  1384. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1385. if err != nil {
  1386. br.Msg = "参数解析异常!"
  1387. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1388. return
  1389. }
  1390. reportChapterId := req.ReportChapterId
  1391. if reportChapterId <= 0 {
  1392. br.Msg = "报告章节ID有误"
  1393. return
  1394. }
  1395. req.Title = strings.TrimSpace(req.Title)
  1396. if req.Title == `` {
  1397. br.Msg = "章节名称不能为空"
  1398. return
  1399. }
  1400. // 获取章节详情
  1401. reportChapterInfo, err := models.GetReportChapterInfoById(reportChapterId)
  1402. if err != nil {
  1403. br.Msg = "报告章节信息有误"
  1404. br.ErrMsg = "报告章节信息有误, Err: " + err.Error()
  1405. return
  1406. }
  1407. // 判断名称是否重复
  1408. {
  1409. var condition string
  1410. var pars []interface{}
  1411. condition += " AND report_id = ? AND title=? AND report_chapter_id != ? "
  1412. pars = append(pars, reportChapterInfo.ReportId, req.Title, reportChapterId)
  1413. count, err := models.GetCountReportChapterByCondition(condition, pars)
  1414. if err != nil {
  1415. br.Msg = "新增失败"
  1416. br.ErrMsg = "判断章节名称是否存在失败,Err:" + err.Error()
  1417. return
  1418. }
  1419. if count > 0 {
  1420. br.Msg = "章节名称不允许重复"
  1421. br.ErrMsg = "章节名称不允许重复"
  1422. br.IsSendEmail = false
  1423. return
  1424. }
  1425. }
  1426. // 获取报告详情
  1427. reportInfo, err := models.GetReportByReportId(reportChapterInfo.ReportId)
  1428. if err != nil {
  1429. br.Msg = "报告信息有误"
  1430. br.ErrMsg = "报告信息有误, Err: " + err.Error()
  1431. return
  1432. }
  1433. // 操作权限校验
  1434. hasAuth, msg, errMsg, isSendEmail := checkOpPermission(sysUser, reportInfo, reportChapterInfo, true, this.Lang)
  1435. if !hasAuth {
  1436. br.Msg = msg
  1437. br.ErrMsg = errMsg
  1438. br.IsSendEmail = isSendEmail
  1439. return
  1440. }
  1441. if reportInfo.State == 2 {
  1442. br.Msg = "该报告已发布,不允许编辑"
  1443. br.ErrMsg = "该报告已发布,不允许编辑"
  1444. br.IsSendEmail = false
  1445. return
  1446. }
  1447. // 报告的最后编辑人
  1448. reportInfo.LastModifyAdminId = sysUser.AdminId
  1449. reportInfo.LastModifyAdminName = sysUser.RealName
  1450. reportInfo.ModifyTime = time.Now()
  1451. reportChapterInfo.Title = req.Title
  1452. reportChapterInfo.LastModifyAdminId = sysUser.AdminId
  1453. reportChapterInfo.LastModifyAdminName = sysUser.RealName
  1454. reportChapterInfo.ModifyTime = time.Now()
  1455. updateCols := make([]string, 0)
  1456. updateCols = append(updateCols, "Title", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime")
  1457. // 更新报告的最近编辑人信息
  1458. if err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}); err != nil {
  1459. br.Msg = "保存失败"
  1460. br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
  1461. return
  1462. }
  1463. // 更新章节
  1464. if err = reportChapterInfo.UpdateChapter(updateCols); err != nil {
  1465. br.Msg = "保存失败"
  1466. br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
  1467. return
  1468. }
  1469. // 标记更新中
  1470. {
  1471. markStatus, err := services.UpdateReportEditMark(reportChapterInfo.ReportId, reportChapterInfo.ReportChapterId, sysUser.AdminId, 1, sysUser.RealName, this.Lang)
  1472. if err != nil {
  1473. br.Msg = err.Error()
  1474. return
  1475. }
  1476. if markStatus.Status == 1 {
  1477. br.Msg = markStatus.Msg
  1478. return
  1479. }
  1480. }
  1481. br.Ret = 200
  1482. br.Success = true
  1483. br.Msg = "保存成功"
  1484. }
  1485. // CancelPublishReportChapter
  1486. // @Title 取消发布章节
  1487. // @Description 取消发布章节
  1488. // @Param request body models.PublishReportChapterReq true "type json string"
  1489. // @Success 200 Ret=200 操作成功
  1490. // @router /chapter/publish/cancel [post]
  1491. func (this *ReportController) CancelPublishReportChapter() {
  1492. br := new(models.BaseResponse).Init()
  1493. defer func() {
  1494. this.Data["json"] = br
  1495. this.ServeJSON()
  1496. }()
  1497. sysUser := this.SysUser
  1498. if sysUser == nil {
  1499. br.Msg = "请登录"
  1500. br.ErrMsg = "请登录,SysUser Is Empty"
  1501. br.Ret = 408
  1502. return
  1503. }
  1504. var req models.PublishReportChapterReq
  1505. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1506. if err != nil {
  1507. br.Msg = "参数解析异常!"
  1508. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1509. return
  1510. }
  1511. if req.ReportChapterId <= 0 {
  1512. br.Msg = "参数有误"
  1513. return
  1514. }
  1515. // 获取章节详情
  1516. chapterInfo, err := models.GetReportChapterInfoById(req.ReportChapterId)
  1517. if err != nil {
  1518. br.Msg = "章节信息有误"
  1519. br.ErrMsg = "获取章节信息失败, Err: " + err.Error()
  1520. return
  1521. }
  1522. // 章节发布状态校验
  1523. if chapterInfo.PublishState == 1 {
  1524. br.Msg = "该章节未发布,不能重复撤销"
  1525. br.ErrMsg = "该章节未发布,不能重复撤销"
  1526. br.IsSendEmail = false
  1527. return
  1528. }
  1529. // 获取报告详情
  1530. reportInfo, err := models.GetReportByReportId(chapterInfo.ReportId)
  1531. if err != nil {
  1532. br.Msg = "查询报告有误"
  1533. br.ErrMsg = "查询报告信息失败, Err: " + err.Error()
  1534. return
  1535. }
  1536. if reportInfo.State == 2 {
  1537. br.Msg = "该报告已发布,不允许撤销章节"
  1538. br.ErrMsg = "该报告已发布,不允许撤销章节"
  1539. br.IsSendEmail = false
  1540. return
  1541. }
  1542. // 更新章节信息
  1543. chapterInfo.PublishState = 1
  1544. chapterInfo.PublishTime = time.Time{}
  1545. chapterInfo.LastModifyAdminId = this.SysUser.AdminId
  1546. chapterInfo.LastModifyAdminName = this.SysUser.RealName
  1547. chapterInfo.ModifyTime = time.Now()
  1548. updateCols := make([]string, 0)
  1549. updateCols = append(updateCols, "PublishState", "PublishTime", "LastModifyAdminId", "LastModifyAdminName", "ModifyTime")
  1550. err = chapterInfo.UpdateChapter(updateCols)
  1551. if err != nil {
  1552. br.Msg = "发布失败"
  1553. br.ErrMsg = "报告章节内容保存失败, Err: " + err.Error()
  1554. return
  1555. }
  1556. // 更新章节ES
  1557. {
  1558. go services.UpdateReportChapterEs(chapterInfo.ReportChapterId)
  1559. }
  1560. br.Ret = 200
  1561. br.Success = true
  1562. br.Msg = "撤销成功"
  1563. }
  1564. // checkOpPermission
  1565. // @Description: 操作权限校验
  1566. // @author: Roc
  1567. // @datetime 2024-11-12 09:58:34
  1568. // @param sysUser *system.Admin
  1569. // @param reportInfo *models.Report
  1570. // @param reportChapterInfo *models.ReportChapter
  1571. // @param isMarkStatus bool
  1572. // @param lang string
  1573. // @return hasAuth bool
  1574. // @return msg string
  1575. // @return errMsg string
  1576. // @return isSendEmail bool
  1577. func checkOpPermission(sysUser *system.Admin, reportInfo *models.Report, reportChapterInfo *models.ReportChapter, isMarkStatus bool, lang string) (hasAuth bool, msg, errMsg string, isSendEmail bool) {
  1578. isSendEmail = true
  1579. // 权限校验
  1580. isAuth, err := services.CheckChapterAuthByReportChapterInfo(sysUser, reportInfo.AdminId, reportChapterInfo)
  1581. if err != nil {
  1582. msg = "获取报告权限失败"
  1583. errMsg = "获取报告权限失败,Err:" + err.Error()
  1584. return
  1585. }
  1586. if !isAuth {
  1587. msg = "没有权限"
  1588. errMsg = "没有权限"
  1589. isSendEmail = false
  1590. return
  1591. }
  1592. // 如果不是创建人,那么就要去查看是否授权
  1593. //if reportInfo.AdminId != sysUser.AdminId && !utils.IsAdminRole(sysUser.RoleTypeCode) {
  1594. // // 授权用户权限校验
  1595. // chapterGrantObj := report.ReportChapterGrant{}
  1596. // _, tmpErr := chapterGrantObj.GetGrantByIdAndAdmin(reportChapterInfo.ReportChapterId, sysUser.AdminId)
  1597. // if tmpErr != nil {
  1598. // if utils.IsErrNoRow(tmpErr) {
  1599. // msg = "没有权限"
  1600. // errMsg = "没有权限"
  1601. // isSendEmail = false
  1602. // return
  1603. // }
  1604. // msg = "获取章节id授权用户失败"
  1605. // errMsg = "获取章节id授权用户失败, Err: " + tmpErr.Error()
  1606. // return
  1607. // }
  1608. //}
  1609. // 标记更新中
  1610. if isMarkStatus {
  1611. markStatus, err := services.UpdateReportEditMark(reportChapterInfo.ReportId, reportChapterInfo.ReportChapterId, sysUser.AdminId, 1, sysUser.RealName, lang)
  1612. if err != nil {
  1613. msg = err.Error()
  1614. errMsg = err.Error()
  1615. return
  1616. }
  1617. if markStatus.Status == 1 {
  1618. msg = markStatus.Msg
  1619. errMsg = markStatus.Msg
  1620. isSendEmail = false
  1621. return
  1622. }
  1623. }
  1624. // 有权限
  1625. hasAuth = true
  1626. return
  1627. }