ppt_v2.go 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  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. var condition string
  435. var pars []interface{}
  436. // 维护封底 背景图
  437. if pptInfo.CurrentBackgroundImg != "" {
  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. } else if pptInfo.BackCoverImg != "" {
  449. condition += ` conf_type=? `
  450. pars = append(pars, 1)
  451. condition += ` AND image_type=? `
  452. pars = append(pars, 3)
  453. condition += ` ORDER BY create_time asc `
  454. imageConfList, err := models.GetImageConfByCondition(condition, pars)
  455. if err == nil && len(imageConfList) > 0 {
  456. pptInfo.BackCoverImg = imageConfList[0].Url
  457. pptInfo.BackCoverImgId = imageConfList[0].ImageConfId
  458. }
  459. }
  460. // 编辑中
  461. editor, e := services.UpdatePptEditing(pptId, 0, sysUser.AdminId, sysUser.RealName, false)
  462. if e != nil {
  463. br.Msg = "操作失败"
  464. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  465. return
  466. }
  467. resp := new(models.PPTDetailResp)
  468. resp.PptV2 = pptInfo
  469. resp.Editor = editor
  470. resp.HasAuth = hasAuth
  471. br.Ret = 200
  472. br.Success = true
  473. br.Msg = "获取成功"
  474. br.Data = resp
  475. }
  476. // DownloadPptx
  477. // @Title ppt下载
  478. // @Description ppt下载
  479. // @Param PptId query int true "PptId"
  480. // @Success 200 下载成功
  481. // @router /downloadpptx [get]
  482. func (this *PptV2CommonController) DownloadPptx() {
  483. br := new(models.BaseResponse).Init()
  484. defer func() {
  485. this.Data["json"] = br
  486. this.ServeJSON()
  487. }()
  488. pptId, err := this.GetInt("PptId")
  489. if err != nil {
  490. br.Msg = "参数错误"
  491. br.ErrMsg = "获取,pptId,Err:" + err.Error()
  492. return
  493. }
  494. pptInfo, err := models.GetPptV2ById(pptId)
  495. if err != nil {
  496. br.Msg = "获取信息失败"
  497. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  498. return
  499. }
  500. filePath := pptInfo.PptxUrl
  501. fileName := pptInfo.Title + ".pptx"
  502. this.Ctx.Output.Download(filePath, fileName)
  503. br.Success = true
  504. br.Ret = 200
  505. br.Msg = "下载成功"
  506. return
  507. }
  508. // Publish
  509. // @Title 发布接口
  510. // @Description 发布接口
  511. // @Param request body models.SavePptV2PathReq true "type json string"
  512. // @Success Ret=200 发布成功
  513. // @router /publish [post]
  514. func (this *PptV2Controller) Publish() {
  515. br := new(models.BaseResponse).Init()
  516. defer func() {
  517. if br.ErrMsg == "" {
  518. br.IsSendEmail = false
  519. }
  520. this.Data["json"] = br
  521. this.ServeJSON()
  522. }()
  523. var req models.SavePptV2PathReq
  524. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  525. if err != nil {
  526. br.Msg = "参数解析异常!"
  527. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  528. return
  529. }
  530. pptId := req.PptId
  531. if pptId <= 0 {
  532. br.Msg = "参数错误"
  533. return
  534. }
  535. req.PptxUrl = strings.TrimSpace(req.PptxUrl)
  536. if req.PptxUrl == "" {
  537. br.Msg = "文件地址为空"
  538. return
  539. }
  540. //err = models.EditPptV2Path(pptId, req.PptxUrl)
  541. //if err != nil {
  542. // br.Msg = "发布失败"
  543. // br.ErrMsg = "发布失败,Err:" + err.Error()
  544. // return
  545. //}
  546. pptItem, e := models.GetPptV2ById(pptId)
  547. if e != nil {
  548. if utils.IsErrNoRow(e) {
  549. br.Msg = "PPT不存在, 请刷新页面"
  550. return
  551. }
  552. br.Msg = "操作失败"
  553. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  554. return
  555. }
  556. stateOrigin := pptItem.State
  557. var updateCols []string
  558. updateCols = append(updateCols, "PptxUrl", "ModifyTime")
  559. pptItem.PptxUrl = req.PptxUrl
  560. pptItem.ModifyTime = time.Now()
  561. // 本地PPT(不加限制, 想发布就发布)
  562. if pptItem.ReportSource == utils.ReportSourceLocal {
  563. updateCols = append(updateCols, "State", "PublishTime")
  564. pptItem.State = models.ReportStatePublished
  565. pptItem.PublishTime = time.Now()
  566. }
  567. // 外部PPT
  568. if pptItem.ReportSource == utils.ReportSourceOuter {
  569. // 报告状态
  570. if pptItem.OutReportId == "" {
  571. br.Msg = "PPT异常"
  572. br.ErrMsg = fmt.Sprintf("PPT外部报告ID为空, ID: %d", pptId)
  573. return
  574. }
  575. if pptItem.State != models.ReportStateWaitSubmit && pptItem.State != models.ReportStateRefused {
  576. br.Msg = "状态异常, 不允许提交"
  577. br.ErrMsg = fmt.Sprintf("PPT报告状态异常, %d", pptItem.State)
  578. return
  579. }
  580. updateCols = append(updateCols, "SubmitTime", "State")
  581. pptItem.SubmitTime = time.Now()
  582. pptItem.State = models.ReportStateWaitApprove
  583. }
  584. // 更新PPT
  585. if e = pptItem.Update(updateCols); e != nil {
  586. br.Msg = "操作失败"
  587. br.ErrMsg = fmt.Sprintf("更新PPT失败, %v", e)
  588. return
  589. }
  590. //添加发布记录
  591. {
  592. record := new(models.PptV2PublishRecord)
  593. record.CreateTime = time.Now()
  594. record.PptId = pptId
  595. record.PptUrl = req.PptxUrl
  596. go models.AddPptV2PublishRecord(record)
  597. }
  598. // 回调智力共享审批
  599. go func() {
  600. if pptItem.ReportSource != utils.ReportSourceOuter {
  601. return
  602. }
  603. outId, _ := strconv.Atoi(pptItem.OutReportId)
  604. // 若回调失败, 则恢复提交前状态(先这么处理吧,允许再次提交)
  605. e = services.OuterReportCallBack(outId, pptItem.Title, req.PptxUrl, ".pptx")
  606. if e != nil {
  607. pptItem.State = stateOrigin
  608. _ = pptItem.Update([]string{"State"})
  609. }
  610. }()
  611. br.Ret = 200
  612. br.Success = true
  613. br.Msg = "发布成功"
  614. br.IsAddLog = true
  615. return
  616. }
  617. // PptUpload
  618. // @Title ppt上传
  619. // @Description ppt上传
  620. // @Param PptId query int true "PptId"
  621. // @Success 200 新增成功
  622. // @router /pptUpload [post]
  623. func (this *PptV2Controller) PptUpload() {
  624. br := new(models.BaseResponse).Init()
  625. defer func() {
  626. this.Data["json"] = br
  627. this.ServeJSON()
  628. }()
  629. pptId, _ := this.GetInt("PptId", 0)
  630. if pptId <= 0 {
  631. br.Msg = "参数错误"
  632. return
  633. }
  634. _, err := models.GetPptV2ById(pptId)
  635. if err != nil {
  636. br.Msg = "获取数据失败"
  637. br.ErrMsg = "获取PPT详情失败,Err:" + err.Error()
  638. return
  639. }
  640. f, h, err := this.GetFile("file")
  641. if err != nil {
  642. br.Msg = "获取资源信息失败"
  643. br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
  644. return
  645. }
  646. defer func() {
  647. _ = f.Close()
  648. }()
  649. uploadFileName := h.Filename //上传的文件名
  650. ext := path.Ext(h.Filename)
  651. dateDir := time.Now().Format("20060102")
  652. uploadDir := utils.STATIC_DIR + "ppt/" + dateDir
  653. err = os.MkdirAll(uploadDir, utils.DIR_MOD)
  654. if err != nil {
  655. br.Msg = "存储目录创建失败"
  656. br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
  657. return
  658. }
  659. randStr := utils.GetRandStringNoSpecialChar(28)
  660. fileName := randStr + ext
  661. fpath := uploadDir + "/" + fileName
  662. if err = this.SaveToFile("file", fpath); err != nil {
  663. br.Msg = "文件上传失败"
  664. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  665. return
  666. }
  667. defer func() {
  668. _ = os.Remove(fpath)
  669. }()
  670. hzUploadDir := utils.RESOURCE_DIR + "ppt/"
  671. savePptxToOssPath := hzUploadDir + time.Now().Format("200601/20060102/")
  672. //pptName := strings.Replace(pptItem.Title, "\n", "", -1)
  673. //pptName = strings.TrimSuffix(pptName, " ")
  674. pptName := utils.GetRandStringNoSpecialChar(28)
  675. savePptxToOssPath += pptName + ".pptx"
  676. //上传到阿里云 和 minio
  677. pptxUrl := ``
  678. ossClient := services.NewOssClient()
  679. if ossClient == nil {
  680. br.Msg = "上传失败"
  681. br.ErrMsg = "初始化OSS服务失败"
  682. return
  683. }
  684. pptxUrl, err = ossClient.UploadFile(fileName, fpath, savePptxToOssPath)
  685. if err != nil {
  686. br.Msg = "文件上传失败"
  687. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  688. return
  689. }
  690. resp := models.ResourceResp{
  691. ResourceUrl: pptxUrl,
  692. ResourceName: uploadFileName,
  693. }
  694. br.Msg = "上传成功"
  695. br.Ret = 200
  696. br.Success = true
  697. br.Data = resp
  698. return
  699. }
  700. // SaveLog
  701. // @Title 定时ppt操作日志记录
  702. // @Description 定时ppt操作日志记录
  703. // @Param request body models.AddPptV2Req true "type json string"
  704. // @Success 200 新增成功
  705. // @router /saveLog [post]
  706. func (this *PptV2Controller) SaveLog() {
  707. br := new(models.BaseResponse).Init()
  708. defer func() {
  709. if br.ErrMsg == "" {
  710. br.IsSendEmail = false
  711. }
  712. this.Data["json"] = br
  713. this.ServeJSON()
  714. }()
  715. sysUser := this.SysUser
  716. if sysUser == nil {
  717. br.Msg = "请登录"
  718. br.ErrMsg = "请登录,SysUser Is Empty"
  719. br.Ret = 408
  720. return
  721. }
  722. var req models.AddPptV2Req
  723. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  724. if err != nil {
  725. br.Msg = "参数解析异常!"
  726. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  727. return
  728. }
  729. if req.FirstPage.Title == "" {
  730. br.Msg = "标题不能为空"
  731. return
  732. }
  733. var pptContent []services.PPTContent
  734. err = json.Unmarshal([]byte(req.Content), &pptContent)
  735. if err != nil {
  736. br.Msg = "参数解析异常!"
  737. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  738. return
  739. }
  740. // 获取ppt
  741. //item, err := models.GetPptV2ByTitleAndId(req.FirstPage.Title, this.SysUser.AdminId)
  742. //if err != nil && !utils.IsErrNoRow(err) {
  743. // br.Msg = "获取数据异常!"
  744. // br.ErrMsg = "获取数据异常,Err:" + err.Error()
  745. // return
  746. //}
  747. //if item != nil && item.PptId > 0 && item.PptId != int(req.PptId) {
  748. // br.Msg = "标题已存在,不可重复添加"
  749. // br.IsSendEmail = false
  750. // return
  751. //}
  752. //变更ppt内容
  753. pptItem, e := models.GetPptV2ById(int(req.PptId))
  754. if e != nil {
  755. if utils.IsErrNoRow(e) {
  756. br.Msg = "PPT已被删除, 请刷新页面"
  757. return
  758. }
  759. br.Msg = "信息获取失败"
  760. br.ErrMsg = "信息获取失败,Err:" + e.Error()
  761. return
  762. }
  763. // 标记编辑状态
  764. if pptItem.PptId > 0 {
  765. _, e = services.UpdatePptEditing(pptItem.PptId, 1, sysUser.AdminId, sysUser.RealName, false)
  766. if e != nil {
  767. br.Msg = "操作失败"
  768. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  769. return
  770. }
  771. }
  772. pptItem.TemplateType = req.FirstPage.TemplateType
  773. pptItem.BackgroundImg = req.FirstPage.ImgUrl
  774. pptItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
  775. pptItem.BackCoverImg = req.FirstPage.BackCoverImg
  776. pptItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
  777. pptItem.BackCoverImgId = req.FirstPage.BackCoverImgId
  778. pptItem.BackgroundImgId = req.FirstPage.BackgroundImgId
  779. pptItem.Title = req.FirstPage.Title
  780. pptItem.ReportType = req.FirstPage.ReportType
  781. pptItem.PptDate = req.FirstPage.PptDate
  782. pptItem.Content = req.Content
  783. pptItem.ModifyTime = time.Now()
  784. pptItem.TitleSetting = req.TitleSetting
  785. pptItem.PptPage = len(pptContent)
  786. err = pptItem.Update([]string{"TemplateType", "BackgroundImg", "CurrentBackgroundImg", "BackCoverImg", "CurrentBackgroundImgId", "BackCoverImgId", "BackgroundImgId", "Title", "ReportType", "PptDate", "Content", "ModifyTime", "TitleSetting", "ppt_page"})
  787. if err != nil {
  788. br.Msg = "自动保存失败"
  789. br.ErrMsg = fmt.Sprintf("自动保存PPT失败, ID: %d, Err: %v", pptItem.PptId, err)
  790. return
  791. }
  792. // 将更新后的PPT, 置顶
  793. //pptMap, err := models.GetPptMappingByPptId(int64(req.PptId))
  794. //if err != nil {
  795. // br.Msg = `该PPT信息不存在, 保存失败`
  796. // br.ErrMsg = `该PPT信息不存在, 保存失败, Err` + err.Error()
  797. // br.IsSendEmail = false
  798. // return
  799. //}
  800. //pptMapList, err := models.GetPptMappingListByGroupId(pptMap.GroupId)
  801. //if err != nil {
  802. // br.ErrMsg = "PPT目录信息异常"
  803. // return
  804. //}
  805. //count, err := models.GetPptMappingByGroupPptCountId(pptMap.GroupPptId, this.SysUser.AdminId)
  806. //if err != nil {
  807. // br.Msg = "查询映射关系失败"
  808. // br.ErrMsg = "查询映射关系失败, 保存失败, Err:" + err.Error()
  809. // return
  810. //}
  811. //if !pptMap.IsMoved && len(pptMapList) > 1 && count > 0 {
  812. // // 如果没有人为移动位置, 且当前用户有权限, 默认将当前ppt置顶
  813. // err = ppt.MoveGroupPpt(pptMap.GroupId, pptMap.GroupPptId, pptMapList[0].GroupPptId, 0, this.SysUser.AdminId)
  814. // if err != nil {
  815. // br.Msg = err.Error()
  816. // br.ErrMsg = "移动失败,Err:" + err.Error()
  817. // return
  818. // }
  819. //}
  820. //日志记录
  821. logInfo := &models.PptV2SaveLog{
  822. PptId: int(req.PptId),
  823. TemplateType: req.FirstPage.TemplateType,
  824. BackgroundImg: req.FirstPage.ImgUrl,
  825. CurrentBackgroundImg: req.FirstPage.CurrentBackgroundImg,
  826. BackCoverImg: req.FirstPage.BackCoverImg,
  827. Title: req.FirstPage.Title,
  828. ReportType: req.FirstPage.ReportType,
  829. PptDate: req.FirstPage.PptDate,
  830. Content: req.Content,
  831. CoverContent: req.CoverContent,
  832. AdminId: this.SysUser.AdminId,
  833. AdminRealName: this.SysUser.RealName,
  834. CreateTime: time.Now(),
  835. TitleSetting: req.TitleSetting,
  836. }
  837. _, e = models.AddPptV2SaveLog(logInfo)
  838. if e != nil {
  839. br.Msg = "保存失败"
  840. br.ErrMsg = "保存PPT日志失败, Err: " + e.Error()
  841. return
  842. }
  843. br.Ret = 200
  844. br.Success = true
  845. br.Msg = "保存成功"
  846. }
  847. // GetConfig
  848. // @Title 获取ppt配置
  849. // @Description 获取ppt列表接口
  850. // @Param PageSize query int true "每页数据条数"
  851. // @Param CurrentIndex query int true "当前页页码,从1开始"
  852. // @Param KeyWord query string true "搜索关键词"
  853. // @Success 200 {object} models.PptV2ListResp
  854. // @router /config [get]
  855. func (this *PptV2Controller) GetConfig() {
  856. br := new(models.BaseResponse).Init()
  857. defer func() {
  858. this.Data["json"] = br
  859. this.ServeJSON()
  860. }()
  861. crmConfig, err := company.GetConfigDetailByCode("ppt_limit")
  862. if err != nil {
  863. br.Msg = "获取配置失败"
  864. br.ErrMsg = "获取配置失败"
  865. br.IsSendEmail = false
  866. return
  867. }
  868. resp := new(models.PptV2ConfigResp)
  869. err = json.Unmarshal([]byte(crmConfig.ConfigValue), resp)
  870. if err != nil {
  871. br.Msg = "获取配置失败"
  872. br.ErrMsg = "获取配置失败;err:" + err.Error()
  873. br.IsSendEmail = false
  874. return
  875. }
  876. br.Ret = 200
  877. br.Success = true
  878. br.Msg = "获取成功"
  879. br.Data = resp
  880. }
  881. // ToReport
  882. // @Title PPT转报告
  883. // @Description PPT转报告
  884. // @Param request body models.PPT2ReportReq true "type json string"
  885. // @Success 200 Ret=200 转换成功
  886. // @router /to_report [post]
  887. func (this *PptV2Controller) ToReport() {
  888. br := new(models.BaseResponse).Init()
  889. defer func() {
  890. this.Data["json"] = br
  891. this.ServeJSON()
  892. }()
  893. sysUser := this.SysUser
  894. if sysUser == nil {
  895. br.Msg = "请登录"
  896. br.ErrMsg = "请登录,SysUser Is Empty"
  897. br.Ret = 408
  898. return
  899. }
  900. var req models.PPT2ReportReq
  901. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  902. if err != nil {
  903. br.Msg = "参数解析异常!"
  904. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  905. return
  906. }
  907. if req.PptId == 0 {
  908. br.Msg = "参数有误"
  909. return
  910. }
  911. reportId, reportCode, msg, e := services.SavePPTReport(req.PptId, req.ClassifyId, req.Title, sysUser)
  912. if e != nil {
  913. br.Msg = msg
  914. br.ErrMsg = "PPT转报告失败, Err: " + e.Error()
  915. return
  916. }
  917. resp := &models.PPT2ReportResp{
  918. ReportId: reportId,
  919. ReportCode: reportCode,
  920. }
  921. br.Ret = 200
  922. br.Success = true
  923. br.Msg = "转换成功"
  924. br.IsAddLog = true
  925. br.Data = resp
  926. }
  927. // Grant
  928. // @Title 分配ppt权限
  929. // @Description 分配ppt权限接口
  930. // @Param request body models.GrantPptReq true "type json string"
  931. // @Success 200 Ret=200 分配成功
  932. // @router /grant [post]
  933. func (this *PptV2Controller) Grant() {
  934. br := new(models.BaseResponse).Init()
  935. defer func() {
  936. this.Data["json"] = br
  937. this.ServeJSON()
  938. }()
  939. var req models.GrantPptReq
  940. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  941. if err != nil {
  942. br.Msg = "参数解析异常!"
  943. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  944. return
  945. }
  946. if req.PptId <= 0 {
  947. br.Msg = "参数错误"
  948. return
  949. }
  950. // 查找ppt信息
  951. pptInfo, err := models.GetPptV2ById(req.PptId)
  952. if err != nil {
  953. br.Msg = "ppt不存在"
  954. return
  955. }
  956. if pptInfo.AdminId != this.SysUser.AdminId {
  957. br.Msg = "无权配置"
  958. return
  959. }
  960. // 分配
  961. err, errMsg := ppt.GrantPpt(req.PptId, req.GrantType, req.AdminIdStr, this.SysUser.AdminId)
  962. if errMsg != `` {
  963. br.Msg = errMsg
  964. br.ErrMsg = errMsg
  965. if err != nil {
  966. br.ErrMsg = errMsg + ";Err:" + err.Error()
  967. } else {
  968. br.IsSendEmail = false
  969. }
  970. return
  971. }
  972. br.Ret = 200
  973. br.Success = true
  974. br.IsAddLog = true
  975. br.Msg = "分配成功"
  976. }
  977. // CancelGrant
  978. // @Title 取消分配ppt权限
  979. // @Description 取消分配ppt权限
  980. // @Param request body models.DeletePptV2Req true "type json string"
  981. // @Success 200 Ret=200 分配成功
  982. // @router /grant/cancel [post]
  983. func (this *PptV2Controller) CancelGrant() {
  984. br := new(models.BaseResponse).Init()
  985. defer func() {
  986. this.Data["json"] = br
  987. this.ServeJSON()
  988. }()
  989. var req models.DeletePptV2Req
  990. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  991. if err != nil {
  992. br.Msg = "参数解析异常!"
  993. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  994. return
  995. }
  996. if req.PptId <= 0 {
  997. br.Msg = "参数错误"
  998. return
  999. }
  1000. // 查找ppt信息
  1001. pptInfo, err := models.GetPptV2ById(req.PptId)
  1002. if err != nil {
  1003. br.Msg = "ppt不存在"
  1004. return
  1005. }
  1006. if pptInfo.AdminId != this.SysUser.AdminId {
  1007. br.Msg = "无权取消配置"
  1008. return
  1009. }
  1010. // 分配
  1011. err, errMsg := ppt.DeleteGrantPpt(req.PptId)
  1012. if errMsg != `` {
  1013. br.Msg = errMsg
  1014. br.ErrMsg = errMsg
  1015. if err != nil {
  1016. br.ErrMsg = errMsg + ";Err:" + err.Error()
  1017. } else {
  1018. br.IsSendEmail = false
  1019. }
  1020. return
  1021. }
  1022. br.Ret = 200
  1023. br.Success = true
  1024. br.IsAddLog = true
  1025. br.Msg = "取消成功"
  1026. }
  1027. // GrantInfo
  1028. // @Title 获取分配ppt权限详情
  1029. // @Description 获取分配ppt权限详情接口
  1030. // @Param PptId query int true "ppt的id"
  1031. // @Success 200 {object} models.GrantInfoResp
  1032. // @router /grant/info [get]
  1033. func (this *PptV2Controller) GrantInfo() {
  1034. br := new(models.BaseResponse).Init()
  1035. defer func() {
  1036. this.Data["json"] = br
  1037. this.ServeJSON()
  1038. }()
  1039. pptId, _ := this.GetInt("PptId")
  1040. if pptId <= 0 {
  1041. br.Msg = "参数错误"
  1042. return
  1043. }
  1044. // 查找ppt信息
  1045. pptInfo, err := models.GetPptV2ById(pptId)
  1046. if err != nil {
  1047. br.Msg = "ppt不存在"
  1048. return
  1049. }
  1050. if pptInfo.AdminId != this.SysUser.AdminId {
  1051. br.Msg = "无权配置"
  1052. return
  1053. }
  1054. pptGrantInfoList, err := models.GetPPtGrantInfo(pptId)
  1055. if err != nil {
  1056. br.Msg = "信息获取失败"
  1057. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  1058. return
  1059. }
  1060. if len(pptGrantInfoList) <= 0 {
  1061. br.Msg = "未配置"
  1062. br.IsSendEmail = false
  1063. return
  1064. }
  1065. grantType := 0
  1066. var adminIdStr string
  1067. if pptGrantInfoList[0].DepartmentId > 0 { //分配类型;1:全部ficc研究员;2:指定成员
  1068. grantType = 1
  1069. } else {
  1070. grantType = 2
  1071. adminIdsList := make([]string, 0)
  1072. for _, v := range pptGrantInfoList {
  1073. adminIdsList = append(adminIdsList, strconv.Itoa(int(v.GrantAdminId)))
  1074. }
  1075. adminIdStr = strings.Join(adminIdsList, ",")
  1076. }
  1077. br.Ret = 200
  1078. br.Success = true
  1079. br.Data = models.GrantInfoResp{
  1080. PptId: pptId,
  1081. GrantType: grantType,
  1082. AdminIdStr: adminIdStr,
  1083. }
  1084. br.Msg = "分配成功"
  1085. }
  1086. // TitleCheck
  1087. // @Title 校验标题是否重复
  1088. // @Description 校验标题是否重复接口
  1089. // @Param Title query int true "标题"
  1090. // @Success 200 Ret=200 编辑成功
  1091. // @router /titleCheck [get]
  1092. func (this *PptV2Controller) TitleCheck() {
  1093. br := new(models.BaseResponse).Init()
  1094. defer func() {
  1095. this.Data["json"] = br
  1096. this.ServeJSON()
  1097. }()
  1098. title := this.GetString("Title")
  1099. pptId, _ := this.GetInt("PptId")
  1100. if title == "" {
  1101. br.Msg = "标题不能为空"
  1102. return
  1103. }
  1104. item, err := models.GetPptV2ByTitleAndId(title, this.SysUser.AdminId)
  1105. if err != nil && !utils.IsErrNoRow(err) {
  1106. br.Msg = "获取数据异常!"
  1107. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  1108. return
  1109. }
  1110. if item != nil && item.PptId > 0 && item.PptId != pptId {
  1111. br.Msg = "标题已存在,不可重复添加"
  1112. br.IsSendEmail = false
  1113. return
  1114. }
  1115. br.Ret = 200
  1116. br.Success = true
  1117. br.Msg = "校验成功"
  1118. }
  1119. // Editing
  1120. // @Title 标记/查询编辑状态
  1121. // @Description 标记/查询编辑状态
  1122. // @Param request body models.PPTEditingReq true "type json string"
  1123. // @Success 200 Ret=200 操作成功
  1124. // @router /editing [post]
  1125. func (this *PptV2Controller) Editing() {
  1126. br := new(models.BaseResponse).Init()
  1127. defer func() {
  1128. if br.ErrMsg == "" {
  1129. br.IsSendEmail = false
  1130. }
  1131. this.Data["json"] = br
  1132. this.ServeJSON()
  1133. }()
  1134. sysUser := this.SysUser
  1135. if sysUser == nil {
  1136. br.Msg = "请登录"
  1137. br.ErrMsg = "请登录,SysUser Is Empty"
  1138. br.Ret = 408
  1139. return
  1140. }
  1141. var req models.PPTEditingReq
  1142. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1143. if err != nil {
  1144. br.Msg = "参数解析异常!"
  1145. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. if req.PptId <= 0 {
  1149. br.Msg = "参数有误"
  1150. return
  1151. }
  1152. if req.Status < 0 {
  1153. br.Msg = "标记状态异常"
  1154. return
  1155. }
  1156. editor, e := services.UpdatePptEditing(req.PptId, req.Status, sysUser.AdminId, sysUser.RealName, false)
  1157. if e != nil {
  1158. br.Msg = "操作失败"
  1159. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  1160. return
  1161. }
  1162. br.Data = editor
  1163. br.Ret = 200
  1164. br.Success = true
  1165. br.Msg = "操作成功"
  1166. }