ppt_v2.go 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/models"
  5. "eta_gn/eta_api/models/company"
  6. "eta_gn/eta_api/services"
  7. "eta_gn/eta_api/services/ppt"
  8. "eta_gn/eta_api/utils"
  9. "fmt"
  10. _ "image/gif"
  11. _ "image/jpeg"
  12. _ "image/png"
  13. "os"
  14. "path"
  15. "strconv"
  16. "strings"
  17. "time"
  18. "github.com/rdlucklib/rdluck_tools/paging"
  19. )
  20. // PptV2Controller 新版ppt模块
  21. type PptV2Controller struct {
  22. BaseAuthController
  23. }
  24. // PptV2CommonController 新版ppt公共模块
  25. type PptV2CommonController struct {
  26. BaseCommonController
  27. }
  28. // ListPpt
  29. // @Title 获取ppt列表
  30. // @Description 获取ppt列表接口
  31. // @Param PageSize query int true "每页数据条数"
  32. // @Param CurrentIndex query int true "当前页页码,从1开始"
  33. // @Param KeyWord query string true "搜索关键词"
  34. // @Success 200 {object} models.PptV2ListResp
  35. // @router /list [get]
  36. func (this *PptV2Controller) ListPpt() {
  37. br := new(models.BaseResponse).Init()
  38. defer func() {
  39. this.Data["json"] = br
  40. this.ServeJSON()
  41. }()
  42. sysUser := this.SysUser
  43. if sysUser == nil {
  44. br.Msg = "请登录"
  45. br.ErrMsg = "请登录,SysUser Is Empty"
  46. return
  47. }
  48. pageSize, _ := this.GetInt("PageSize")
  49. currentIndex, _ := this.GetInt("CurrentIndex")
  50. keyWord := this.GetString("KeyWord")
  51. var startSize int
  52. if pageSize <= 0 {
  53. pageSize = utils.PageSize20
  54. }
  55. if currentIndex <= 0 {
  56. currentIndex = 1
  57. }
  58. startSize = utils.StartIndex(currentIndex, pageSize)
  59. var condition string
  60. var pars []interface{}
  61. if keyWord != "" {
  62. condition += ` AND (title LIKE ? OR admin_real_name LIKE ? ) `
  63. pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
  64. }
  65. total, err := models.GetPptV2ListCount(condition, pars)
  66. if err != nil {
  67. br.Msg = "获取失败"
  68. br.ErrMsg = "获取失败,Err:" + err.Error()
  69. return
  70. }
  71. list, err := models.GetPptV2List(condition, pars, startSize, pageSize)
  72. if err != nil {
  73. br.Msg = "获取失败"
  74. br.ErrMsg = "获取失败,Err:" + err.Error()
  75. return
  76. }
  77. lenList := len(list)
  78. for i := 0; i < lenList; i++ {
  79. adminId := list[i].AdminId
  80. if adminId == sysUser.AdminId || sysUser.Role == "admin" {
  81. list[i].IsAuth = true
  82. } else {
  83. list[i].IsAuth = false
  84. }
  85. }
  86. page := paging.GetPaging(currentIndex, pageSize, total)
  87. resp := new(models.PptV2ListResp)
  88. resp.Paging = page
  89. resp.List = list
  90. br.Ret = 200
  91. br.Success = true
  92. br.Msg = "获取成功"
  93. br.Data = resp
  94. }
  95. // AddPpt
  96. // @Title 新增ppt
  97. // @Description 新增ppt接口
  98. // @Param request body models.AddPptV2Req true "type json string"
  99. // @Success 200 Ret=200 新增成功
  100. // @router /add [post]
  101. func (this *PptV2Controller) AddPpt() {
  102. br := new(models.BaseResponse).Init()
  103. defer func() {
  104. this.Data["json"] = br
  105. this.ServeJSON()
  106. }()
  107. var req models.AddPptV2Req
  108. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  109. if err != nil {
  110. br.Msg = "参数解析异常!"
  111. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  112. return
  113. }
  114. if req.FirstPage.Title == "" {
  115. br.Msg = "标题不能为空"
  116. return
  117. }
  118. var newId int64
  119. var msg string
  120. if req.PptId <= 0 {
  121. if req.GroupId == 0 {
  122. br.Msg = "请输入目录ID"
  123. return
  124. }
  125. //item, err := models.GetPptV2ByTitleAndId(req.FirstPage.Title, this.SysUser.AdminId)
  126. //if err != nil && !utils.IsErrNoRow(err) {
  127. // br.Msg = "获取数据异常!"
  128. // br.ErrMsg = "获取数据异常,Err:" + err.Error()
  129. // return
  130. //}
  131. //if item != nil && item.PptId > 0 && item.PptId != int(req.PptId) {
  132. // br.Msg = "标题已存在,不可重复添加"
  133. // br.IsSendEmail = false
  134. // return
  135. //}
  136. pptInfo := &models.PptV2{
  137. //PptId: 0,
  138. TemplateType: req.FirstPage.TemplateType,
  139. BackgroundImg: req.FirstPage.ImgUrl,
  140. Title: req.FirstPage.Title,
  141. ReportType: req.FirstPage.ReportType,
  142. PptDate: req.FirstPage.PptDate,
  143. Content: req.Content,
  144. CoverContent: req.CoverContent,
  145. CreateTime: time.Now(),
  146. ModifyTime: time.Now(),
  147. AdminId: this.SysUser.AdminId,
  148. AdminRealName: this.SysUser.RealName,
  149. PptVersion: 2,
  150. TitleSetting: req.TitleSetting,
  151. }
  152. newId, err = models.AddPptV2(pptInfo)
  153. if err != nil {
  154. br.Msg = "新增失败"
  155. br.ErrMsg = "新增失败,Err:" + err.Error()
  156. return
  157. }
  158. //新增ppt和目录映射
  159. _, err = ppt.AddGroupPptMapping(newId, req.GroupId, this.SysUser.AdminId, this.SysUser.RealName)
  160. if err != nil {
  161. br.Msg = err.Error()
  162. return
  163. }
  164. msg = "新增成功"
  165. } else {
  166. newId = req.PptId
  167. pptInfo, err := models.GetPptV2ById(int(req.PptId))
  168. if err != nil {
  169. br.Msg = "信息获取失败"
  170. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  171. return
  172. }
  173. pptInfo.TemplateType = req.FirstPage.TemplateType
  174. pptInfo.BackgroundImg = req.FirstPage.ImgUrl
  175. pptInfo.Title = req.FirstPage.Title
  176. pptInfo.ReportType = req.FirstPage.ReportType
  177. pptInfo.PptDate = req.FirstPage.PptDate
  178. pptInfo.Content = req.Content
  179. pptInfo.CoverContent = req.CoverContent
  180. pptInfo.ModifyTime = time.Now()
  181. pptInfo.TitleSetting = req.TitleSetting
  182. err = pptInfo.Update([]string{"TemplateType", "BackgroundImg", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "CoverContent", "TitleSetting"})
  183. msg = "保存成功"
  184. }
  185. resp := models.AddPptResp{
  186. PptId: newId,
  187. }
  188. br.Ret = 200
  189. br.Success = true
  190. br.Msg = msg
  191. br.Data = resp
  192. }
  193. // EditPpt
  194. // @Title 编辑ppt
  195. // @Description 编辑ppt接口
  196. // @Param request body models.AddPptV2Req true "type json string"
  197. // @Success 200 Ret=200 编辑成功
  198. // @router /edit [post]
  199. func (this *PptV2Controller) EditPpt() {
  200. br := new(models.BaseResponse).Init()
  201. defer func() {
  202. this.Data["json"] = br
  203. this.ServeJSON()
  204. }()
  205. var req models.AddPptV2Req
  206. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  207. if err != nil {
  208. br.Msg = "参数解析异常!"
  209. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  210. return
  211. }
  212. if req.FirstPage.Title == "" {
  213. br.Msg = "标题不能为空"
  214. return
  215. }
  216. pptInfo, err := models.GetPptV2ById(int(req.PptId))
  217. if err != nil {
  218. br.Msg = "信息获取失败"
  219. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  220. return
  221. }
  222. // 协作人权限
  223. if pptInfo.AdminId != this.SysUser.AdminId {
  224. if pptInfo.CollaborateType != utils.ReportWriteTypeGroup {
  225. br.Msg = "非协作人无权操作"
  226. return
  227. }
  228. if pptInfo.CollaborateUsers == "" {
  229. br.Msg = "非协作人无权操作"
  230. return
  231. }
  232. partnerArr := strings.Split(pptInfo.CollaborateUsers, ",")
  233. if !utils.InArrayByStr(partnerArr, fmt.Sprint(this.SysUser.AdminId)) {
  234. br.Msg = "非协作人无权操作"
  235. return
  236. }
  237. }
  238. // 修改
  239. pptInfo.TemplateType = req.FirstPage.TemplateType
  240. pptInfo.BackgroundImg = req.FirstPage.ImgUrl
  241. pptInfo.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
  242. pptInfo.BackCoverImg = req.FirstPage.BackCoverImg
  243. pptInfo.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
  244. pptInfo.BackCoverImgId = req.FirstPage.BackCoverImgId
  245. pptInfo.BackgroundImgId = req.FirstPage.BackgroundImgId
  246. pptInfo.Title = req.FirstPage.Title
  247. pptInfo.ReportType = req.FirstPage.ReportType
  248. pptInfo.PptDate = req.FirstPage.PptDate
  249. pptInfo.Content = req.Content
  250. pptInfo.CoverContent = req.CoverContent
  251. pptInfo.ModifyTime = time.Now()
  252. pptInfo.TitleSetting = req.TitleSetting
  253. err = pptInfo.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "CurrentBackgroundImgId", "BackCoverImgId", "BackgroundImgId", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "CoverContent", "TitleSetting"})
  254. if err != nil {
  255. br.Msg = "编辑失败"
  256. br.ErrMsg = "编辑失败,Err:" + err.Error()
  257. return
  258. }
  259. //pptMap, err := models.GetPptMappingByPptId(req.PptId)
  260. //if err != nil {
  261. // br.Msg = `该PPT信息不存在, 保存失败`
  262. // br.ErrMsg = `该PPT信息不存在, 保存失败, Err` + err.Error()
  263. // br.IsSendEmail = false
  264. // return
  265. //}
  266. //pptMapList, err := models.GetPptMappingListByGroupId(pptMap.GroupId)
  267. //if err != nil {
  268. // br.ErrMsg = "PPT目录信息异常"
  269. // return
  270. //}
  271. //count, err := models.GetPptMappingByGroupPptCountId(pptMap.GroupPptId, this.SysUser.AdminId)
  272. //if err != nil {
  273. // br.Msg = "查询映射关系失败"
  274. // br.ErrMsg = "查询映射关系失败, 保存失败, Err:" + err.Error()
  275. // return
  276. //}
  277. //if !pptMap.IsMoved && len(pptMapList) > 1 && count > 0 {
  278. // // 如果没有人为移动位置, 默认将当前ppt置顶
  279. // err = ppt.MoveGroupPpt(pptMap.GroupId, pptMap.GroupPptId, pptMapList[0].GroupPptId, 0, this.SysUser.AdminId)
  280. // if err != nil {
  281. // br.Msg = err.Error()
  282. // br.ErrMsg = "移动失败,Err:" + err.Error()
  283. // return
  284. // }
  285. //}
  286. // 版本记录
  287. historyInfo := &models.PptV2History{
  288. PptId: pptInfo.PptId,
  289. TemplateType: pptInfo.TemplateType,
  290. BackgroundImg: pptInfo.BackgroundImg,
  291. Title: pptInfo.Title,
  292. ReportType: pptInfo.ReportType,
  293. PptDate: pptInfo.PptDate,
  294. Content: pptInfo.Content,
  295. CoverContent: pptInfo.CoverContent,
  296. AdminId: this.SysUser.AdminId,
  297. AdminRealName: this.SysUser.RealName,
  298. CreateTime: time.Now(),
  299. TitleSetting: pptInfo.TitleSetting,
  300. }
  301. err = historyInfo.Add()
  302. if err != nil {
  303. br.Msg = "保存失败"
  304. br.ErrMsg = "保存PPT版本失败, Err: " + err.Error()
  305. return
  306. }
  307. // 日志记录
  308. {
  309. logInfo := &models.PptV2SaveLog{
  310. PptId: pptInfo.PptId,
  311. TemplateType: pptInfo.TemplateType,
  312. BackgroundImg: pptInfo.BackgroundImg,
  313. CurrentBackgroundImg: pptInfo.CurrentBackgroundImg,
  314. BackCoverImg: pptInfo.BackCoverImg,
  315. Title: pptInfo.Title,
  316. ReportType: pptInfo.ReportType,
  317. PptDate: pptInfo.PptDate,
  318. Content: pptInfo.Content,
  319. CoverContent: pptInfo.CoverContent,
  320. AdminId: this.SysUser.AdminId,
  321. AdminRealName: this.SysUser.RealName,
  322. CreateTime: time.Now(),
  323. }
  324. _, err = models.AddPptV2SaveLog(logInfo)
  325. }
  326. resp := models.AddPptResp{
  327. PptId: req.PptId,
  328. }
  329. br.Ret = 200
  330. br.Success = true
  331. br.Msg = "编辑成功"
  332. br.IsAddLog = true
  333. br.Data = resp
  334. }
  335. // DeletePpt
  336. // @Title 删除ppt
  337. // @Description 删除ppt接口
  338. // @Param request body models.DeletePptV2Req true "type json string"
  339. // @Success 200 Ret=200 删除成功
  340. // @router /delete [post]
  341. func (this *PptV2Controller) DeletePpt() {
  342. br := new(models.BaseResponse).Init()
  343. defer func() {
  344. this.Data["json"] = br
  345. this.ServeJSON()
  346. }()
  347. var req models.DeletePptV2Req
  348. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  349. if err != nil {
  350. br.Msg = "参数解析异常!"
  351. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  352. return
  353. }
  354. if req.PptId <= 0 {
  355. br.Msg = "参数错误"
  356. return
  357. }
  358. pptInfo, err := models.GetPptV2ById(req.PptId)
  359. if err != nil {
  360. br.Msg = "ppt不存在"
  361. return
  362. }
  363. if pptInfo.AdminId != this.SysUser.AdminId {
  364. br.Msg = "无权删除"
  365. return
  366. }
  367. if pptInfo.ReportSource != utils.ReportSourceLocal {
  368. br.Msg = "仅允许删除系统内部报告"
  369. return
  370. }
  371. err = models.DeletePptV2(req.PptId)
  372. if err != nil {
  373. br.Msg = "删除失败"
  374. br.ErrMsg = "删除失败,Err:" + err.Error()
  375. return
  376. }
  377. //如果该ppt存在单个共享记录,则删除共享
  378. err = ppt.DeleteGroupPpt(req.PptId)
  379. if err != nil {
  380. br.Msg = "删除失败"
  381. br.ErrMsg = "删除失败,Err:" + err.Error()
  382. return
  383. }
  384. // 更新报告计数
  385. go func() {
  386. _ = services.UpdateClassifyReportNum(pptInfo.ClassifyId)
  387. }()
  388. br.Ret = 200
  389. br.Success = true
  390. br.IsAddLog = true
  391. br.Msg = "删除成功"
  392. }
  393. // DetailPpt
  394. // @Title 获取ppt详情
  395. // @Description 获取ppt详情接口
  396. // @Param PptId query int true "PptId"
  397. // @Success 200 {object} models.PptV2
  398. // @router /detail [get]
  399. func (this *PptV2Controller) DetailPpt() {
  400. br := new(models.BaseResponse).Init()
  401. defer func() {
  402. if br.ErrMsg == "" {
  403. br.IsSendEmail = false
  404. }
  405. this.Data["json"] = br
  406. this.ServeJSON()
  407. }()
  408. sysUser := this.SysUser
  409. if sysUser == nil {
  410. br.Msg = "请登录"
  411. br.ErrMsg = "请登录,SysUser Is Empty"
  412. br.Ret = 408
  413. return
  414. }
  415. pptId, _ := this.GetInt("PptId")
  416. pptInfo, err := models.GetPptV2ById(pptId)
  417. if err != nil {
  418. br.Msg = "信息获取失败"
  419. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  420. return
  421. }
  422. // 权限
  423. var hasAuth bool
  424. if pptInfo.AdminId == sysUser.AdminId {
  425. hasAuth = true
  426. }
  427. if hasAuth == false && pptInfo.CollaborateUsers != "" {
  428. authorArr := strings.Split(pptInfo.CollaborateUsers, ",")
  429. strId := strconv.Itoa(sysUser.AdminId)
  430. if utils.InArrayByStr(authorArr, strId) {
  431. hasAuth = true
  432. }
  433. }
  434. // 维护封底 背景图
  435. if pptInfo.CurrentBackgroundImg == "" {
  436. var condition string
  437. var pars []interface{}
  438. condition += ` conf_type=? `
  439. pars = append(pars, 1)
  440. condition += ` AND image_type=? `
  441. pars = append(pars, 2)
  442. condition += ` ORDER BY create_time asc `
  443. imageConfList, err := models.GetImageConfByCondition(condition, pars)
  444. if err == nil && len(imageConfList) > 0 {
  445. pptInfo.CurrentBackgroundImg = imageConfList[0].Url
  446. pptInfo.CurrentBackgroundImgId = imageConfList[0].ImageConfId
  447. }
  448. }
  449. if pptInfo.BackCoverImg == "" {
  450. var condition string
  451. var pars []interface{}
  452. condition += ` conf_type=? `
  453. pars = append(pars, 1)
  454. condition += ` AND image_type=? `
  455. pars = append(pars, 3)
  456. condition += ` ORDER BY create_time asc `
  457. imageConfList, err := models.GetImageConfByCondition(condition, pars)
  458. if err == nil && len(imageConfList) > 0 {
  459. pptInfo.BackCoverImg = imageConfList[0].Url
  460. pptInfo.BackCoverImgId = imageConfList[0].ImageConfId
  461. }
  462. }
  463. // 编辑中
  464. editor, e := services.UpdatePptEditing(pptId, 0, sysUser.AdminId, sysUser.RealName, false)
  465. if e != nil {
  466. br.Msg = "操作失败"
  467. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  468. return
  469. }
  470. resp := new(models.PPTDetailResp)
  471. resp.PptV2 = pptInfo
  472. resp.Editor = editor
  473. resp.HasAuth = hasAuth
  474. br.Ret = 200
  475. br.Success = true
  476. br.Msg = "获取成功"
  477. br.Data = resp
  478. }
  479. // DownloadPptx
  480. // @Title ppt下载
  481. // @Description ppt下载
  482. // @Param PptId query int true "PptId"
  483. // @Success 200 下载成功
  484. // @router /downloadpptx [get]
  485. func (this *PptV2CommonController) DownloadPptx() {
  486. br := new(models.BaseResponse).Init()
  487. defer func() {
  488. this.Data["json"] = br
  489. this.ServeJSON()
  490. }()
  491. pptId, err := this.GetInt("PptId")
  492. if err != nil {
  493. br.Msg = "参数错误"
  494. br.ErrMsg = "获取,pptId,Err:" + err.Error()
  495. return
  496. }
  497. pptInfo, err := models.GetPptV2ById(pptId)
  498. if err != nil {
  499. br.Msg = "获取信息失败"
  500. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  501. return
  502. }
  503. filePath := pptInfo.PptxUrl
  504. fileName := pptInfo.Title + ".pptx"
  505. this.Ctx.Output.Download(filePath, fileName)
  506. br.Success = true
  507. br.Ret = 200
  508. br.Msg = "下载成功"
  509. return
  510. }
  511. // Publish
  512. // @Title 发布接口
  513. // @Description 发布接口
  514. // @Param request body models.SavePptV2PathReq true "type json string"
  515. // @Success Ret=200 发布成功
  516. // @router /publish [post]
  517. func (this *PptV2Controller) Publish() {
  518. br := new(models.BaseResponse).Init()
  519. defer func() {
  520. if br.ErrMsg == "" {
  521. br.IsSendEmail = false
  522. }
  523. this.Data["json"] = br
  524. this.ServeJSON()
  525. }()
  526. var req models.SavePptV2PathReq
  527. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  528. if err != nil {
  529. br.Msg = "参数解析异常!"
  530. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  531. return
  532. }
  533. pptId := req.PptId
  534. if pptId <= 0 {
  535. br.Msg = "参数错误"
  536. return
  537. }
  538. req.PptxUrl = strings.TrimSpace(req.PptxUrl)
  539. if req.PptxUrl == "" {
  540. br.Msg = "文件地址为空"
  541. return
  542. }
  543. //err = models.EditPptV2Path(pptId, req.PptxUrl)
  544. //if err != nil {
  545. // br.Msg = "发布失败"
  546. // br.ErrMsg = "发布失败,Err:" + err.Error()
  547. // return
  548. //}
  549. pptItem, e := models.GetPptV2ById(pptId)
  550. if e != nil {
  551. if utils.IsErrNoRow(e) {
  552. br.Msg = "PPT不存在, 请刷新页面"
  553. return
  554. }
  555. br.Msg = "操作失败"
  556. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  557. return
  558. }
  559. stateOrigin := pptItem.State
  560. var updateCols []string
  561. updateCols = append(updateCols, "PptxUrl", "ModifyTime")
  562. pptItem.PptxUrl = req.PptxUrl
  563. pptItem.ModifyTime = time.Now()
  564. // 本地PPT(不加限制, 想发布就发布)
  565. if pptItem.ReportSource == utils.ReportSourceLocal {
  566. updateCols = append(updateCols, "State", "PublishTime")
  567. pptItem.State = models.ReportStatePublished
  568. pptItem.PublishTime = time.Now()
  569. }
  570. // 外部PPT
  571. if pptItem.ReportSource == utils.ReportSourceOuter {
  572. // 报告状态
  573. if pptItem.OutReportId == "" {
  574. br.Msg = "PPT异常"
  575. br.ErrMsg = fmt.Sprintf("PPT外部报告ID为空, ID: %d", pptId)
  576. return
  577. }
  578. if pptItem.State != models.ReportStateWaitSubmit && pptItem.State != models.ReportStateRefused {
  579. br.Msg = "状态异常, 不允许提交"
  580. br.ErrMsg = fmt.Sprintf("PPT报告状态异常, %d", pptItem.State)
  581. return
  582. }
  583. updateCols = append(updateCols, "SubmitTime", "State")
  584. pptItem.SubmitTime = time.Now()
  585. pptItem.State = models.ReportStateWaitApprove
  586. }
  587. // 更新PPT
  588. if e = pptItem.Update(updateCols); e != nil {
  589. br.Msg = "操作失败"
  590. br.ErrMsg = fmt.Sprintf("更新PPT失败, %v", e)
  591. return
  592. }
  593. //添加发布记录
  594. {
  595. record := new(models.PptV2PublishRecord)
  596. record.CreateTime = time.Now()
  597. record.PptId = pptId
  598. record.PptUrl = req.PptxUrl
  599. go models.AddPptV2PublishRecord(record)
  600. }
  601. // 回调智力共享审批
  602. go func() {
  603. if pptItem.ReportSource != utils.ReportSourceOuter {
  604. return
  605. }
  606. outId, _ := strconv.Atoi(pptItem.OutReportId)
  607. // 若回调失败, 则恢复提交前状态(先这么处理吧,允许再次提交)
  608. e = services.OuterReportCallBack(outId, pptItem.Title, req.PptxUrl, ".pptx")
  609. if e != nil {
  610. pptItem.State = stateOrigin
  611. _ = pptItem.Update([]string{"State"})
  612. }
  613. }()
  614. br.Ret = 200
  615. br.Success = true
  616. br.Msg = "发布成功"
  617. br.IsAddLog = true
  618. return
  619. }
  620. // PptUpload
  621. // @Title ppt上传
  622. // @Description ppt上传
  623. // @Param PptId query int true "PptId"
  624. // @Success 200 新增成功
  625. // @router /pptUpload [post]
  626. func (this *PptV2Controller) PptUpload() {
  627. br := new(models.BaseResponse).Init()
  628. defer func() {
  629. this.Data["json"] = br
  630. this.ServeJSON()
  631. }()
  632. pptId, _ := this.GetInt("PptId", 0)
  633. if pptId <= 0 {
  634. br.Msg = "参数错误"
  635. return
  636. }
  637. _, err := models.GetPptV2ById(pptId)
  638. if err != nil {
  639. br.Msg = "获取数据失败"
  640. br.ErrMsg = "获取PPT详情失败,Err:" + err.Error()
  641. return
  642. }
  643. f, h, err := this.GetFile("file")
  644. if err != nil {
  645. br.Msg = "获取资源信息失败"
  646. br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
  647. return
  648. }
  649. defer func() {
  650. _ = f.Close()
  651. }()
  652. uploadFileName := h.Filename //上传的文件名
  653. ext := path.Ext(h.Filename)
  654. dateDir := time.Now().Format("20060102")
  655. uploadDir := utils.STATIC_DIR + "ppt/" + dateDir
  656. err = os.MkdirAll(uploadDir, utils.DIR_MOD)
  657. if err != nil {
  658. br.Msg = "存储目录创建失败"
  659. br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
  660. return
  661. }
  662. randStr := utils.GetRandStringNoSpecialChar(28)
  663. fileName := randStr + ext
  664. fpath := uploadDir + "/" + fileName
  665. if err = this.SaveToFile("file", fpath); err != nil {
  666. br.Msg = "文件上传失败"
  667. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  668. return
  669. }
  670. defer func() {
  671. _ = os.Remove(fpath)
  672. }()
  673. hzUploadDir := utils.RESOURCE_DIR + "ppt/"
  674. savePptxToOssPath := hzUploadDir + time.Now().Format("200601/20060102/")
  675. //pptName := strings.Replace(pptItem.Title, "\n", "", -1)
  676. //pptName = strings.TrimSuffix(pptName, " ")
  677. pptName := utils.GetRandStringNoSpecialChar(28)
  678. savePptxToOssPath += pptName + ".pptx"
  679. //上传到阿里云 和 minio
  680. pptxUrl := ``
  681. ossClient := services.NewOssClient()
  682. if ossClient == nil {
  683. br.Msg = "上传失败"
  684. br.ErrMsg = "初始化OSS服务失败"
  685. return
  686. }
  687. pptxUrl, err = ossClient.UploadFile(fileName, fpath, savePptxToOssPath)
  688. if err != nil {
  689. br.Msg = "文件上传失败"
  690. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  691. return
  692. }
  693. resp := models.ResourceResp{
  694. ResourceUrl: pptxUrl,
  695. ResourceName: uploadFileName,
  696. }
  697. br.Msg = "上传成功"
  698. br.Ret = 200
  699. br.Success = true
  700. br.Data = resp
  701. return
  702. }
  703. // SaveLog
  704. // @Title 定时ppt操作日志记录
  705. // @Description 定时ppt操作日志记录
  706. // @Param request body models.AddPptV2Req true "type json string"
  707. // @Success 200 新增成功
  708. // @router /saveLog [post]
  709. func (this *PptV2Controller) SaveLog() {
  710. br := new(models.BaseResponse).Init()
  711. defer func() {
  712. if br.ErrMsg == "" {
  713. br.IsSendEmail = false
  714. }
  715. this.Data["json"] = br
  716. this.ServeJSON()
  717. }()
  718. sysUser := this.SysUser
  719. if sysUser == nil {
  720. br.Msg = "请登录"
  721. br.ErrMsg = "请登录,SysUser Is Empty"
  722. br.Ret = 408
  723. return
  724. }
  725. var req models.AddPptV2Req
  726. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  727. if err != nil {
  728. br.Msg = "参数解析异常!"
  729. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  730. return
  731. }
  732. if req.FirstPage.Title == "" {
  733. br.Msg = "标题不能为空"
  734. return
  735. }
  736. var pptContent []services.PPTContent
  737. err = json.Unmarshal([]byte(req.Content), &pptContent)
  738. if err != nil {
  739. br.Msg = "参数解析异常!"
  740. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  741. return
  742. }
  743. // 获取ppt
  744. //item, err := models.GetPptV2ByTitleAndId(req.FirstPage.Title, this.SysUser.AdminId)
  745. //if err != nil && !utils.IsErrNoRow(err) {
  746. // br.Msg = "获取数据异常!"
  747. // br.ErrMsg = "获取数据异常,Err:" + err.Error()
  748. // return
  749. //}
  750. //if item != nil && item.PptId > 0 && item.PptId != int(req.PptId) {
  751. // br.Msg = "标题已存在,不可重复添加"
  752. // br.IsSendEmail = false
  753. // return
  754. //}
  755. //变更ppt内容
  756. pptItem, e := models.GetPptV2ById(int(req.PptId))
  757. if e != nil {
  758. if utils.IsErrNoRow(e) {
  759. br.Msg = "PPT已被删除, 请刷新页面"
  760. return
  761. }
  762. br.Msg = "信息获取失败"
  763. br.ErrMsg = "信息获取失败,Err:" + e.Error()
  764. return
  765. }
  766. // 标记编辑状态
  767. if pptItem.PptId > 0 {
  768. _, e = services.UpdatePptEditing(pptItem.PptId, 1, sysUser.AdminId, sysUser.RealName, false)
  769. if e != nil {
  770. br.Msg = "操作失败"
  771. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  772. return
  773. }
  774. }
  775. pptItem.TemplateType = req.FirstPage.TemplateType
  776. pptItem.BackgroundImg = req.FirstPage.ImgUrl
  777. pptItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
  778. pptItem.BackCoverImg = req.FirstPage.BackCoverImg
  779. pptItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
  780. pptItem.BackCoverImgId = req.FirstPage.BackCoverImgId
  781. pptItem.BackgroundImgId = req.FirstPage.BackgroundImgId
  782. pptItem.Title = req.FirstPage.Title
  783. pptItem.ReportType = req.FirstPage.ReportType
  784. pptItem.PptDate = req.FirstPage.PptDate
  785. pptItem.Content = req.Content
  786. pptItem.ModifyTime = time.Now()
  787. pptItem.TitleSetting = req.TitleSetting
  788. pptItem.PptPage = len(pptContent)
  789. err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "CurrentBackgroundImgId", "BackCoverImgId", "BackgroundImgId", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "TitleSetting", "ppt_page"})
  790. if err != nil {
  791. br.Msg = "自动保存失败"
  792. br.ErrMsg = fmt.Sprintf("自动保存PPT失败, ID: %d, Err: %v", pptItem.PptId, err)
  793. return
  794. }
  795. // 将更新后的PPT, 置顶
  796. //pptMap, err := models.GetPptMappingByPptId(int64(req.PptId))
  797. //if err != nil {
  798. // br.Msg = `该PPT信息不存在, 保存失败`
  799. // br.ErrMsg = `该PPT信息不存在, 保存失败, Err` + err.Error()
  800. // br.IsSendEmail = false
  801. // return
  802. //}
  803. //pptMapList, err := models.GetPptMappingListByGroupId(pptMap.GroupId)
  804. //if err != nil {
  805. // br.ErrMsg = "PPT目录信息异常"
  806. // return
  807. //}
  808. //count, err := models.GetPptMappingByGroupPptCountId(pptMap.GroupPptId, this.SysUser.AdminId)
  809. //if err != nil {
  810. // br.Msg = "查询映射关系失败"
  811. // br.ErrMsg = "查询映射关系失败, 保存失败, Err:" + err.Error()
  812. // return
  813. //}
  814. //if !pptMap.IsMoved && len(pptMapList) > 1 && count > 0 {
  815. // // 如果没有人为移动位置, 且当前用户有权限, 默认将当前ppt置顶
  816. // err = ppt.MoveGroupPpt(pptMap.GroupId, pptMap.GroupPptId, pptMapList[0].GroupPptId, 0, this.SysUser.AdminId)
  817. // if err != nil {
  818. // br.Msg = err.Error()
  819. // br.ErrMsg = "移动失败,Err:" + err.Error()
  820. // return
  821. // }
  822. //}
  823. //日志记录
  824. logInfo := &models.PptV2SaveLog{
  825. PptId: int(req.PptId),
  826. TemplateType: req.FirstPage.TemplateType,
  827. BackgroundImg: req.FirstPage.ImgUrl,
  828. CurrentBackgroundImg: req.FirstPage.CurrentBackgroundImg,
  829. BackCoverImg: req.FirstPage.BackCoverImg,
  830. Title: req.FirstPage.Title,
  831. ReportType: req.FirstPage.ReportType,
  832. PptDate: req.FirstPage.PptDate,
  833. Content: req.Content,
  834. CoverContent: req.CoverContent,
  835. AdminId: this.SysUser.AdminId,
  836. AdminRealName: this.SysUser.RealName,
  837. CreateTime: time.Now(),
  838. TitleSetting: req.TitleSetting,
  839. }
  840. _, e = models.AddPptV2SaveLog(logInfo)
  841. if e != nil {
  842. br.Msg = "保存失败"
  843. br.ErrMsg = "保存PPT日志失败, Err: " + e.Error()
  844. return
  845. }
  846. br.Ret = 200
  847. br.Success = true
  848. br.Msg = "保存成功"
  849. }
  850. // GetConfig
  851. // @Title 获取ppt配置
  852. // @Description 获取ppt列表接口
  853. // @Param PageSize query int true "每页数据条数"
  854. // @Param CurrentIndex query int true "当前页页码,从1开始"
  855. // @Param KeyWord query string true "搜索关键词"
  856. // @Success 200 {object} models.PptV2ListResp
  857. // @router /config [get]
  858. func (this *PptV2Controller) GetConfig() {
  859. br := new(models.BaseResponse).Init()
  860. defer func() {
  861. this.Data["json"] = br
  862. this.ServeJSON()
  863. }()
  864. crmConfig, err := company.GetConfigDetailByCode("ppt_limit")
  865. if err != nil {
  866. br.Msg = "获取配置失败"
  867. br.ErrMsg = "获取配置失败"
  868. br.IsSendEmail = false
  869. return
  870. }
  871. resp := new(models.PptV2ConfigResp)
  872. err = json.Unmarshal([]byte(crmConfig.ConfigValue), resp)
  873. if err != nil {
  874. br.Msg = "获取配置失败"
  875. br.ErrMsg = "获取配置失败;err:" + err.Error()
  876. br.IsSendEmail = false
  877. return
  878. }
  879. br.Ret = 200
  880. br.Success = true
  881. br.Msg = "获取成功"
  882. br.Data = resp
  883. }
  884. // ToReport
  885. // @Title PPT转报告
  886. // @Description PPT转报告
  887. // @Param request body models.PPT2ReportReq true "type json string"
  888. // @Success 200 Ret=200 转换成功
  889. // @router /to_report [post]
  890. func (this *PptV2Controller) ToReport() {
  891. br := new(models.BaseResponse).Init()
  892. defer func() {
  893. this.Data["json"] = br
  894. this.ServeJSON()
  895. }()
  896. sysUser := this.SysUser
  897. if sysUser == nil {
  898. br.Msg = "请登录"
  899. br.ErrMsg = "请登录,SysUser Is Empty"
  900. br.Ret = 408
  901. return
  902. }
  903. var req models.PPT2ReportReq
  904. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  905. if err != nil {
  906. br.Msg = "参数解析异常!"
  907. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  908. return
  909. }
  910. if req.PptId == 0 {
  911. br.Msg = "参数有误"
  912. return
  913. }
  914. reportId, reportCode, msg, e := services.SavePPTReport(req.PptId, req.ClassifyId, req.Title, sysUser)
  915. if e != nil {
  916. br.Msg = msg
  917. br.ErrMsg = "PPT转报告失败, Err: " + e.Error()
  918. return
  919. }
  920. resp := &models.PPT2ReportResp{
  921. ReportId: reportId,
  922. ReportCode: reportCode,
  923. }
  924. br.Ret = 200
  925. br.Success = true
  926. br.Msg = "转换成功"
  927. br.IsAddLog = true
  928. br.Data = resp
  929. }
  930. // Grant
  931. // @Title 分配ppt权限
  932. // @Description 分配ppt权限接口
  933. // @Param request body models.GrantPptReq true "type json string"
  934. // @Success 200 Ret=200 分配成功
  935. // @router /grant [post]
  936. func (this *PptV2Controller) Grant() {
  937. br := new(models.BaseResponse).Init()
  938. defer func() {
  939. this.Data["json"] = br
  940. this.ServeJSON()
  941. }()
  942. var req models.GrantPptReq
  943. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  944. if err != nil {
  945. br.Msg = "参数解析异常!"
  946. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  947. return
  948. }
  949. if req.PptId <= 0 {
  950. br.Msg = "参数错误"
  951. return
  952. }
  953. // 查找ppt信息
  954. pptInfo, err := models.GetPptV2ById(req.PptId)
  955. if err != nil {
  956. br.Msg = "ppt不存在"
  957. return
  958. }
  959. if pptInfo.AdminId != this.SysUser.AdminId {
  960. br.Msg = "无权配置"
  961. return
  962. }
  963. // 分配
  964. err, errMsg := ppt.GrantPpt(req.PptId, req.GrantType, req.AdminIdStr, this.SysUser.AdminId)
  965. if errMsg != `` {
  966. br.Msg = errMsg
  967. br.ErrMsg = errMsg
  968. if err != nil {
  969. br.ErrMsg = errMsg + ";Err:" + err.Error()
  970. } else {
  971. br.IsSendEmail = false
  972. }
  973. return
  974. }
  975. br.Ret = 200
  976. br.Success = true
  977. br.IsAddLog = true
  978. br.Msg = "分配成功"
  979. }
  980. // CancelGrant
  981. // @Title 取消分配ppt权限
  982. // @Description 取消分配ppt权限
  983. // @Param request body models.DeletePptV2Req true "type json string"
  984. // @Success 200 Ret=200 分配成功
  985. // @router /grant/cancel [post]
  986. func (this *PptV2Controller) CancelGrant() {
  987. br := new(models.BaseResponse).Init()
  988. defer func() {
  989. this.Data["json"] = br
  990. this.ServeJSON()
  991. }()
  992. var req models.DeletePptV2Req
  993. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  994. if err != nil {
  995. br.Msg = "参数解析异常!"
  996. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  997. return
  998. }
  999. if req.PptId <= 0 {
  1000. br.Msg = "参数错误"
  1001. return
  1002. }
  1003. // 查找ppt信息
  1004. pptInfo, err := models.GetPptV2ById(req.PptId)
  1005. if err != nil {
  1006. br.Msg = "ppt不存在"
  1007. return
  1008. }
  1009. if pptInfo.AdminId != this.SysUser.AdminId {
  1010. br.Msg = "无权取消配置"
  1011. return
  1012. }
  1013. // 分配
  1014. err, errMsg := ppt.DeleteGrantPpt(req.PptId)
  1015. if errMsg != `` {
  1016. br.Msg = errMsg
  1017. br.ErrMsg = errMsg
  1018. if err != nil {
  1019. br.ErrMsg = errMsg + ";Err:" + err.Error()
  1020. } else {
  1021. br.IsSendEmail = false
  1022. }
  1023. return
  1024. }
  1025. br.Ret = 200
  1026. br.Success = true
  1027. br.IsAddLog = true
  1028. br.Msg = "取消成功"
  1029. }
  1030. // GrantInfo
  1031. // @Title 获取分配ppt权限详情
  1032. // @Description 获取分配ppt权限详情接口
  1033. // @Param PptId query int true "ppt的id"
  1034. // @Success 200 {object} models.GrantInfoResp
  1035. // @router /grant/info [get]
  1036. func (this *PptV2Controller) GrantInfo() {
  1037. br := new(models.BaseResponse).Init()
  1038. defer func() {
  1039. this.Data["json"] = br
  1040. this.ServeJSON()
  1041. }()
  1042. pptId, _ := this.GetInt("PptId")
  1043. if pptId <= 0 {
  1044. br.Msg = "参数错误"
  1045. return
  1046. }
  1047. // 查找ppt信息
  1048. pptInfo, err := models.GetPptV2ById(pptId)
  1049. if err != nil {
  1050. br.Msg = "ppt不存在"
  1051. return
  1052. }
  1053. if pptInfo.AdminId != this.SysUser.AdminId {
  1054. br.Msg = "无权配置"
  1055. return
  1056. }
  1057. pptGrantInfoList, err := models.GetPPtGrantInfo(pptId)
  1058. if err != nil {
  1059. br.Msg = "信息获取失败"
  1060. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  1061. return
  1062. }
  1063. if len(pptGrantInfoList) <= 0 {
  1064. br.Msg = "未配置"
  1065. br.IsSendEmail = false
  1066. return
  1067. }
  1068. grantType := 0
  1069. var adminIdStr string
  1070. if pptGrantInfoList[0].DepartmentId > 0 { //分配类型;1:全部ficc研究员;2:指定成员
  1071. grantType = 1
  1072. } else {
  1073. grantType = 2
  1074. adminIdsList := make([]string, 0)
  1075. for _, v := range pptGrantInfoList {
  1076. adminIdsList = append(adminIdsList, strconv.Itoa(int(v.GrantAdminId)))
  1077. }
  1078. adminIdStr = strings.Join(adminIdsList, ",")
  1079. }
  1080. br.Ret = 200
  1081. br.Success = true
  1082. br.Data = models.GrantInfoResp{
  1083. PptId: pptId,
  1084. GrantType: grantType,
  1085. AdminIdStr: adminIdStr,
  1086. }
  1087. br.Msg = "分配成功"
  1088. }
  1089. // TitleCheck
  1090. // @Title 校验标题是否重复
  1091. // @Description 校验标题是否重复接口
  1092. // @Param Title query int true "标题"
  1093. // @Success 200 Ret=200 编辑成功
  1094. // @router /titleCheck [get]
  1095. func (this *PptV2Controller) TitleCheck() {
  1096. br := new(models.BaseResponse).Init()
  1097. defer func() {
  1098. this.Data["json"] = br
  1099. this.ServeJSON()
  1100. }()
  1101. title := this.GetString("Title")
  1102. pptId, _ := this.GetInt("PptId")
  1103. if title == "" {
  1104. br.Msg = "标题不能为空"
  1105. return
  1106. }
  1107. item, err := models.GetPptV2ByTitleAndId(title, this.SysUser.AdminId)
  1108. if err != nil && !utils.IsErrNoRow(err) {
  1109. br.Msg = "获取数据异常!"
  1110. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  1111. return
  1112. }
  1113. if item != nil && item.PptId > 0 && item.PptId != pptId {
  1114. br.Msg = "标题已存在,不可重复添加"
  1115. br.IsSendEmail = false
  1116. return
  1117. }
  1118. br.Ret = 200
  1119. br.Success = true
  1120. br.Msg = "校验成功"
  1121. }
  1122. // Editing
  1123. // @Title 标记/查询编辑状态
  1124. // @Description 标记/查询编辑状态
  1125. // @Param request body models.PPTEditingReq true "type json string"
  1126. // @Success 200 Ret=200 操作成功
  1127. // @router /editing [post]
  1128. func (this *PptV2Controller) Editing() {
  1129. br := new(models.BaseResponse).Init()
  1130. defer func() {
  1131. if br.ErrMsg == "" {
  1132. br.IsSendEmail = false
  1133. }
  1134. this.Data["json"] = br
  1135. this.ServeJSON()
  1136. }()
  1137. sysUser := this.SysUser
  1138. if sysUser == nil {
  1139. br.Msg = "请登录"
  1140. br.ErrMsg = "请登录,SysUser Is Empty"
  1141. br.Ret = 408
  1142. return
  1143. }
  1144. var req models.PPTEditingReq
  1145. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1146. if err != nil {
  1147. br.Msg = "参数解析异常!"
  1148. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1149. return
  1150. }
  1151. if req.PptId <= 0 {
  1152. br.Msg = "参数有误"
  1153. return
  1154. }
  1155. if req.Status < 0 {
  1156. br.Msg = "标记状态异常"
  1157. return
  1158. }
  1159. editor, e := services.UpdatePptEditing(req.PptId, req.Status, sysUser.AdminId, sysUser.RealName, false)
  1160. if e != nil {
  1161. br.Msg = "操作失败"
  1162. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  1163. return
  1164. }
  1165. br.Data = editor
  1166. br.Ret = 200
  1167. br.Success = true
  1168. br.Msg = "操作成功"
  1169. }