ppt_report.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. resp = services.RecursiveFilterPptNoChildTreeClassify(resp)
  158. br.Data = resp
  159. br.Ret = 200
  160. br.Success = true
  161. br.Msg = "获取成功"
  162. }
  163. // ReportList
  164. // @Title 获取ppt报告列表-分页
  165. // @Description 获取ppt报告列表-分页
  166. // @Param Source query int false "来源:1-我的;2-协作;3-公共"
  167. // @Param ClassifyId query int false "分类ID"
  168. // @Param Keyword query string false "搜索关键词"
  169. // @Success 200 {object} models.PptPageReportResp
  170. // @router /report/list [get]
  171. func (this *PptV2Controller) ReportList() {
  172. br := new(models.BaseResponse).Init()
  173. defer func() {
  174. if br.ErrMsg == "" {
  175. br.IsSendEmail = false
  176. }
  177. this.Data["json"] = br
  178. this.ServeJSON()
  179. }()
  180. sysUser := this.SysUser
  181. if sysUser == nil {
  182. br.Msg = "请登录"
  183. br.ErrMsg = "请登录,SysUser Is Empty"
  184. return
  185. }
  186. pageSize, _ := this.GetInt("PageSize")
  187. currentIndex, _ := this.GetInt("CurrentIndex")
  188. source, _ := this.GetInt("Source", 1)
  189. if source < 1 || source > 3 {
  190. source = 1
  191. }
  192. classifyId, _ := this.GetInt("ClassifyId", 0)
  193. keyword := this.GetString("Keyword")
  194. var startSize int
  195. if pageSize <= 0 {
  196. pageSize = utils.PageSize20
  197. }
  198. if currentIndex <= 0 {
  199. currentIndex = 1
  200. }
  201. startSize = utils.StartIndex(currentIndex, pageSize)
  202. resp := new(models.PptPageReportResp)
  203. resp.List = make([]*models.PptReportItem, 0)
  204. // 获取PPT, source:1-我的;2-协作;3-公共
  205. pptList := make([]*models.PptV2, 0)
  206. cond := ``
  207. pars := make([]interface{}, 0)
  208. {
  209. switch source {
  210. case 1:
  211. cond += ` AND admin_id = ?`
  212. pars = append(pars, sysUser.AdminId)
  213. case 2:
  214. cond += ` AND collaborate_type = ? AND (admin_id = ? OR FIND_IN_SET(?, collaborate_users)) `
  215. pars = append(pars, utils.ReportWriteTypeGroup, sysUser.AdminId, sysUser.AdminId)
  216. case 3:
  217. cond += ` AND report_source = ? AND state = ?`
  218. pars = append(pars, utils.ReportSourceOuter, models.ReportStatePass)
  219. }
  220. if classifyId > 0 {
  221. // 查询分类及子集
  222. classifyOb := new(models.Classify)
  223. childCond := ` AND FIND_IN_SET(?, level_path)`
  224. childPars := make([]interface{}, 0)
  225. childPars = append(childPars, classifyId)
  226. children, e := classifyOb.GetItemsByCondition(childCond, childPars, []string{"id"}, "")
  227. if e != nil {
  228. br.Msg = "获取失败"
  229. br.ErrMsg = fmt.Sprintf("获取分类及子分类失败, %v", e)
  230. return
  231. }
  232. var childIds []int
  233. for _, v := range children {
  234. childIds = append(childIds, v.Id)
  235. }
  236. if len(childIds) == 0 {
  237. page := paging.GetPaging(currentIndex, pageSize, 0)
  238. resp.Paging = page
  239. br.Data = resp
  240. br.Ret = 200
  241. br.Success = true
  242. br.Msg = "获取成功"
  243. return
  244. }
  245. cond += ` AND classify_id IN (?)`
  246. pars = append(pars, childIds)
  247. }
  248. keyword = strings.TrimSpace(keyword)
  249. if keyword != "" {
  250. cond += ` AND title LIKE ?`
  251. pars = append(pars, fmt.Sprint("%", keyword, "%"))
  252. }
  253. }
  254. noVisibleClassifyIds, err := models.GetNoVisibleClassifyIdByAdminId(this.SysUser.AdminId)
  255. if err != nil {
  256. br.Msg = "获取失败"
  257. br.ErrMsg = "获取不可见分类id失败,Err:" + err.Error()
  258. return
  259. }
  260. if len(noVisibleClassifyIds) > 0 {
  261. cond += ` AND classify_id NOT IN (?) `
  262. pars = append(pars, noVisibleClassifyIds)
  263. }
  264. pptOb := new(models.PptV2)
  265. total, e := pptOb.GetCountByCondition(cond, pars)
  266. if e != nil {
  267. br.Msg = "获取失败"
  268. br.ErrMsg = fmt.Sprintf("获取PPT总数失败, %v", e)
  269. return
  270. }
  271. list, e := pptOb.GetPageItemsByCondition(cond, pars, models.PptReportQueryFields, "modify_time DESC", startSize, pageSize)
  272. if e != nil {
  273. br.Msg = "获取失败"
  274. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  275. return
  276. }
  277. pptList = list
  278. for _, v := range pptList {
  279. // 当前编辑人
  280. t := v.Format2ReportItem(v)
  281. editor, e := services.UpdatePptEditing(v.PptId, 0, sysUser.AdminId, sysUser.RealName, false)
  282. if e != nil {
  283. br.Msg = "获取失败"
  284. br.ErrMsg = fmt.Sprintf("获取PPT编辑状态失败, err: %s", e.Error())
  285. return
  286. }
  287. t.Editor = editor
  288. // 权限
  289. if source == 1 || source == 2 {
  290. t.HasAuth = true
  291. } else {
  292. if v.AdminId == sysUser.AdminId {
  293. t.HasAuth = true
  294. }
  295. if t.HasAuth == false && v.CollaborateUsers != "" {
  296. authorArr := strings.Split(v.CollaborateUsers, ",")
  297. strId := strconv.Itoa(sysUser.AdminId)
  298. if utils.InArrayByStr(authorArr, strId) {
  299. t.HasAuth = true
  300. }
  301. }
  302. }
  303. resp.List = append(resp.List, t)
  304. }
  305. page := paging.GetPaging(currentIndex, pageSize, total)
  306. resp.Paging = page
  307. br.Data = resp
  308. br.Ret = 200
  309. br.Success = true
  310. br.Msg = "获取成功"
  311. }
  312. // CreateReport
  313. // @Title 新增ppt报告
  314. // @Description 新增ppt报告
  315. // @Param request body models.PptReportCreateReq true "type json string"
  316. // @Success 200 Ret=200 新增成功
  317. // @router /report/add [post]
  318. func (this *PptV2Controller) CreateReport() {
  319. br := new(models.BaseResponse).Init()
  320. defer func() {
  321. if br.ErrMsg == "" {
  322. br.IsSendEmail = false
  323. }
  324. this.Data["json"] = br
  325. this.ServeJSON()
  326. }()
  327. sysUser := this.SysUser
  328. if sysUser == nil {
  329. br.Msg = "请登录"
  330. br.ErrMsg = "请登录,SysUser Is Empty"
  331. return
  332. }
  333. var req models.PptReportCreateReq
  334. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  335. br.Msg = "参数解析异常"
  336. br.ErrMsg = fmt.Sprintf("参数解析失败, %v", e)
  337. return
  338. }
  339. req.Title = strings.TrimSpace(req.Title)
  340. if req.Title == "" {
  341. br.Msg = "请输入标题"
  342. return
  343. }
  344. if req.AddType != 1 && req.AddType != 2 {
  345. req.AddType = 1
  346. }
  347. if req.ClassifyId <= 0 {
  348. br.Msg = "请选择分类"
  349. return
  350. }
  351. if req.CollaborateType != 1 && req.CollaborateType != 2 {
  352. br.Msg = "协作方式异常"
  353. br.ErrMsg = fmt.Sprintf("协作方式异常, %d", req.CollaborateType)
  354. return
  355. }
  356. if req.CollaborateType == 2 && len(req.CollaborateUserIds) == 0 {
  357. br.Msg = "请选择协作人"
  358. return
  359. }
  360. // 新报告
  361. newItem := new(models.PptV2)
  362. newItem.Title = req.Title
  363. newItem.Abstract = req.Abstract
  364. newItem.AddType = req.AddType
  365. newItem.ClassifyId = req.ClassifyId
  366. newItem.CollaborateType = req.CollaborateType
  367. if len(req.CollaborateUserIds) > 0 {
  368. var partnerArr []string
  369. for _, v := range req.CollaborateUserIds {
  370. partnerArr = append(partnerArr, strconv.Itoa(v))
  371. }
  372. newItem.CollaborateUsers = strings.Trim(strings.Join(partnerArr, ","), `"`)
  373. }
  374. newItem.PptVersion = 2
  375. newItem.AdminId = sysUser.AdminId
  376. newItem.AdminRealName = sysUser.RealName
  377. newItem.ReportSource = utils.ReportSourceLocal // 固定本地PPT
  378. newItem.State = models.ReportStateUnpublished // 默认未发布
  379. newItem.CreateTime = time.Now()
  380. newItem.ModifyTime = time.Now()
  381. // 继承PPT内容
  382. if req.AddType == utils.ReportAddTypeInherit && req.InheritPptId > 0 {
  383. inheritPpt, e := models.GetPptV2ById(req.InheritPptId)
  384. if e != nil {
  385. if utils.IsErrNoRow(e) {
  386. br.Msg = "被继承报告不存在"
  387. return
  388. }
  389. br.Msg = "操作失败"
  390. br.ErrMsg = fmt.Sprintf("操作失败, %v", e)
  391. return
  392. }
  393. newItem.TemplateType = inheritPpt.TemplateType
  394. newItem.BackgroundImg = inheritPpt.BackgroundImg
  395. newItem.CurrentBackgroundImg = inheritPpt.CurrentBackgroundImg
  396. newItem.BackCoverImg = inheritPpt.BackCoverImg
  397. newItem.CurrentBackgroundImgId = inheritPpt.CurrentBackgroundImgId
  398. newItem.BackCoverImgId = inheritPpt.BackCoverImgId
  399. newItem.BackgroundImgId = inheritPpt.BackgroundImgId
  400. newItem.ReportType = inheritPpt.ReportType
  401. newItem.PptDate = inheritPpt.PptDate
  402. newItem.Content = inheritPpt.Content
  403. newItem.CoverContent = inheritPpt.CoverContent
  404. newItem.TitleSetting = inheritPpt.TitleSetting
  405. }
  406. // 非继承PPT,有内容时写入内容(如合并PPT时)
  407. if req.InheritPptId <= 0 {
  408. newItem.TemplateType = req.FirstPage.TemplateType
  409. newItem.BackgroundImg = req.FirstPage.ImgUrl
  410. newItem.CurrentBackgroundImg = req.FirstPage.CurrentBackgroundImg
  411. newItem.BackCoverImg = req.FirstPage.BackCoverImg
  412. newItem.CurrentBackgroundImgId = req.FirstPage.CurrentBackgroundImgId
  413. newItem.BackCoverImgId = req.FirstPage.BackCoverImgId
  414. newItem.BackgroundImgId = req.FirstPage.BackgroundImgId
  415. newItem.ReportType = req.FirstPage.ReportType
  416. newItem.PptDate = req.FirstPage.PptDate
  417. newItem.Content = req.Content
  418. newItem.CoverContent = req.CoverContent
  419. newItem.TitleSetting = req.TitleSetting
  420. }
  421. // 初始的PPT页数
  422. if newItem.Content != "" {
  423. var pageContents []services.PPTContent
  424. _ = json.Unmarshal([]byte(newItem.Content), &pageContents) // 这里转不过去问题也不大,编辑时自动保存会更新页数字段
  425. newItem.PptPage = len(pageContents)
  426. }
  427. newId, e := models.AddPptV2(newItem)
  428. if e != nil {
  429. br.Msg = "操作失败"
  430. br.ErrMsg = fmt.Sprintf("新增PPT报告失败, %v", e)
  431. return
  432. }
  433. // 更新报告分类计数
  434. go func() {
  435. _ = services.UpdateClassifyReportNum(req.ClassifyId)
  436. }()
  437. resp := models.AddPptResp{
  438. PptId: newId,
  439. }
  440. br.Data = resp
  441. br.Ret = 200
  442. br.Success = true
  443. br.Msg = "操作成功"
  444. }
  445. // AuthList
  446. // @Title 获取有权限的列表
  447. // @Description 获取有权限的列表
  448. // @Param PageSize query int true "每页数据条数"
  449. // @Param CurrentIndex query int true "当前页页码,从1开始"
  450. // @Param Keyword query string false "搜索关键词"
  451. // @Param ClassifyId query int false "分类ID"
  452. // @Success 200 {object} models.PptPageReportResp
  453. // @router /report/auth_list [get]
  454. func (this *PptV2Controller) AuthList() {
  455. br := new(models.BaseResponse).Init()
  456. defer func() {
  457. if br.ErrMsg == "" {
  458. br.IsSendEmail = false
  459. }
  460. this.Data["json"] = br
  461. this.ServeJSON()
  462. }()
  463. sysUser := this.SysUser
  464. if sysUser == nil {
  465. br.Msg = "请登录"
  466. br.ErrMsg = "请登录,SysUser Is Empty"
  467. br.Ret = 408
  468. return
  469. }
  470. pageSize, _ := this.GetInt("PageSize")
  471. currentIndex, _ := this.GetInt("CurrentIndex")
  472. keyword := this.GetString("Keyword")
  473. classifyId, _ := this.GetInt("ClassifyId", 0)
  474. var startSize int
  475. if pageSize <= 0 {
  476. pageSize = utils.PageSize20
  477. }
  478. if currentIndex <= 0 {
  479. currentIndex = 1
  480. }
  481. startSize = utils.StartIndex(currentIndex, pageSize)
  482. var pptList []*models.PptReportItem
  483. // 无相关搜索时,返回空集(其实我感觉没必要,没关键词查全部也属于正常=_=!)
  484. if keyword == `` && classifyId <= 0 {
  485. page := paging.GetPaging(currentIndex, pageSize, 0)
  486. resp := new(models.PptPageReportResp)
  487. resp.Paging = page
  488. resp.List = pptList
  489. br.Ret = 200
  490. br.Success = true
  491. br.Msg = "获取成功"
  492. br.Data = resp
  493. return
  494. }
  495. // 查询自己创建的以及协作人包含自己的报告、以及外部已审批报告
  496. var cond string
  497. var pars []interface{}
  498. cond += ` AND (admin_id = ? OR (admin_id <> ? AND FIND_IN_SET(?, collaborate_users)) OR (report_source = ? AND state = ?))`
  499. pars = append(pars, sysUser.AdminId, sysUser.AdminId, sysUser.AdminId, utils.ReportSourceOuter, models.ReportStatePass)
  500. if classifyId > 0 {
  501. cond += ` AND classify_id = ? `
  502. pars = append(pars, classifyId)
  503. }
  504. keyword = strings.TrimSpace(keyword)
  505. if keyword != `` {
  506. cond += ` AND title LIKE ? `
  507. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  508. }
  509. noVisisbleClassifyIds, err := models.GetNoVisibleClassifyIdByAdminId(sysUser.AdminId)
  510. if err != nil {
  511. br.Msg = "获取失败"
  512. br.ErrMsg = fmt.Sprintf("获取不可见分类失败, %v", err)
  513. return
  514. }
  515. if len(noVisisbleClassifyIds) > 0 {
  516. cond += ` AND classify_id NOT IN (?)`
  517. pars = append(pars, noVisisbleClassifyIds)
  518. }
  519. pptOb := new(models.PptV2)
  520. total, e := pptOb.GetCountByCondition(cond, pars)
  521. if e != nil {
  522. br.Msg = "获取失败"
  523. br.ErrMsg = fmt.Sprintf("获取PPT总数失败, %v", e)
  524. return
  525. }
  526. list, e := pptOb.GetPageItemsByCondition(cond, pars, models.PptReportQueryFields, "", startSize, pageSize)
  527. if e != nil {
  528. br.Msg = "获取失败"
  529. br.ErrMsg = fmt.Sprintf("获取PPT失败, %v", e)
  530. return
  531. }
  532. // 分类完整路径、协作人姓名
  533. classifyIdFull := make(map[int]string)
  534. {
  535. ob := new(models.Classify)
  536. classifies, e := ob.GetItemsByCondition("", make([]interface{}, 0), []string{}, "")
  537. if e != nil {
  538. br.Msg = "获取失败"
  539. br.ErrMsg = fmt.Sprintf("获取分类失败, %v", e)
  540. return
  541. }
  542. classifyIdName := make(map[string]string)
  543. for _, v := range classifies {
  544. classifyIdName[strconv.Itoa(v.Id)] = v.ClassifyName
  545. }
  546. for _, v := range classifies {
  547. arr := strings.Split(v.LevelPath, ",")
  548. if len(arr) == 0 {
  549. continue
  550. }
  551. var nameArr []string
  552. for _, a := range arr {
  553. n := classifyIdName[a]
  554. if n == "" {
  555. continue
  556. }
  557. nameArr = append(nameArr, n)
  558. }
  559. classifyIdFull[v.Id] = strings.Join(nameArr, "/")
  560. }
  561. }
  562. adminIdName := make(map[int]string)
  563. {
  564. cond := ` AND enabled = 1`
  565. pars := make([]interface{}, 0)
  566. sysAdmin, e := system.GetSysAdminList(cond, pars, []string{}, "")
  567. if e != nil {
  568. br.Msg = "获取失败"
  569. br.ErrMsg = "获取用户失败,Err:" + e.Error()
  570. return
  571. }
  572. for _, v := range sysAdmin {
  573. adminIdName[v.AdminId] = v.RealName
  574. }
  575. }
  576. // 格式化数据
  577. for _, v := range list {
  578. t := v.Format2ReportItem(v)
  579. t.HasAuth = true // 该列表固定有权限
  580. t.FullClassify = classifyIdFull[v.ClassifyId] // 分类的完整路径
  581. // 协作人
  582. if v.CollaborateUsers != "" {
  583. var authors []models.PptReportCollaborateUser
  584. authorArr := strings.Split(v.CollaborateUsers, ",")
  585. for _, au := range authorArr {
  586. uid, _ := strconv.Atoi(au)
  587. if uid <= 0 {
  588. continue
  589. }
  590. name := adminIdName[uid]
  591. if name == "" {
  592. continue
  593. }
  594. authors = append(authors, models.PptReportCollaborateUser{
  595. AdminId: uid,
  596. RealName: name,
  597. })
  598. }
  599. t.CollaborateUsers = authors
  600. }
  601. pptList = append(pptList, t)
  602. }
  603. page := paging.GetPaging(currentIndex, pageSize, total)
  604. resp := new(models.PptPageReportResp)
  605. resp.Paging = page
  606. resp.List = pptList
  607. br.Ret = 200
  608. br.Success = true
  609. br.Msg = "获取成功"
  610. br.Data = resp
  611. }