ppt_report.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/models"
  5. "eta_gn/eta_api/models/system"
  6. "eta_gn/eta_api/services"
  7. "eta_gn/eta_api/utils"
  8. "fmt"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "github.com/rdlucklib/rdluck_tools/paging"
  13. )
  14. // ReportClassify
  15. // @Title 获取ppt报告分类
  16. // @Description 获取ppt报告分类
  17. // @Param Source query int false "来源:1-我的;2-协作;3-公共"
  18. // @Success 200 {object} models.PptReportClassifyItem
  19. // @router /report/classify [get]
  20. func (this *PptV2Controller) ReportClassify() {
  21. br := new(models.BaseResponse).Init()
  22. defer func() {
  23. if br.ErrMsg == "" {
  24. br.IsSendEmail = false
  25. }
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. sysUser := this.SysUser
  30. if sysUser == nil {
  31. br.Msg = "请登录"
  32. br.ErrMsg = "请登录,SysUser Is Empty"
  33. return
  34. }
  35. source, _ := this.GetInt("Source", 1)
  36. if source < 1 || source > 3 {
  37. source = 1
  38. }
  39. // 获取PPT, source:1-我的;2-协作;3-公共
  40. pptList := make([]*models.PptV2, 0)
  41. {
  42. cond := ``
  43. pars := make([]interface{}, 0)
  44. switch source {
  45. case 1:
  46. cond += ` AND admin_id = ?`
  47. pars = append(pars, sysUser.AdminId)
  48. case 2:
  49. cond += ` AND collaborate_type = ? AND (admin_id = ? OR FIND_IN_SET(?, collaborate_users)) `
  50. pars = append(pars, utils.ReportWriteTypeGroup, sysUser.AdminId)
  51. case 3:
  52. cond += ` AND report_source = ? AND state = ?`
  53. pars = append(pars, utils.ReportSourceOuter, models.ReportStatePass)
  54. }
  55. pptOb := new(models.PptV2)
  56. list, e := pptOb.GetItemsByCondition(cond, pars, models.PptReportQueryFields, "modify_time DESC")
  57. if e != nil {
  58. br.Msg = "获取失败"
  59. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  60. return
  61. }
  62. pptList = list
  63. }
  64. classifyPpt := make(map[int][]*models.PptReportItem)
  65. for _, v := range pptList {
  66. // 当前编辑人
  67. t := v.Format2ReportItem(v)
  68. editor, e := services.UpdatePptEditing(v.PptId, 0, sysUser.AdminId, sysUser.RealName, false)
  69. if e != nil {
  70. br.Msg = "获取失败"
  71. br.ErrMsg = fmt.Sprintf("获取PPT编辑状态失败, err: %s", e.Error())
  72. return
  73. }
  74. t.Editor = editor
  75. // 权限
  76. if source == 1 || source == 2 {
  77. t.HasAuth = true
  78. } else {
  79. if v.AdminId == sysUser.AdminId {
  80. t.HasAuth = true
  81. }
  82. if t.HasAuth == false && v.CollaborateUsers != "" {
  83. authorArr := strings.Split(v.CollaborateUsers, ",")
  84. strId := strconv.Itoa(sysUser.AdminId)
  85. if utils.InArrayByStr(authorArr, strId) {
  86. t.HasAuth = true
  87. }
  88. }
  89. }
  90. if classifyPpt[v.ClassifyId] == nil {
  91. classifyPpt[v.ClassifyId] = make([]*models.PptReportItem, 0)
  92. }
  93. classifyPpt[v.ClassifyId] = append(classifyPpt[v.ClassifyId], t)
  94. }
  95. visibleUsers, err := models.GetClassifyVisibleAll()
  96. if err != nil {
  97. br.Msg = "获取失败"
  98. br.ErrMsg = fmt.Sprintf("获取可见用户失败, err: %s", err.Error())
  99. return
  100. }
  101. visibleUsersMap := make(map[int][]int)
  102. for _, v := range visibleUsers {
  103. visibleUsersMap[v.ClassifyId] = append(visibleUsersMap[v.ClassifyId], v.AdminId)
  104. }
  105. var resp []*models.PptReportClassifyItem
  106. // 获取分类
  107. classifies := make([]*models.Classify, 0)
  108. {
  109. // 获取所有分类
  110. ob := new(models.Classify)
  111. cond := ` AND enabled = ?`
  112. pars := make([]interface{}, 0)
  113. pars = append(pars, 1, utils.ReportTypePPT)
  114. list, e := ob.GetItemsByCondition(cond, pars, []string{}, "sort ASC, create_time ASC")
  115. if e != nil {
  116. br.Msg = "获取失败"
  117. br.ErrMsg = fmt.Sprintf("获取分类失败, %v", e)
  118. return
  119. }
  120. // 上级中的分类类型可能与最下层的不一致,但是要把上级也一起取出来, 所以这里要过滤一遍
  121. classifyIds := make([]int, 0)
  122. for _, v := range list {
  123. if v.ClassifyType != utils.ReportTypePPT {
  124. continue
  125. }
  126. // 没有PPT的分类也都过滤掉
  127. //if len(classifyPpt[v.Id]) == 0 {
  128. // continue
  129. //}
  130. // 根据LevelPath去处理
  131. pathArr := strings.Split(v.LevelPath, ",")
  132. for _, p := range pathArr {
  133. id, _ := strconv.Atoi(p)
  134. if id <= 0 {
  135. continue
  136. }
  137. if utils.InArrayByInt(classifyIds, id) {
  138. continue
  139. }
  140. classifyIds = append(classifyIds, id)
  141. }
  142. }
  143. // 过滤掉不在ID中的
  144. for _, v := range list {
  145. if !utils.InArrayByInt(classifyIds, v.Id) {
  146. continue
  147. }
  148. if visible, ok := visibleUsersMap[v.Id]; ok {
  149. if !utils.InArrayByInt(visible, sysUser.AdminId) {
  150. continue
  151. }
  152. }
  153. classifies = append(classifies, v)
  154. }
  155. }
  156. resp = services.GetPptReportClassifyTreeRecursive(classifies, 0, classifyPpt)
  157. br.Data = resp
  158. br.Ret = 200
  159. br.Success = true
  160. br.Msg = "获取成功"
  161. }
  162. // ReportList
  163. // @Title 获取ppt报告列表-分页
  164. // @Description 获取ppt报告列表-分页
  165. // @Param Source query int false "来源:1-我的;2-协作;3-公共"
  166. // @Param ClassifyId query int false "分类ID"
  167. // @Param Keyword query string false "搜索关键词"
  168. // @Success 200 {object} models.PptPageReportResp
  169. // @router /report/list [get]
  170. func (this *PptV2Controller) ReportList() {
  171. br := new(models.BaseResponse).Init()
  172. defer func() {
  173. if br.ErrMsg == "" {
  174. br.IsSendEmail = false
  175. }
  176. this.Data["json"] = br
  177. this.ServeJSON()
  178. }()
  179. sysUser := this.SysUser
  180. if sysUser == nil {
  181. br.Msg = "请登录"
  182. br.ErrMsg = "请登录,SysUser Is Empty"
  183. return
  184. }
  185. pageSize, _ := this.GetInt("PageSize")
  186. currentIndex, _ := this.GetInt("CurrentIndex")
  187. source, _ := this.GetInt("Source", 1)
  188. if source < 1 || source > 3 {
  189. source = 1
  190. }
  191. classifyId, _ := this.GetInt("ClassifyId", 0)
  192. keyword := this.GetString("Keyword")
  193. var startSize int
  194. if pageSize <= 0 {
  195. pageSize = utils.PageSize20
  196. }
  197. if currentIndex <= 0 {
  198. currentIndex = 1
  199. }
  200. startSize = utils.StartIndex(currentIndex, pageSize)
  201. resp := new(models.PptPageReportResp)
  202. resp.List = make([]*models.PptReportItem, 0)
  203. // 获取PPT, source:1-我的;2-协作;3-公共
  204. pptList := make([]*models.PptV2, 0)
  205. cond := ``
  206. pars := make([]interface{}, 0)
  207. {
  208. switch source {
  209. case 1:
  210. cond += ` AND admin_id = ?`
  211. pars = append(pars, sysUser.AdminId)
  212. case 2:
  213. cond += ` AND collaborate_type = ? AND (admin_id = ? OR FIND_IN_SET(?, collaborate_users)) `
  214. pars = append(pars, utils.ReportWriteTypeGroup, sysUser.AdminId, sysUser.AdminId)
  215. case 3:
  216. cond += ` AND report_source = ? AND state = ?`
  217. pars = append(pars, utils.ReportSourceOuter, models.ReportStatePass)
  218. }
  219. if classifyId > 0 {
  220. // 查询分类及子集
  221. classifyOb := new(models.Classify)
  222. childCond := ` AND FIND_IN_SET(?, level_path)`
  223. childPars := make([]interface{}, 0)
  224. childPars = append(childPars, classifyId)
  225. children, e := classifyOb.GetItemsByCondition(childCond, childPars, []string{"id"}, "")
  226. if e != nil {
  227. br.Msg = "获取失败"
  228. br.ErrMsg = fmt.Sprintf("获取分类及子分类失败, %v", e)
  229. return
  230. }
  231. var childIds []int
  232. for _, v := range children {
  233. childIds = append(childIds, v.Id)
  234. }
  235. if len(childIds) == 0 {
  236. page := paging.GetPaging(currentIndex, pageSize, 0)
  237. resp.Paging = page
  238. br.Data = resp
  239. br.Ret = 200
  240. br.Success = true
  241. br.Msg = "获取成功"
  242. return
  243. }
  244. cond += ` AND classify_id IN (?)`
  245. pars = append(pars, childIds)
  246. }
  247. keyword = strings.TrimSpace(keyword)
  248. if keyword != "" {
  249. cond += ` AND title LIKE ?`
  250. pars = append(pars, fmt.Sprint("%", keyword, "%"))
  251. }
  252. }
  253. pptOb := new(models.PptV2)
  254. total, e := pptOb.GetCountByConditionWithAdminId(cond, pars, this.SysUser.AdminId)
  255. if e != nil {
  256. br.Msg = "获取失败"
  257. br.ErrMsg = fmt.Sprintf("获取PPT总数失败, %v", e)
  258. return
  259. }
  260. list, e := pptOb.GetPageItemsByConditionWithAdminId(cond, pars, models.PptReportQueryFields, "modify_time DESC", this.SysUser.AdminId, startSize, pageSize)
  261. if e != nil {
  262. br.Msg = "获取失败"
  263. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  264. return
  265. }
  266. pptList = list
  267. for _, v := range pptList {
  268. // 当前编辑人
  269. t := v.Format2ReportItem(v)
  270. editor, e := services.UpdatePptEditing(v.PptId, 0, sysUser.AdminId, sysUser.RealName, false)
  271. if e != nil {
  272. br.Msg = "获取失败"
  273. br.ErrMsg = fmt.Sprintf("获取PPT编辑状态失败, err: %s", e.Error())
  274. return
  275. }
  276. t.Editor = editor
  277. // 权限
  278. if source == 1 || source == 2 {
  279. t.HasAuth = true
  280. } else {
  281. if v.AdminId == sysUser.AdminId {
  282. t.HasAuth = true
  283. }
  284. if t.HasAuth == false && v.CollaborateUsers != "" {
  285. authorArr := strings.Split(v.CollaborateUsers, ",")
  286. strId := strconv.Itoa(sysUser.AdminId)
  287. if utils.InArrayByStr(authorArr, strId) {
  288. t.HasAuth = true
  289. }
  290. }
  291. }
  292. resp.List = append(resp.List, t)
  293. }
  294. page := paging.GetPaging(currentIndex, pageSize, total)
  295. resp.Paging = page
  296. br.Data = resp
  297. br.Ret = 200
  298. br.Success = true
  299. br.Msg = "获取成功"
  300. }
  301. // CreateReport
  302. // @Title 新增ppt报告
  303. // @Description 新增ppt报告
  304. // @Param request body models.PptReportCreateReq true "type json string"
  305. // @Success 200 Ret=200 新增成功
  306. // @router /report/add [post]
  307. func (this *PptV2Controller) CreateReport() {
  308. br := new(models.BaseResponse).Init()
  309. defer func() {
  310. if br.ErrMsg == "" {
  311. br.IsSendEmail = false
  312. }
  313. this.Data["json"] = br
  314. this.ServeJSON()
  315. }()
  316. sysUser := this.SysUser
  317. if sysUser == nil {
  318. br.Msg = "请登录"
  319. br.ErrMsg = "请登录,SysUser Is Empty"
  320. return
  321. }
  322. var req models.PptReportCreateReq
  323. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  324. br.Msg = "参数解析异常"
  325. br.ErrMsg = fmt.Sprintf("参数解析失败, %v", e)
  326. return
  327. }
  328. req.Title = strings.TrimSpace(req.Title)
  329. if req.Title == "" {
  330. br.Msg = "请输入标题"
  331. return
  332. }
  333. if req.AddType != 1 && req.AddType != 2 {
  334. req.AddType = 1
  335. }
  336. if req.ClassifyId <= 0 {
  337. br.Msg = "请选择分类"
  338. return
  339. }
  340. if req.CollaborateType != 1 && req.CollaborateType != 2 {
  341. br.Msg = "协作方式异常"
  342. br.ErrMsg = fmt.Sprintf("协作方式异常, %d", req.CollaborateType)
  343. return
  344. }
  345. if req.CollaborateType == 2 && len(req.CollaborateUserIds) == 0 {
  346. br.Msg = "请选择协作人"
  347. return
  348. }
  349. // 新报告
  350. newItem := new(models.PptV2)
  351. newItem.Title = req.Title
  352. newItem.AddType = req.AddType
  353. newItem.ClassifyId = req.ClassifyId
  354. newItem.CollaborateType = req.CollaborateType
  355. if len(req.CollaborateUserIds) > 0 {
  356. var partnerArr []string
  357. for _, v := range req.CollaborateUserIds {
  358. partnerArr = append(partnerArr, strconv.Itoa(v))
  359. }
  360. newItem.CollaborateUsers = strings.Trim(strings.Join(partnerArr, ","), `"`)
  361. }
  362. newItem.PptVersion = 2
  363. newItem.AdminId = sysUser.AdminId
  364. newItem.AdminRealName = sysUser.RealName
  365. newItem.ReportSource = utils.ReportSourceLocal // 固定本地PPT
  366. newItem.State = models.ReportStateUnpublished // 默认未发布
  367. newItem.CreateTime = time.Now()
  368. newItem.ModifyTime = time.Now()
  369. // 继承PPT内容
  370. if req.AddType == utils.ReportAddTypeInherit && req.InheritPptId > 0 {
  371. inheritPpt, e := models.GetPptV2ById(req.InheritPptId)
  372. if e != nil {
  373. if utils.IsErrNoRow(e) {
  374. br.Msg = "被继承报告不存在"
  375. return
  376. }
  377. br.Msg = "操作失败"
  378. br.ErrMsg = fmt.Sprintf("操作失败, %v", e)
  379. return
  380. }
  381. newItem.TemplateType = inheritPpt.TemplateType
  382. newItem.BackgroundImg = inheritPpt.BackgroundImg
  383. newItem.CurrentBackgroundImg = inheritPpt.CurrentBackgroundImg
  384. newItem.BackCoverImg = inheritPpt.BackCoverImg
  385. newItem.CurrentBackgroundImgId = inheritPpt.CurrentBackgroundImgId
  386. newItem.BackCoverImgId = inheritPpt.BackCoverImgId
  387. newItem.BackgroundImgId = inheritPpt.BackgroundImgId
  388. newItem.ReportType = inheritPpt.ReportType
  389. newItem.PptDate = inheritPpt.PptDate
  390. newItem.Content = inheritPpt.Content
  391. newItem.CoverContent = inheritPpt.CoverContent
  392. newItem.TitleSetting = inheritPpt.TitleSetting
  393. }
  394. // 非继承PPT,有内容时写入内容(如合并PPT时)
  395. if req.InheritPptId <= 0 {
  396. newItem.TemplateType = req.FirstPage.TemplateType
  397. newItem.BackgroundImg = req.FirstPage.ImgUrl
  398. newItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
  399. newItem.BackCoverImg = req.FirstPage.BackCoverImg
  400. newItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
  401. newItem.BackCoverImgId = req.FirstPage.BackCoverImgId
  402. newItem.BackgroundImgId = req.FirstPage.BackgroundImgId
  403. newItem.ReportType = req.FirstPage.ReportType
  404. newItem.PptDate = req.FirstPage.PptDate
  405. newItem.Content = req.Content
  406. newItem.CoverContent = req.CoverContent
  407. newItem.TitleSetting = req.TitleSetting
  408. }
  409. // 初始的PPT页数
  410. if newItem.Content != "" {
  411. var pageContents []services.PPTContent
  412. _ = json.Unmarshal([]byte(newItem.Content), &pageContents) // 这里转不过去问题也不大,编辑时自动保存会更新页数字段
  413. newItem.PptPage = len(pageContents)
  414. }
  415. newId, e := models.AddPptV2(newItem)
  416. if e != nil {
  417. br.Msg = "操作失败"
  418. br.ErrMsg = fmt.Sprintf("新增PPT报告失败, %v", e)
  419. return
  420. }
  421. // 更新报告分类计数
  422. go func() {
  423. _ = services.UpdateClassifyReportNum(req.ClassifyId)
  424. }()
  425. resp := models.AddPptResp{
  426. PptId: newId,
  427. }
  428. br.Data = resp
  429. br.Ret = 200
  430. br.Success = true
  431. br.Msg = "操作成功"
  432. }
  433. // AuthList
  434. // @Title 获取有权限的列表
  435. // @Description 获取有权限的列表
  436. // @Param PageSize query int true "每页数据条数"
  437. // @Param CurrentIndex query int true "当前页页码,从1开始"
  438. // @Param Keyword query string false "搜索关键词"
  439. // @Param ClassifyId query int false "分类ID"
  440. // @Success 200 {object} models.PptPageReportResp
  441. // @router /report/auth_list [get]
  442. func (this *PptV2Controller) AuthList() {
  443. br := new(models.BaseResponse).Init()
  444. defer func() {
  445. if br.ErrMsg == "" {
  446. br.IsSendEmail = false
  447. }
  448. this.Data["json"] = br
  449. this.ServeJSON()
  450. }()
  451. sysUser := this.SysUser
  452. if sysUser == nil {
  453. br.Msg = "请登录"
  454. br.ErrMsg = "请登录,SysUser Is Empty"
  455. br.Ret = 408
  456. return
  457. }
  458. pageSize, _ := this.GetInt("PageSize")
  459. currentIndex, _ := this.GetInt("CurrentIndex")
  460. keyword := this.GetString("Keyword")
  461. classifyId, _ := this.GetInt("ClassifyId", 0)
  462. var startSize int
  463. if pageSize <= 0 {
  464. pageSize = utils.PageSize20
  465. }
  466. if currentIndex <= 0 {
  467. currentIndex = 1
  468. }
  469. startSize = utils.StartIndex(currentIndex, pageSize)
  470. var pptList []*models.PptReportItem
  471. // 无相关搜索时,返回空集(其实我感觉没必要,没关键词查全部也属于正常=_=!)
  472. if keyword == `` && classifyId <= 0 {
  473. page := paging.GetPaging(currentIndex, pageSize, 0)
  474. resp := new(models.PptPageReportResp)
  475. resp.Paging = page
  476. resp.List = pptList
  477. br.Ret = 200
  478. br.Success = true
  479. br.Msg = "获取成功"
  480. br.Data = resp
  481. return
  482. }
  483. // 查询自己创建的以及协作人包含自己的报告、以及外部已审批报告
  484. var cond string
  485. var pars []interface{}
  486. cond += ` AND (admin_id = ? OR (admin_id <> ? AND FIND_IN_SET(?, collaborate_users)) OR (report_source = ? AND state = ?))`
  487. pars = append(pars, sysUser.AdminId, sysUser.AdminId, sysUser.AdminId, utils.ReportSourceOuter, models.ReportStatePass)
  488. if classifyId > 0 {
  489. cond += ` AND classify_id = ? `
  490. pars = append(pars, classifyId)
  491. }
  492. keyword = strings.TrimSpace(keyword)
  493. if keyword != `` {
  494. cond += ` AND title LIKE ? `
  495. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  496. }
  497. noVisisbleClassifyIds, err := models.GetNoVisibleClassifyIdByAdminId(sysUser.AdminId)
  498. if err != nil {
  499. br.Msg = "获取失败"
  500. br.ErrMsg = fmt.Sprintf("获取不可见分类失败, %v", err)
  501. return
  502. }
  503. if len(noVisisbleClassifyIds) > 0 {
  504. cond += ` AND classify_id NOT IN (?)`
  505. pars = append(pars, noVisisbleClassifyIds)
  506. }
  507. pptOb := new(models.PptV2)
  508. total, e := pptOb.GetCountByCondition(cond, pars)
  509. if e != nil {
  510. br.Msg = "获取失败"
  511. br.ErrMsg = fmt.Sprintf("获取PPT总数失败, %v", e)
  512. return
  513. }
  514. list, e := pptOb.GetPageItemsByCondition(cond, pars, models.PptReportQueryFields, "", startSize, pageSize)
  515. if e != nil {
  516. br.Msg = "获取失败"
  517. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  518. return
  519. }
  520. // 分类完整路径、协作人姓名
  521. classifyIdFull := make(map[int]string)
  522. {
  523. ob := new(models.Classify)
  524. classifies, e := ob.GetItemsByCondition("", make([]interface{}, 0), []string{}, "")
  525. if e != nil {
  526. br.Msg = "获取失败"
  527. br.ErrMsg = fmt.Sprintf("获取分类失败, %v", e)
  528. return
  529. }
  530. classifyIdName := make(map[string]string)
  531. for _, v := range classifies {
  532. classifyIdName[strconv.Itoa(v.Id)] = v.ClassifyName
  533. }
  534. for _, v := range classifies {
  535. arr := strings.Split(v.LevelPath, ",")
  536. if len(arr) == 0 {
  537. continue
  538. }
  539. var nameArr []string
  540. for _, a := range arr {
  541. n := classifyIdName[a]
  542. if n == "" {
  543. continue
  544. }
  545. nameArr = append(nameArr, n)
  546. }
  547. classifyIdFull[v.Id] = strings.Join(nameArr, "/")
  548. }
  549. }
  550. adminIdName := make(map[int]string)
  551. {
  552. cond := ` AND enabled = 1`
  553. pars := make([]interface{}, 0)
  554. sysAdmin, e := system.GetSysAdminList(cond, pars, []string{}, "")
  555. if e != nil {
  556. br.Msg = "获取失败"
  557. br.ErrMsg = "获取用户失败,Err:" + e.Error()
  558. return
  559. }
  560. for _, v := range sysAdmin {
  561. adminIdName[v.AdminId] = v.RealName
  562. }
  563. }
  564. // 格式化数据
  565. for _, v := range list {
  566. t := v.Format2ReportItem(v)
  567. t.HasAuth = true // 该列表固定有权限
  568. t.FullClassify = classifyIdFull[v.ClassifyId] // 分类的完整路径
  569. // 协作人
  570. if v.CollaborateUsers != "" {
  571. var authors []models.PptReportCollaborateUser
  572. authorArr := strings.Split(v.CollaborateUsers, ",")
  573. for _, au := range authorArr {
  574. uid, _ := strconv.Atoi(au)
  575. if uid <= 0 {
  576. continue
  577. }
  578. name := adminIdName[uid]
  579. if name == "" {
  580. continue
  581. }
  582. authors = append(authors, models.PptReportCollaborateUser{
  583. AdminId: uid,
  584. RealName: name,
  585. })
  586. }
  587. t.CollaborateUsers = authors
  588. }
  589. pptList = append(pptList, t)
  590. }
  591. page := paging.GetPaging(currentIndex, pageSize, total)
  592. resp := new(models.PptPageReportResp)
  593. resp.Paging = page
  594. resp.List = pptList
  595. br.Ret = 200
  596. br.Success = true
  597. br.Msg = "获取成功"
  598. br.Data = resp
  599. }