ppt_group.go 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819
  1. package ppt
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta_gn/eta_api/models"
  6. "eta_gn/eta_api/models/system"
  7. "eta_gn/eta_api/services"
  8. "eta_gn/eta_api/utils"
  9. "fmt"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type PageContent struct {
  16. //Id int `json:"id"`
  17. Key int `json:"key"`
  18. ModelId int `json:"modelId"`
  19. Title string `json:"title"`
  20. Elements []PageContentElements `json:"elements"`
  21. }
  22. type PageContentElements struct {
  23. Type string `json:"type"`
  24. Position int `json:"position"`
  25. Content string `json:"content"`
  26. RichContent string `json:"richContent"`
  27. ChartId string `json:"chartId"`
  28. Src string `json:"src"`
  29. }
  30. // GetGroupsByAdminId 查询ppt目录列表
  31. func GetGroupsByAdminId(IsNewPpt, adminId int) (ret models.RespGroupList, err error) {
  32. publicGroups, err := models.GetPublicPptGroups()
  33. if err != nil {
  34. err = errors.New("公共目录查询出错:" + err.Error())
  35. return
  36. }
  37. privateGroups, err := models.GetPrivatePptGroups(adminId)
  38. if err != nil {
  39. err = errors.New("私有目录查询出错:" + err.Error())
  40. return
  41. }
  42. groupIds := make([]int64, 0)
  43. for _, v := range publicGroups {
  44. groupIds = append(groupIds, v.GroupId)
  45. }
  46. for _, v := range privateGroups {
  47. groupIds = append(groupIds, v.GroupId)
  48. }
  49. ret.PublicList = make([]*models.RespGroupListItem, 0)
  50. ret.PrivateList = make([]*models.RespGroupListItem, 0)
  51. if len(groupIds) == 0 {
  52. return
  53. }
  54. //整理目录数据
  55. for _, v := range publicGroups {
  56. tmp := new(models.RespGroupListItem)
  57. tmp.GroupId = v.GroupId
  58. tmp.GroupName = v.GroupName
  59. tmp.IsShare = v.IsShare
  60. tmp.AdminId = v.AdminId
  61. ret.PublicList = append(ret.PublicList, tmp)
  62. }
  63. for _, v := range privateGroups {
  64. if v.IsShareAdd == 1 {
  65. continue
  66. } else {
  67. tmp := new(models.RespGroupListItem)
  68. tmp.GroupId = v.GroupId
  69. tmp.GroupName = v.GroupName
  70. tmp.IsShare = v.IsShare
  71. tmp.AdminId = v.AdminId
  72. ret.PrivateList = append(ret.PrivateList, tmp)
  73. }
  74. }
  75. pptMappings, err := models.GetPptMappingListByGroupIds(groupIds)
  76. if err != nil {
  77. err = errors.New("查询目录里的ppt出错:" + err.Error())
  78. return
  79. }
  80. pptMap := make(map[int]*models.PptV2)
  81. groupMap := make(map[int64][]*models.RespGroupPptNameListItem)
  82. groupHasNewPptMap := make(map[int64]struct{})
  83. pptIds := make([]int, 0)
  84. for _, v := range pptMappings {
  85. pptIds = append(pptIds, int(v.PptId))
  86. }
  87. if len(pptIds) == 0 {
  88. // 返回所有空目录
  89. return
  90. }
  91. pptList, err := models.GetPptV2ByIds(pptIds)
  92. if err != nil {
  93. err = errors.New("查询ppt详情出错:" + err.Error())
  94. return
  95. }
  96. for _, v := range pptList {
  97. pptMap[v.PptId] = v
  98. }
  99. //组装group ppt
  100. for _, v := range pptMappings {
  101. tmp := new(models.RespGroupPptNameListItem)
  102. tmp.AdminId = v.AdminId
  103. tmp.GroupPptId = v.GroupPptId
  104. tmp.PptId = v.PptId
  105. if v.ChildGroupPptId > 0 {
  106. tmp.IsSingleShare = 1
  107. }
  108. if i, ok := pptMap[int(v.PptId)]; ok {
  109. // 因之前并没有存储PPT页数字段,所以此处读取PPT内容的长度
  110. if i.Content != "" {
  111. contents := make([]PageContent, 0)
  112. if e := json.Unmarshal([]byte(i.Content), &contents); e != nil {
  113. err = errors.New("解析PPT内容页数失败: " + e.Error())
  114. return
  115. }
  116. tmp.PptPage = len(contents)
  117. }
  118. tmp.Title = i.Title
  119. tmp.PptVersion = i.PptVersion
  120. tmp.PptxUrl = i.PptxUrl
  121. tmp.ReportId = i.ReportId
  122. tmp.ReportCode = i.ReportCode
  123. tmp.PptCreateTime = i.CreateTime.Format(utils.FormatDateTime)
  124. }
  125. tmp.AdminRealName = v.AdminRealName
  126. if tmp.PptVersion == 2 {
  127. groupHasNewPptMap[v.GroupId] = struct{}{}
  128. } else {
  129. if IsNewPpt == 1 { //如果只展示新版的ppt,则忽略旧版ppt
  130. continue
  131. }
  132. }
  133. groupMap[v.GroupId] = append(groupMap[v.GroupId], tmp)
  134. }
  135. for k, v := range ret.PublicList {
  136. if pptL, ok := groupMap[v.GroupId]; ok {
  137. ret.PublicList[k].PptList = pptL
  138. if _, ok1 := groupHasNewPptMap[v.GroupId]; !ok1 && len(pptL) > 0 {
  139. ret.PublicList[k].OnlyOld = true
  140. }
  141. }
  142. }
  143. for k, v := range ret.PrivateList {
  144. if pptL, ok := groupMap[v.GroupId]; ok {
  145. ret.PrivateList[k].PptList = pptL
  146. if _, ok1 := groupHasNewPptMap[v.GroupId]; !ok1 && len(pptL) > 0 {
  147. ret.PrivateList[k].OnlyOld = true
  148. }
  149. }
  150. }
  151. if IsNewPpt == 1 { //如果只展示新版ppt,则过滤空文件夹
  152. pubList := make([]*models.RespGroupListItem, 0)
  153. for _, v := range ret.PublicList {
  154. if len(v.PptList) > 0 {
  155. pubList = append(pubList, v)
  156. }
  157. }
  158. ret.PublicList = pubList
  159. priList := make([]*models.RespGroupListItem, 0)
  160. for _, v := range ret.PrivateList {
  161. if len(v.PptList) > 0 {
  162. priList = append(priList, v)
  163. }
  164. }
  165. ret.PrivateList = priList
  166. }
  167. return
  168. }
  169. // AddGroup 新增ppt目录
  170. func AddGroup(groupName string, adminId int, isShare int8, isSharedAdd int8) (newId int64, err error) {
  171. item, err := models.GetPptGroupByName(groupName, adminId)
  172. if err != nil && !utils.IsErrNoRow(err) {
  173. err = errors.New("目录查询出错:" + err.Error())
  174. return
  175. }
  176. if item != nil && item.GroupId > 0 {
  177. err = errors.New("目录名称已存在,不可重复添加")
  178. return
  179. }
  180. groupInfo := &models.PptV2Group{
  181. GroupName: groupName,
  182. AdminId: adminId,
  183. IsShare: isShare,
  184. IsShareAdd: isSharedAdd,
  185. }
  186. if isShare == 1 {
  187. groupInfo.ShareTime = time.Now()
  188. }
  189. newId, err = models.AddPptGroup(groupInfo)
  190. if err != nil {
  191. err = errors.New("新增失败,Err:" + err.Error())
  192. return
  193. }
  194. groupInfo.GroupSort = newId
  195. groupInfo.GroupId = newId
  196. // 更新排序标识
  197. err = groupInfo.Update([]string{"group_sort"})
  198. if err != nil {
  199. err = errors.New("更新排序失败:" + err.Error())
  200. return
  201. }
  202. return
  203. }
  204. // AddGroupPptMapping 新增ppt和目录映射关系
  205. func AddGroupPptMapping(pptId int64, groupId int64, adminId int, adminRealName string) (newId int64, err error) {
  206. _, err = models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  207. if err != nil {
  208. if utils.IsErrNoRow(err) {
  209. err = errors.New("目录不存在")
  210. return
  211. }
  212. err = errors.New("目录查询出错:" + err.Error())
  213. return
  214. }
  215. bindInfo := &models.PptV2GroupMapping{
  216. GroupId: groupId,
  217. PptId: pptId,
  218. AdminId: adminId,
  219. AdminRealName: adminRealName,
  220. }
  221. newId, err = models.AddPptGroupMapping(bindInfo)
  222. if err != nil {
  223. err = errors.New("绑定目录失败:" + err.Error())
  224. return
  225. }
  226. bindInfo.GroupPptId = newId
  227. bindInfo.PptSort = newId
  228. err = bindInfo.Update([]string{"ppt_sort"})
  229. if err != nil {
  230. err = errors.New("更新排序失败:" + err.Error())
  231. return
  232. }
  233. return
  234. }
  235. // DelGroup 删除ppt 目录
  236. func DelGroup(groupId int64, adminId int) (err error) {
  237. _, err = models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  238. if err != nil {
  239. if utils.IsErrNoRow(err) {
  240. err = errors.New("目录不存在")
  241. return
  242. }
  243. err = errors.New("目录查询出错:" + err.Error())
  244. return
  245. }
  246. //查询是否有映射存在
  247. count, err := models.GetPptMappingCountByGroupId(groupId)
  248. if err != nil {
  249. err = errors.New("查询目录里的ppt个数出错:" + err.Error())
  250. return
  251. }
  252. if count > 0 {
  253. err = errors.New("该目录下有关联PPT,不允许删除")
  254. return
  255. }
  256. err = models.DeletePptGroup(groupId)
  257. if err != nil {
  258. err = errors.New("删除失败:" + err.Error())
  259. return
  260. }
  261. return
  262. }
  263. // ShareGroup 共享/取消共享目录
  264. func ShareGroup(groupId int64, adminId int) (respShare models.RespPptGroupShare, err error) {
  265. // 查询目录是否存在
  266. groupInfo, err := models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  267. if err != nil {
  268. if utils.IsErrNoRow(err) {
  269. err = errors.New("目录不存在")
  270. return
  271. }
  272. err = errors.New("目录查询出错:" + err.Error())
  273. return
  274. }
  275. // 判断是共享操作还是取消共享操作
  276. if groupInfo.IsShare == 1 {
  277. //取消共享
  278. groupInfo.IsShare = 0
  279. //groupInfo.ModifyTime = time.Now()
  280. err = groupInfo.Update([]string{"is_share"})
  281. if err != nil {
  282. err = errors.New("取消共享出错:" + err.Error())
  283. return
  284. }
  285. } else {
  286. //设置共享
  287. groupInfo.IsShare = 1
  288. groupInfo.ShareTime = time.Now()
  289. err = groupInfo.Update([]string{"is_share", "share_time"})
  290. if err != nil {
  291. err = errors.New("设置共享出错:" + err.Error())
  292. return
  293. }
  294. respShare.IsShare = 1
  295. }
  296. respShare.GroupId = groupId
  297. return
  298. }
  299. // CopyGroup 复制目录
  300. func CopyGroup(groupId int64, adminId int, adminRealName string) (err error) {
  301. //查询目录是否存在
  302. groupInfo, err := models.GetPptGroupByGroupId(groupId)
  303. if err != nil {
  304. if utils.IsErrNoRow(err) {
  305. err = errors.New("目录不存在")
  306. return
  307. }
  308. err = errors.New("目录查询出错:" + err.Error())
  309. return
  310. }
  311. //新增公共目录。目录名称在原来的基础上带上复制序号
  312. groupNames, err := models.GetPptGroupNamesByAdminId(adminId)
  313. if err != nil {
  314. err = errors.New("目录查询出错:" + err.Error())
  315. return
  316. }
  317. newGroupName := generateCopyName(groupInfo.GroupName, 1, groupNames)
  318. newGroupId, err := AddGroup(newGroupName, adminId, 0, 0)
  319. if err != nil {
  320. err = errors.New("复制目录出错:" + err.Error())
  321. return
  322. }
  323. //查询该目录下面是否存在ppt,如果存在则批量复制ppt到新目录下
  324. mappingList, err := models.GetPptMappingListByGroupId(groupId)
  325. if err != nil {
  326. err = errors.New("查询目录里的ppt列表出错:" + err.Error())
  327. return
  328. }
  329. if len(mappingList) <= 0 {
  330. return
  331. }
  332. pptIds := make([]int, 0)
  333. for _, v := range mappingList {
  334. pptIds = append(pptIds, int(v.PptId))
  335. }
  336. //批量查询ppt详情
  337. pptList, err := models.GetPptV2ByIds(pptIds)
  338. if err != nil {
  339. err = errors.New("查询ppt列表出错:" + err.Error())
  340. return
  341. }
  342. pptNames, err := models.GetAllPptTitle()
  343. if err != nil {
  344. err = errors.New("查询ppt标题出错:" + err.Error())
  345. return
  346. }
  347. //批量复制ppt,更新作者为当前账号,并返回新的pptID
  348. newPptList := make([]*models.PptV2, 0)
  349. for _, v := range pptList {
  350. if v.PptVersion != 2 { //只复制新版的ppt,旧版本的ppt忽略
  351. continue
  352. }
  353. tmp := &models.PptV2{
  354. TemplateType: v.TemplateType,
  355. BackgroundImg: v.BackgroundImg,
  356. Title: generateCopyName(v.Title, 1, pptNames),
  357. ReportType: v.ReportType,
  358. PptDate: v.PptDate,
  359. Content: v.Content,
  360. CoverContent: v.CoverContent,
  361. PptUrl: v.PptUrl,
  362. PptxUrl: v.PptxUrl,
  363. CreateTime: time.Now(),
  364. ModifyTime: time.Now(),
  365. AdminId: adminId,
  366. AdminRealName: adminRealName,
  367. PptVersion: v.PptVersion,
  368. TitleSetting: v.TitleSetting,
  369. }
  370. newPptList = append(newPptList, tmp)
  371. }
  372. if len(newPptList) > 0 {
  373. err = models.AddPptV2Multi(newPptList)
  374. if err != nil {
  375. err = errors.New("复制目录里的ppt出错:" + err.Error())
  376. return
  377. }
  378. newMappings := make([]*models.PptV2GroupMapping, 0)
  379. for _, v := range newPptList {
  380. tmp := &models.PptV2GroupMapping{
  381. GroupId: newGroupId,
  382. PptId: int64(v.PptId),
  383. CreateTime: time.Now(),
  384. ModifyTime: time.Now(),
  385. AdminId: adminId,
  386. AdminRealName: adminRealName,
  387. }
  388. newMappings = append(newMappings, tmp)
  389. }
  390. err = models.AddPptGroupMappingMulti(newMappings)
  391. if err != nil {
  392. err = errors.New("复制目录里的ppt出错:" + err.Error())
  393. return
  394. }
  395. //批量更新排序字段
  396. var newGroupPptIds []int64
  397. for _, v := range newMappings {
  398. newGroupPptIds = append(newGroupPptIds, v.GroupPptId)
  399. }
  400. err = models.UpdatePptGroupMappingSortMulti(newGroupPptIds)
  401. if err != nil {
  402. err = errors.New("更新排序标识出错:" + err.Error())
  403. return
  404. }
  405. }
  406. return
  407. }
  408. // RenameGroupName 目录重命名
  409. func RenameGroupName(groupId int64, groupName string, adminId int) (err error) {
  410. groupInfo, err := models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  411. if err != nil {
  412. if utils.IsErrNoRow(err) {
  413. err = errors.New("目录不存在")
  414. return
  415. }
  416. err = errors.New("目录查询出错:" + err.Error())
  417. return
  418. }
  419. if groupInfo.GroupName == groupName {
  420. err = errors.New("与原名字一致,无需修改")
  421. return
  422. }
  423. item, err := models.GetPptGroupByName(groupName, adminId)
  424. if err != nil && !utils.IsErrNoRow(err) {
  425. err = errors.New("目录查询出错:" + err.Error())
  426. return
  427. }
  428. if item != nil && item.GroupId > 0 && item.GroupId != groupId {
  429. err = errors.New("目录名称已存在,不可重复添加")
  430. return
  431. }
  432. //更新新名字
  433. groupInfo.GroupName = groupName
  434. err = groupInfo.Update([]string{"group_name"})
  435. if err != nil {
  436. err = errors.New("目录重命名失败" + err.Error())
  437. return
  438. }
  439. return
  440. }
  441. // ShareSingleGroupPpt 共享单个ppt/取消共享单个ppt,返回共享状态
  442. func ShareSingleGroupPpt(groupPptId int64, adminId int, adminRealName string) (ret models.RespPptShare, err error) {
  443. //判断当前登录者是否有共享的权限
  444. groupPpt, err := models.GetPptMappingByGroupPptId(groupPptId, adminId)
  445. if err != nil {
  446. if utils.IsErrNoRow(err) {
  447. err = errors.New("当前目录下的ppt不存在")
  448. return
  449. }
  450. err = errors.New("目录下的ppt查询出错:" + err.Error())
  451. return
  452. }
  453. groupInfo, err := models.GetPptGroupByGroupIdAdminId(groupPpt.GroupId, adminId)
  454. if err != nil {
  455. if utils.IsErrNoRow(err) {
  456. err = errors.New("目录不存在")
  457. return
  458. }
  459. err = errors.New("目录查询出错:" + err.Error())
  460. return
  461. }
  462. //判断当前的共享状态
  463. if groupPpt.ChildGroupPptId > 0 {
  464. err = CancelShareSingleGroupPpt(groupPpt, adminId)
  465. if err != nil {
  466. err = errors.New(err.Error())
  467. return
  468. }
  469. ret.IsSingleShare = 0
  470. } else {
  471. //如果是未共享状态,则共享该ppt,类似复制流程,并更新共享标识
  472. //新增公共目录。目录名称在原来的基础上带上复制序号
  473. groupNames, tErr := models.GetPptGroupNamesByAdminId(adminId)
  474. if tErr != nil {
  475. err = errors.New("目录查询出错:" + tErr.Error())
  476. return
  477. }
  478. newGroupName := generateCopyName(groupInfo.GroupName, 1, groupNames)
  479. newGroupId, tErr := AddGroup(newGroupName, adminId, 1, 1)
  480. if tErr != nil {
  481. err = errors.New(tErr.Error())
  482. return
  483. }
  484. //新增公共的目录和ppt之间的映射关系
  485. newGroupPptId, tErr := AddGroupPptMapping(groupPpt.PptId, newGroupId, adminId, adminRealName)
  486. if tErr != nil {
  487. err = errors.New(tErr.Error())
  488. return
  489. }
  490. //更新共享标识
  491. groupPpt.ChildGroupPptId = newGroupPptId
  492. err = groupPpt.Update([]string{"child_group_ppt_id"})
  493. if err != nil {
  494. err = errors.New("更新共享标识失败" + err.Error())
  495. return
  496. }
  497. ret.IsSingleShare = 1
  498. }
  499. ret.GroupPptId = groupPptId
  500. return
  501. }
  502. // GetGroupPptList 公共目录下的ppt列表或者单个目录里的ppt列表
  503. func GetGroupPptList(groupId int64, adminId int) (ret models.RespGroupPptList, err error) {
  504. var groupPptList []*models.PptV2GroupMapping
  505. var groups []*models.PptV2Group
  506. list := make([]*models.RespGroupPptListItem, 0)
  507. ret.List = list
  508. if groupId > 0 {
  509. //只查询组内的ppt列表
  510. //查询目录是否存在
  511. groupInfo, tErr := models.GetPptGroupByGroupId(groupId)
  512. if tErr != nil {
  513. if utils.IsErrNoRow(tErr) {
  514. err = errors.New("目录不存在")
  515. return
  516. }
  517. err = errors.New("目录查询出错:" + tErr.Error())
  518. return
  519. }
  520. groups = append(groups, groupInfo)
  521. groupPptList, tErr = models.GetPptMappingListByGroupId(groupId)
  522. if tErr != nil {
  523. err = errors.New("目录里的ppt查询出错:" + tErr.Error())
  524. return
  525. }
  526. } else {
  527. // 获取我的所有的ppt
  528. ret, err = GetMyPptList(adminId, ``)
  529. return
  530. ////查询所有公共目录下的ppt列表
  531. //var tErr error
  532. //groups, tErr = models.GetPublicPptGroups()
  533. //if tErr != nil {
  534. // err = errors.New("目录查询出错:" + tErr.Error())
  535. // return
  536. //}
  537. ////查询这些目录下的所有ppt
  538. //groupIds := make([]int64, 0)
  539. //for _, v := range groups {
  540. // groupIds = append(groupIds, v.GroupId)
  541. //}
  542. //
  543. //groupPptList, tErr = models.GetPptMappingListByGroupIds(groupIds)
  544. //if tErr != nil {
  545. // err = errors.New("目录里的ppt查询出错:" + tErr.Error())
  546. // return
  547. //}
  548. }
  549. if len(groupPptList) <= 0 {
  550. return
  551. }
  552. pptMap := make(map[int]*models.PptV2)
  553. groupMap := make(map[int64][]*models.PptV2GroupMapping)
  554. pptIds := make([]int, 0)
  555. for _, v := range groupPptList {
  556. pptIds = append(pptIds, int(v.PptId))
  557. groupMap[v.GroupId] = append(groupMap[v.GroupId], v)
  558. }
  559. if len(pptIds) == 0 {
  560. // 返回所有空目录
  561. return
  562. }
  563. pptList, err := models.GetPptV2ByIds(pptIds)
  564. if err != nil {
  565. err = errors.New("查询ppt详情出错:" + err.Error())
  566. return
  567. }
  568. for _, v := range pptList {
  569. if v.PptPage == 0 && v.Content != "" {
  570. var pptContent []services.PPTContent
  571. err = json.Unmarshal([]byte(v.Content), &pptContent)
  572. if err != nil {
  573. err = errors.New("解析ppt内容出错" + err.Error())
  574. return
  575. }
  576. v.PptPage = len(pptContent)
  577. }
  578. pptMap[v.PptId] = v
  579. }
  580. //按照排序顺序,依次放入ppt
  581. hasPpt := make(map[int]struct{})
  582. for _, v := range groups {
  583. if mapList, ok := groupMap[v.GroupId]; ok {
  584. if len(mapList) > 0 {
  585. for _, pptV := range mapList {
  586. pptInfo, ok1 := pptMap[int(pptV.PptId)]
  587. _, ok2 := hasPpt[int(pptV.PptId)]
  588. if ok1 && !ok2 {
  589. tmp := &models.RespGroupPptListItem{
  590. GroupPptId: pptV.GroupPptId,
  591. PptId: pptV.PptId,
  592. TemplateType: pptInfo.TemplateType,
  593. BackgroundImg: pptInfo.BackgroundImg,
  594. Title: pptInfo.Title,
  595. AdminId: pptV.AdminId,
  596. AdminRealName: pptV.AdminRealName,
  597. IsSingleShare: 0,
  598. PptCreateTime: pptInfo.CreateTime.Format(utils.FormatDateTime),
  599. PptModifyTime: pptInfo.ModifyTime.Format(utils.FormatDateTime),
  600. PptxUrl: pptInfo.PptxUrl,
  601. PptVersion: pptInfo.PptVersion,
  602. ReportId: pptInfo.ReportId,
  603. ReportCode: pptInfo.ReportCode,
  604. PublishTime: utils.DealDateTimeZero(pptInfo.PublishTime, utils.FormatDateTime),
  605. PptPage: pptInfo.PptPage,
  606. }
  607. if pptV.ChildGroupPptId > 0 {
  608. tmp.IsSingleShare = 1
  609. }
  610. list = append(list, tmp)
  611. hasPpt[pptInfo.PptId] = struct{}{}
  612. }
  613. }
  614. }
  615. }
  616. }
  617. ret.List = list
  618. if groupId <= 0 {
  619. sort.Sort(ret)
  620. }
  621. ret.Total = len(list)
  622. return
  623. }
  624. // MoveGroupPpt 移动ppt操作
  625. func MoveGroupPpt(groupId, groupPptId, prevGroupPptId, nextGroupPptId int64, adminId int) (err error) {
  626. //查询当前映射是否存在
  627. //判断当前登录者是否有共享的权限oo
  628. groupPpt, err := models.GetPptMappingByGroupPptId(groupPptId, adminId)
  629. if err != nil {
  630. if utils.IsErrNoRow(err) {
  631. err = errors.New("当前目录下的ppt不存在")
  632. return
  633. }
  634. err = errors.New("目录下的ppt查询出错:" + err.Error())
  635. return
  636. }
  637. var updateStr []string
  638. //如果更换了目录,默认当前排序值为0
  639. var currentSort, prevSort, nextSort int64
  640. //判断是否更换group
  641. if groupPpt.GroupId != groupId {
  642. _, err = models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  643. if err != nil {
  644. if utils.IsErrNoRow(err) {
  645. err = errors.New("目录不存在")
  646. return
  647. }
  648. err = errors.New("目录查询出错:" + err.Error())
  649. return
  650. }
  651. //判断是否需要解除当个ppt共享
  652. //解除共享操作
  653. err = CancelShareSingleGroupPpt(groupPpt, adminId)
  654. if err != nil {
  655. err = errors.New(err.Error())
  656. return
  657. }
  658. groupPpt.GroupId = groupId
  659. updateStr = append(updateStr, "group_id")
  660. }
  661. currentSort = groupPpt.PptSort
  662. var prevGroupPpt *models.PptV2GroupMapping
  663. var nextGroupPpt *models.PptV2GroupMapping
  664. if prevGroupPptId > 0 {
  665. prevGroupPpt, err = models.GetPptMappingByGroupPptId(prevGroupPptId, adminId)
  666. if err != nil {
  667. if utils.IsErrNoRow(err) {
  668. err = errors.New("目录下的ppt不存在")
  669. return
  670. }
  671. err = errors.New("目录下的ppt查询出错:" + err.Error())
  672. return
  673. }
  674. prevSort = prevGroupPpt.PptSort
  675. }
  676. if nextGroupPptId > 0 {
  677. nextGroupPpt, err = models.GetPptMappingByGroupPptId(nextGroupPptId, adminId)
  678. if err != nil {
  679. if utils.IsErrNoRow(err) {
  680. err = errors.New("目录下的ppt不存在")
  681. return
  682. }
  683. err = errors.New("目录下的ppt查询出错:" + err.Error())
  684. return
  685. }
  686. nextSort = nextGroupPpt.PptSort
  687. }
  688. updateStr = append(updateStr, "ppt_sort")
  689. //移到两个排序值中间操作
  690. if prevSort >= currentSort {
  691. //往下移动
  692. err = models.MoveDownGroupPptBySort(groupId, prevSort, currentSort)
  693. if err != nil {
  694. err = errors.New("向下移动ppt出错:" + err.Error())
  695. return
  696. }
  697. groupPpt.PptSort = prevSort
  698. } else if nextSort <= currentSort && nextSort != 0 {
  699. //往上移动
  700. err = models.MoveUpGroupPptBySort(groupId, nextSort, currentSort)
  701. if err != nil {
  702. err = errors.New("向上移动ppt出错:" + err.Error())
  703. return
  704. }
  705. groupPpt.PptSort = nextSort
  706. }
  707. //更新当前排序
  708. err = groupPpt.Update(updateStr)
  709. if err != nil {
  710. err = errors.New("移动ppt出错:" + err.Error())
  711. return
  712. }
  713. return
  714. }
  715. // MoveGroup 移动目录
  716. func MoveGroup(groupId, prevGroupId, nextGroupId int64, adminId int) (err error) {
  717. //查询目录是否存在
  718. groupInfo, err := models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  719. if err != nil {
  720. if utils.IsErrNoRow(err) {
  721. err = errors.New("目录不存在")
  722. return
  723. }
  724. err = errors.New("目录查询出错:" + err.Error())
  725. return
  726. }
  727. //如果更换了目录,默认当前排序值为0
  728. var currentSort, prevSort, nextSort int64
  729. currentSort = groupInfo.GroupSort
  730. var prevGroup *models.PptV2Group
  731. var nextGroup *models.PptV2Group
  732. if prevGroupId > 0 {
  733. prevGroup, err = models.GetPptGroupByGroupIdAdminId(prevGroupId, adminId)
  734. if err != nil {
  735. if utils.IsErrNoRow(err) {
  736. err = errors.New("目录不存在")
  737. return
  738. }
  739. err = errors.New("目录查询出错:" + err.Error())
  740. return
  741. }
  742. prevSort = prevGroup.GroupSort
  743. }
  744. if nextGroupId > 0 {
  745. nextGroup, err = models.GetPptGroupByGroupIdAdminId(nextGroupId, adminId)
  746. if err != nil {
  747. if utils.IsErrNoRow(err) {
  748. err = errors.New("目录不存在")
  749. return
  750. }
  751. err = errors.New("目录查询出错:" + err.Error())
  752. return
  753. }
  754. nextSort = nextGroup.GroupSort
  755. }
  756. //移到两个排序值中间操作
  757. if prevSort >= currentSort {
  758. //往下移动
  759. err = models.MoveDownGroupBySort(prevSort, currentSort)
  760. if err != nil {
  761. err = errors.New("向下移动ppt出错:" + err.Error())
  762. return
  763. }
  764. groupInfo.GroupSort = prevSort
  765. } else if nextSort <= currentSort && nextSort != 0 {
  766. //往上移动
  767. err = models.MoveUpGroupBySort(nextSort, currentSort)
  768. if err != nil {
  769. err = errors.New("向上移动ppt出错:" + err.Error())
  770. return
  771. }
  772. groupInfo.GroupSort = nextSort
  773. }
  774. //更新当前排序
  775. err = groupInfo.Update([]string{"group_sort"})
  776. if err != nil {
  777. err = errors.New("移动目录出错:" + err.Error())
  778. return
  779. }
  780. return
  781. }
  782. // CancelShareSingleGroupPpt 解除单个共享的ppt
  783. func CancelShareSingleGroupPpt(groupPpt *models.PptV2GroupMapping, adminId int) (err error) {
  784. if groupPpt.ChildGroupPptId <= 0 {
  785. return
  786. }
  787. //如果已经是共享状态,
  788. //判断当前登录者是否有取消共享的权限
  789. childGroupPpt, tErr := models.GetPptMappingByGroupPptId(groupPpt.ChildGroupPptId, adminId)
  790. if tErr != nil {
  791. if !utils.IsErrNoRow(tErr) {
  792. err = errors.New("目录下的ppt查询出错:" + tErr.Error())
  793. return
  794. }
  795. }
  796. if childGroupPpt != nil {
  797. //删除共享目录和ppt的映射关系
  798. err = models.DeletePptGroupMapping(childGroupPpt.GroupPptId, adminId)
  799. if err != nil {
  800. err = errors.New("删除共享目录下的ppt失败:" + err.Error())
  801. return
  802. }
  803. //删除共享出去的公共目录
  804. err = models.DeletePptGroup(childGroupPpt.GroupId)
  805. if err != nil {
  806. err = errors.New("删除共享目录失败:" + err.Error())
  807. return
  808. }
  809. }
  810. //更新共享状态为未共享,
  811. //更新共享标识
  812. groupPpt.ChildGroupPptId = 0
  813. err = groupPpt.Update([]string{"child_group_ppt_id"})
  814. if err != nil {
  815. err = errors.New("更新共享标识失败" + err.Error())
  816. return
  817. }
  818. return
  819. }
  820. // DeleteGroupPpt 删除ppt
  821. func DeleteGroupPpt(PptId int) (err error) {
  822. //查询该ppt的所有单个共享出去的目录信息
  823. groupPpts, err := models.GetGroupPptByPptId(PptId)
  824. if err != nil {
  825. err = errors.New("查询目录里的ppt失败" + err.Error())
  826. return
  827. }
  828. if len(groupPpts) <= 0 {
  829. return
  830. }
  831. //整理出需要删除的groupId
  832. groupPptMap := make(map[int64]*models.PptV2GroupMapping)
  833. for _, v := range groupPpts {
  834. groupPptMap[v.GroupPptId] = v
  835. }
  836. var delGroupIds string
  837. for _, v := range groupPpts {
  838. if v.ChildGroupPptId > 0 {
  839. if childGroup, ok := groupPptMap[v.ChildGroupPptId]; ok {
  840. delGroupIds += strconv.Itoa(int(childGroup.GroupId)) + ","
  841. }
  842. }
  843. }
  844. if delGroupIds != "" {
  845. delGroupIds = "(" + strings.Trim(delGroupIds, ",") + ")"
  846. err = models.DeletePptGroupByGroupIds(delGroupIds)
  847. if err != nil {
  848. err = errors.New("删除单个共享目录失败" + err.Error())
  849. return
  850. }
  851. }
  852. //再统一删除目录里相关的ppt
  853. err = models.DeletePptGroupMappingByPptId(PptId)
  854. if err != nil {
  855. err = errors.New("删除目录里的ppt失败" + err.Error())
  856. return
  857. }
  858. return
  859. }
  860. // CopyPpt 复制单个ppt,并移动到新的目录下面
  861. func CopyPpt(pptId int, groupId int64, adminId int, adminRealName string) (resp models.RespGroupPptNameListItem, err error) {
  862. //查询ppt详情
  863. pptInfo, err := models.GetPptV2ById(pptId)
  864. if err != nil {
  865. if utils.IsErrNoRow(err) {
  866. err = errors.New("ppt 不存在")
  867. return
  868. }
  869. err = errors.New("查询ppt失败" + err.Error())
  870. return
  871. }
  872. if pptInfo.PptVersion == 1 {
  873. err = errors.New("旧版本的ppt不允许复制")
  874. return
  875. }
  876. // 查询目录是否存在
  877. _, err = models.GetPptGroupByGroupIdAdminId(groupId, adminId)
  878. if err != nil {
  879. if utils.IsErrNoRow(err) {
  880. err = errors.New("目录不存在")
  881. return
  882. }
  883. err = errors.New("目录查询出错:" + err.Error())
  884. return
  885. }
  886. pptNames, err := models.GetAllPptTitle()
  887. if err != nil {
  888. err = errors.New("查询ppt标题出错:" + err.Error())
  889. return
  890. }
  891. //复制ppt,更新作者为当前账号,并返回新的pptID
  892. var newPptList []*models.PptV2
  893. newPpt := &models.PptV2{
  894. TemplateType: pptInfo.TemplateType,
  895. BackgroundImg: pptInfo.BackgroundImg,
  896. Title: generateCopyName(pptInfo.Title, 1, pptNames),
  897. ReportType: pptInfo.ReportType,
  898. PptDate: pptInfo.PptDate,
  899. Content: pptInfo.Content,
  900. CoverContent: pptInfo.CoverContent,
  901. PptUrl: pptInfo.PptUrl,
  902. PptxUrl: pptInfo.PptxUrl,
  903. CreateTime: time.Now(),
  904. ModifyTime: time.Now(),
  905. AdminId: adminId,
  906. AdminRealName: adminRealName,
  907. PptVersion: pptInfo.PptVersion,
  908. TitleSetting: pptInfo.TitleSetting,
  909. }
  910. newPptList = append(newPptList, newPpt)
  911. err = models.AddPptV2Multi(newPptList)
  912. if err != nil {
  913. err = errors.New("复制目录里的ppt出错:" + err.Error())
  914. return
  915. }
  916. var newMappings []*models.PptV2GroupMapping
  917. newGroupPpt := &models.PptV2GroupMapping{
  918. GroupId: groupId,
  919. PptId: int64(newPpt.PptId),
  920. CreateTime: time.Now(),
  921. ModifyTime: time.Now(),
  922. AdminId: adminId,
  923. AdminRealName: adminRealName,
  924. }
  925. newMappings = append(newMappings, newGroupPpt)
  926. err = models.AddPptGroupMappingMulti(newMappings)
  927. if err != nil {
  928. err = errors.New("复制目录里的ppt出错:" + err.Error())
  929. return
  930. }
  931. //批量更新排序字段
  932. err = models.UpdatePptGroupMappingSortMulti([]int64{newGroupPpt.GroupPptId})
  933. if err != nil {
  934. err = errors.New("更新排序标识出错:" + err.Error())
  935. return
  936. }
  937. pptPage := 0
  938. // 因之前并没有存储PPT页数字段,所以此处读取PPT内容的长度
  939. if newPpt.Content != "" {
  940. contents := make([]PageContent, 0)
  941. if e := json.Unmarshal([]byte(newPpt.Content), &contents); e != nil {
  942. err = errors.New(fmt.Sprintf("%d,解析PPT内容页数失败: %s", newPpt.PptId, e.Error()))
  943. return
  944. }
  945. pptPage = len(contents)
  946. }
  947. resp = models.RespGroupPptNameListItem{
  948. GroupPptId: newGroupPpt.GroupPptId,
  949. PptId: int64(newPpt.PptId),
  950. Title: newPpt.Title,
  951. AdminId: newPpt.AdminId,
  952. AdminRealName: newPpt.AdminRealName,
  953. PptVersion: newPpt.PptVersion,
  954. PptxUrl: newPpt.PptxUrl,
  955. ReportId: newPpt.ReportId,
  956. ReportCode: newPpt.ReportCode,
  957. PptCreateTime: newPpt.CreateTime.Format(utils.FormatDateTime),
  958. PptPage: pptPage,
  959. TitleSetting: newPpt.TitleSetting,
  960. }
  961. return
  962. }
  963. // generateCopyName 生成复制的目录名称
  964. func generateCopyName(originName string, count int, nameList []string) (newName string) {
  965. newName = originName + "(" + strconv.Itoa(count) + ")"
  966. for _, v := range nameList {
  967. if v == newName {
  968. count++
  969. newName = generateCopyName(originName, count, nameList)
  970. return
  971. }
  972. }
  973. return
  974. }
  975. // SearchGroupPpt 根据ppt标题搜索ppt
  976. func SearchGroupPpt(keyWord string) (ret models.RespSearchGroupPptList, err error) {
  977. //组装group ppt
  978. list := make([]*models.RespSearchGroupPptListItem, 0)
  979. ret.List = list
  980. reqKeyword := "%" + keyWord + "%"
  981. condition := " and title like ? "
  982. var pars []interface{}
  983. pars = append(pars, reqKeyword)
  984. pptList, err := models.GetPptV2ByCondition(condition, pars)
  985. if err != nil {
  986. err = errors.New("查询ppt列表出错:" + err.Error())
  987. return
  988. }
  989. if len(pptList) == 0 {
  990. return
  991. }
  992. pptIds := make([]string, 0)
  993. pptMap := make(map[int]*models.PptV2)
  994. for _, v := range pptList {
  995. pptIds = append(pptIds, strconv.Itoa(v.PptId))
  996. pptMap[v.PptId] = v
  997. }
  998. groupPptList, err := models.GetPublicGroupPptByPptIds(pptIds)
  999. if err != nil {
  1000. err = errors.New("查询目录里的ppt列表出错:" + err.Error())
  1001. return
  1002. }
  1003. for _, v := range groupPptList {
  1004. tmp := new(models.RespSearchGroupPptListItem)
  1005. tmp.GroupPptId = v.GroupPptId
  1006. tmp.PptId = v.PptId
  1007. if i, ok := pptMap[int(v.PptId)]; ok {
  1008. tmp.Title = i.Title
  1009. }
  1010. list = append(list, tmp)
  1011. }
  1012. ret.List = list
  1013. return
  1014. }
  1015. // InitPptGroup 初始化目录分组
  1016. func InitPptGroup() (err error) {
  1017. //查询所有的ppt
  1018. now := time.Now()
  1019. pptList, err := models.GetPptV2ByCondition("", []interface{}{})
  1020. if err != nil {
  1021. errors.New("查询所有的ppt出错" + err.Error())
  1022. return
  1023. }
  1024. pptAdminMap := make(map[int]string, 0)
  1025. adminPptListMap := make(map[int][]*models.PptV2)
  1026. oldPptAdminMap := make(map[int]string, 0)
  1027. oldAdminPptListMap := make(map[int][]*models.PptV2)
  1028. //查询所有的ppt作者
  1029. for _, v := range pptList {
  1030. if v.PptVersion == 2 {
  1031. if _, ok := pptAdminMap[v.AdminId]; !ok {
  1032. pptAdminMap[v.AdminId] = v.AdminRealName
  1033. }
  1034. adminPptListMap[v.AdminId] = append(adminPptListMap[v.AdminId], v)
  1035. } else {
  1036. if _, ok := oldPptAdminMap[v.AdminId]; !ok {
  1037. oldPptAdminMap[v.AdminId] = v.AdminRealName
  1038. }
  1039. oldAdminPptListMap[v.AdminId] = append(oldAdminPptListMap[v.AdminId], v)
  1040. }
  1041. }
  1042. //批量生成历史目录,共享目录
  1043. newOldGroupList := make([]*models.PptV2Group, 0)
  1044. //批量生成目录,共享目录
  1045. newGroupList := make([]*models.PptV2Group, 0)
  1046. if len(pptAdminMap) > 0 {
  1047. for k, v := range pptAdminMap {
  1048. tmp := &models.PptV2Group{
  1049. GroupName: v + "的PPT",
  1050. AdminId: k,
  1051. IsShare: 1,
  1052. CreateTime: now,
  1053. ModifyTime: now,
  1054. ShareTime: now,
  1055. }
  1056. newGroupList = append(newGroupList, tmp)
  1057. }
  1058. //批量把对应的ppt放到目录当中
  1059. err = models.AddPptGroupMulti(newGroupList)
  1060. if err != nil {
  1061. err = errors.New("创建目录出错:" + err.Error())
  1062. return
  1063. }
  1064. }
  1065. if len(oldPptAdminMap) > 0 {
  1066. for k, v := range oldPptAdminMap {
  1067. tmp := &models.PptV2Group{
  1068. GroupName: v + "的历史PPT",
  1069. AdminId: k,
  1070. IsShare: 1,
  1071. CreateTime: now,
  1072. ModifyTime: now,
  1073. ShareTime: now,
  1074. }
  1075. newOldGroupList = append(newOldGroupList, tmp)
  1076. }
  1077. //批量把对应的ppt放到目录当中
  1078. err = models.AddPptGroupMulti(newOldGroupList)
  1079. if err != nil {
  1080. err = errors.New("创建目录出错:" + err.Error())
  1081. return
  1082. }
  1083. }
  1084. //批量更新排序字段
  1085. var newGroupIds []int64
  1086. var newMappings []*models.PptV2GroupMapping
  1087. for _, v := range newGroupList {
  1088. newGroupIds = append(newGroupIds, v.GroupId)
  1089. if ppts, ok := adminPptListMap[v.AdminId]; ok {
  1090. for _, p := range ppts {
  1091. tmp := &models.PptV2GroupMapping{
  1092. GroupId: v.GroupId,
  1093. PptId: int64(p.PptId),
  1094. CreateTime: now,
  1095. ModifyTime: now,
  1096. AdminId: p.AdminId,
  1097. AdminRealName: p.AdminRealName,
  1098. }
  1099. newMappings = append(newMappings, tmp)
  1100. }
  1101. }
  1102. }
  1103. for _, v := range newOldGroupList {
  1104. newGroupIds = append(newGroupIds, v.GroupId)
  1105. if oldPpts, ok1 := oldAdminPptListMap[v.AdminId]; ok1 {
  1106. for _, p := range oldPpts {
  1107. tmp := &models.PptV2GroupMapping{
  1108. GroupId: v.GroupId,
  1109. PptId: int64(p.PptId),
  1110. CreateTime: now,
  1111. ModifyTime: now,
  1112. AdminId: p.AdminId,
  1113. AdminRealName: p.AdminRealName,
  1114. }
  1115. newMappings = append(newMappings, tmp)
  1116. }
  1117. }
  1118. }
  1119. err = models.UpdatePptGroupSortMulti(newGroupIds)
  1120. if err != nil {
  1121. err = errors.New("更新目录排序标识出错:" + err.Error())
  1122. return
  1123. }
  1124. err = models.AddPptGroupMappingMulti(newMappings)
  1125. if err != nil {
  1126. err = errors.New("创建目录里的ppt出错:" + err.Error())
  1127. return
  1128. }
  1129. //批量更新排序字段
  1130. var newGroupPptIds []int64
  1131. for _, v := range newMappings {
  1132. newGroupPptIds = append(newGroupPptIds, v.GroupPptId)
  1133. }
  1134. err = models.UpdatePptGroupMappingSortMulti(newGroupPptIds)
  1135. if err != nil {
  1136. err = errors.New("更新排序标识出错:" + err.Error())
  1137. return
  1138. }
  1139. return
  1140. }
  1141. // GetGroupsByAdminIdV2 查询ppt目录列表
  1142. // @Author roc
  1143. // @Time 2022-08-29 15:22:20
  1144. func GetGroupsByAdminIdV2(IsNewPpt, adminId int, lang string) (ret models.RespGroupList, err error) {
  1145. myPptList := make([]*models.RespGroupPptNameListItem, 0)
  1146. otherPptList := make([]*models.RespGroupPptNameListItem, 0)
  1147. grantList := []models.RespGroupListItem{}
  1148. if lang == utils.EnLangVersion {
  1149. grantList = append(grantList, []models.RespGroupListItem{
  1150. {
  1151. GroupId: 1,
  1152. GroupName: "My shared",
  1153. PptList: myPptList,
  1154. },
  1155. {
  1156. GroupId: 2,
  1157. GroupName: "Received shared",
  1158. PptList: otherPptList,
  1159. },
  1160. }...)
  1161. } else {
  1162. grantList = append(grantList, []models.RespGroupListItem{
  1163. {
  1164. GroupId: 1,
  1165. GroupName: "我共享的",
  1166. PptList: myPptList,
  1167. },
  1168. {
  1169. GroupId: 2,
  1170. GroupName: "收到共享",
  1171. PptList: otherPptList,
  1172. },
  1173. }...)
  1174. }
  1175. ret.PublicList = make([]*models.RespGroupListItem, 0)
  1176. ret.PrivateList = make([]*models.RespGroupListItem, 0)
  1177. ret.GrantList = grantList
  1178. pptMap := make(map[int]*models.PptV2)
  1179. groupMap := make(map[int64][]*models.RespGroupPptNameListItem)
  1180. groupHasNewPptMap := make(map[int64]struct{})
  1181. pptIds := make([]int, 0)
  1182. // 获取我的ppt分组
  1183. privateGroups, err := models.GetPrivatePptGroupsByAdminId(adminId)
  1184. if err != nil {
  1185. err = errors.New("私有目录查询出错:" + err.Error())
  1186. return
  1187. }
  1188. groupIds := make([]int64, 0)
  1189. for _, v := range privateGroups {
  1190. groupIds = append(groupIds, v.GroupId)
  1191. }
  1192. var pptMappings []*models.PptV2GroupMapping
  1193. // 如果没有分组,那么直接返回
  1194. if len(groupIds) > 0 {
  1195. // 遍历分组并拼接
  1196. for _, v := range privateGroups {
  1197. tmp := new(models.RespGroupListItem)
  1198. tmp.GroupId = v.GroupId
  1199. tmp.GroupName = v.GroupName
  1200. tmp.IsShare = v.IsShare
  1201. tmp.AdminId = v.AdminId
  1202. ret.PrivateList = append(ret.PrivateList, tmp)
  1203. }
  1204. // 通过分组id获取相关的ppt信息,主要是为了获取所有的ppt_id字段
  1205. pptMappings, err = models.GetPptMappingListByGroupIds(groupIds)
  1206. if err != nil {
  1207. err = errors.New("查询目录里的ppt出错:" + err.Error())
  1208. return
  1209. }
  1210. for _, v := range pptMappings {
  1211. pptIds = append(pptIds, int(v.PptId))
  1212. }
  1213. }
  1214. adminIdList := make([]int, 0) //需要查询的创建人admin_id列表集合
  1215. adminIdMap := make(map[int]int) //需要查询的创建人admin_id集合,用来去重的,避免重复id
  1216. // grantList 已经分配权限的ppt
  1217. grantPptList, err := models.GetAllGrantList(adminId)
  1218. for _, v := range grantPptList {
  1219. pptIds = append(pptIds, v.PptId)
  1220. if _, ok := adminIdMap[v.AdminId]; !ok {
  1221. adminIdList = append(adminIdList, v.AdminId) //需要查询的创建人admin_id列表集合
  1222. adminIdMap[v.AdminId] = v.AdminId //需要查询的创建人admin_id集合,用来去重的,避免重复id
  1223. }
  1224. }
  1225. if len(pptIds) > 0 {
  1226. // 通过ppt_id列表字段获取所有的ppt信息
  1227. pptList, tmpErr := models.GetPptV2ByIds(pptIds)
  1228. if tmpErr != nil {
  1229. err = errors.New("查询ppt详情出错:" + err.Error())
  1230. return
  1231. }
  1232. for _, v := range pptList {
  1233. pptMap[v.PptId] = v
  1234. }
  1235. }
  1236. // 私有的Ppt列表
  1237. {
  1238. //组装group ppt
  1239. for _, v := range pptMappings {
  1240. i, ok := pptMap[int(v.PptId)]
  1241. if !ok { //找不到ppt,还干个啥,直接退出当前循环啊
  1242. continue
  1243. }
  1244. if IsNewPpt == 1 && i.PptVersion != 2 { //都说了只要新版ppt,你一个不是新版ppt的,凑啥热闹,靠边站去,直接退出当前循环啊
  1245. continue
  1246. }
  1247. pptPage := 0
  1248. // 因之前并没有存储PPT页数字段,所以此处读取PPT内容的长度
  1249. if i.Content != "" {
  1250. contents := make([]PageContent, 0)
  1251. if e := json.Unmarshal([]byte(i.Content), &contents); e != nil {
  1252. err = errors.New(fmt.Sprintf("%d,解析PPT内容页数失败: %s", i.PptId, e.Error()))
  1253. return
  1254. }
  1255. pptPage = len(contents)
  1256. }
  1257. tmp := &models.RespGroupPptNameListItem{
  1258. AdminId: v.AdminId,
  1259. GroupPptId: v.GroupPptId,
  1260. PptId: v.PptId,
  1261. AdminRealName: v.AdminRealName,
  1262. Title: i.Title,
  1263. PptVersion: i.PptVersion,
  1264. IsSingleShare: i.IsShare,
  1265. PptxUrl: i.PptxUrl,
  1266. ReportId: i.ReportId,
  1267. ReportCode: i.ReportCode,
  1268. PptCreateTime: i.CreateTime.Format(utils.FormatDateTime),
  1269. PptModifyTime: i.ModifyTime.Format(utils.FormatDateTime),
  1270. PublishTime: utils.DealDateTimeZero(i.PublishTime, utils.FormatDateTime),
  1271. PptPage: pptPage,
  1272. }
  1273. if tmp.PptVersion == 2 {
  1274. groupHasNewPptMap[v.GroupId] = struct{}{}
  1275. }
  1276. groupMap[v.GroupId] = append(groupMap[v.GroupId], tmp)
  1277. }
  1278. for k, v := range ret.PrivateList {
  1279. if pptL, ok := groupMap[v.GroupId]; ok {
  1280. ret.PrivateList[k].PptList = pptL
  1281. if _, ok1 := groupHasNewPptMap[v.GroupId]; !ok1 && len(pptL) > 0 {
  1282. ret.PrivateList[k].OnlyOld = true
  1283. }
  1284. }
  1285. }
  1286. }
  1287. publicAdminIdList := make([]int, 0)
  1288. publicPptListMap := make(map[int][]*models.RespGroupPptNameListItem)
  1289. // 获取公开分享的ppt
  1290. sharePptList, err := models.GetSharePptV2(IsNewPpt)
  1291. for _, v := range sharePptList {
  1292. publicPptList, ok := publicPptListMap[v.AdminId]
  1293. if !ok {
  1294. publicPptList = make([]*models.RespGroupPptNameListItem, 0)
  1295. publicAdminIdList = append(publicAdminIdList, v.AdminId)
  1296. // 需要查询的创建人信息
  1297. if _, ok := adminIdMap[v.AdminId]; !ok {
  1298. adminIdList = append(adminIdList, v.AdminId) //需要查询的创建人admin_id列表集合
  1299. adminIdMap[v.AdminId] = v.AdminId //需要查询的创建人admin_id集合,用来去重的,避免重复id
  1300. }
  1301. }
  1302. contents := make([]PageContent, 0)
  1303. if e := json.Unmarshal([]byte(v.Content), &contents); e != nil {
  1304. err = errors.New("解析PPT内容页数失败: " + e.Error())
  1305. return
  1306. }
  1307. pptPage := len(contents)
  1308. tmpV := &models.RespGroupPptNameListItem{
  1309. GroupPptId: int64(v.PptId),
  1310. PptId: int64(v.PptId),
  1311. Title: v.Title,
  1312. AdminId: v.AdminId,
  1313. AdminRealName: v.AdminRealName,
  1314. PptVersion: v.PptVersion,
  1315. IsSingleShare: v.IsShare,
  1316. PptxUrl: v.PptxUrl,
  1317. ReportId: v.ReportId,
  1318. ReportCode: v.ReportCode,
  1319. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1320. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1321. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1322. PptPage: pptPage,
  1323. }
  1324. publicPptList = append(publicPptList, tmpV)
  1325. publicPptListMap[v.AdminId] = publicPptList
  1326. }
  1327. // 创建人信息
  1328. systemAdminMap := make(map[int]*system.Admin)
  1329. systemAdminList, err := system.GetAdminListByIdList(adminIdList)
  1330. if err != nil {
  1331. return
  1332. }
  1333. for _, v := range systemAdminList {
  1334. systemAdminMap[v.AdminId] = v
  1335. }
  1336. // 公开分享的用户列表
  1337. {
  1338. for _, v := range publicAdminIdList {
  1339. systemAdmin, ok := systemAdminMap[v]
  1340. if !ok {
  1341. continue
  1342. }
  1343. // ppt 列表信息
  1344. respGroupPptNameListItemList, ok := publicPptListMap[v]
  1345. if !ok {
  1346. respGroupPptNameListItemList = make([]*models.RespGroupPptNameListItem, 0)
  1347. }
  1348. // ppt 分组信息
  1349. tmpRespGroupListItem := &models.RespGroupListItem{
  1350. GroupId: int64(systemAdmin.AdminId),
  1351. GroupName: systemAdmin.RealName + "的PPT",
  1352. AdminId: systemAdmin.AdminId,
  1353. IsShare: 1,
  1354. OnlyOld: false,
  1355. PptList: respGroupPptNameListItemList,
  1356. }
  1357. ret.PublicList = append(ret.PublicList, tmpRespGroupListItem)
  1358. }
  1359. }
  1360. myGrantPPtIdMap := make(map[int]int) //我分配的ppt的id集合
  1361. // 共享Ppt
  1362. {
  1363. for _, v := range grantPptList {
  1364. pptPage := 0
  1365. // 因之前并没有存储PPT页数字段,所以此处读取PPT内容的长度
  1366. if v.Content != "" {
  1367. contents := make([]PageContent, 0)
  1368. if e := json.Unmarshal([]byte(v.Content), &contents); e != nil {
  1369. err = errors.New("解析PPT内容页数失败: " + e.Error())
  1370. return
  1371. }
  1372. }
  1373. title := v.Title
  1374. if adminInfo, ok := systemAdminMap[v.AdminId]; ok {
  1375. title = adminInfo.RealName + "———" + title
  1376. }
  1377. tmp := &models.RespGroupPptNameListItem{
  1378. AdminId: v.AdminId,
  1379. //GroupPptId: v.GroupPptId,
  1380. PptId: int64(v.PptId),
  1381. AdminRealName: v.AdminRealName,
  1382. Title: title,
  1383. PptVersion: v.PptVersion,
  1384. IsSingleShare: v.IsShare,
  1385. PptxUrl: v.PptxUrl,
  1386. ReportId: v.ReportId,
  1387. ReportCode: v.ReportCode,
  1388. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1389. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1390. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1391. PptPage: pptPage,
  1392. }
  1393. //如果只展示新版ppt,则过滤旧版的Ppt
  1394. if IsNewPpt == 1 && v.PptVersion == 1 {
  1395. continue
  1396. }
  1397. if v.AdminId == adminId {
  1398. tmp.IsGrant = 1
  1399. myPptList = append(myPptList, tmp)
  1400. myGrantPPtIdMap[v.PptId] = v.PptId
  1401. } else {
  1402. tmp.IsReceived = 1
  1403. otherPptList = append(otherPptList, tmp)
  1404. }
  1405. }
  1406. grantList[0].PptList = myPptList
  1407. grantList[1].PptList = otherPptList
  1408. ret.GrantList = grantList
  1409. }
  1410. // 处理公共ppt里面的关于自个的ppt是否有配置权限的字段数据变更
  1411. for k, publicList := range ret.PublicList {
  1412. for kk, pptInfo := range publicList.PptList {
  1413. // 是否有过权限配置
  1414. if _, ok := myGrantPPtIdMap[int(pptInfo.PptId)]; ok {
  1415. pptInfo.IsGrant = 1
  1416. }
  1417. publicList.PptList[kk] = pptInfo
  1418. }
  1419. ret.PublicList[k] = publicList
  1420. }
  1421. for k, privateList := range ret.PrivateList {
  1422. for kk, pptInfo := range privateList.PptList {
  1423. // 是否有过权限配置
  1424. if _, ok := myGrantPPtIdMap[int(pptInfo.PptId)]; ok {
  1425. pptInfo.IsGrant = 1
  1426. }
  1427. privateList.PptList[kk] = pptInfo
  1428. }
  1429. ret.PrivateList[k] = privateList
  1430. }
  1431. //如果只展示新版ppt,则过滤空文件夹
  1432. if IsNewPpt == 1 {
  1433. //公共ppt
  1434. pubList := make([]*models.RespGroupListItem, 0)
  1435. for _, v := range ret.PublicList {
  1436. if len(v.PptList) > 0 {
  1437. pubList = append(pubList, v)
  1438. }
  1439. }
  1440. ret.PublicList = pubList
  1441. // 私有ppt
  1442. priList := make([]*models.RespGroupListItem, 0)
  1443. for _, v := range ret.PrivateList {
  1444. if len(v.PptList) > 0 {
  1445. priList = append(priList, v)
  1446. }
  1447. }
  1448. ret.PrivateList = priList
  1449. }
  1450. return
  1451. }
  1452. // ShareSingleGroupPptV2 共享单个ppt/取消共享单个ppt,返回共享状态
  1453. // @Author roc
  1454. // @Time 2022-08-29 15:22:20
  1455. func ShareSingleGroupPptV2(pptId int, adminId int) (pptInfo *models.PptV2, err error) {
  1456. //判断当前登录者是否有共享的权限
  1457. pptInfo, err = models.GetPptV2ById(pptId)
  1458. if err != nil {
  1459. if utils.IsErrNoRow(err) {
  1460. err = errors.New("当前目录下的ppt不存在")
  1461. return
  1462. }
  1463. err = errors.New("目录下的ppt查询出错:" + err.Error())
  1464. return
  1465. }
  1466. if pptInfo.AdminId != adminId {
  1467. err = errors.New("该Ppt不是本人创建")
  1468. return
  1469. }
  1470. //判断当前的共享状态
  1471. if pptInfo.IsShare > 0 {
  1472. pptInfo.IsShare = 0
  1473. err = pptInfo.Update([]string{"IsShare"})
  1474. if err != nil {
  1475. err = errors.New(err.Error())
  1476. return
  1477. }
  1478. } else {
  1479. pptInfo.IsShare = 1
  1480. err = pptInfo.Update([]string{"IsShare"})
  1481. if err != nil {
  1482. err = errors.New(err.Error())
  1483. return
  1484. }
  1485. }
  1486. return
  1487. }
  1488. // GetMyPptList 我的ppt列表
  1489. // @Author roc
  1490. // @Time 2022-09-05 17:26:21
  1491. func GetMyPptList(adminId int, keyword string) (ret models.RespGroupPptList, err error) {
  1492. list := make([]*models.RespGroupPptListItem, 0)
  1493. ret.List = list
  1494. var condition string
  1495. var pars []interface{}
  1496. condition += ` AND admin_id=? `
  1497. pars = append(pars, adminId)
  1498. if keyword != `` {
  1499. condition += ` AND (title LIKE ? OR admin_real_name LIKE ? ) `
  1500. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  1501. }
  1502. pptList, err := models.GetAllPptV2List(condition, pars)
  1503. if len(pptList) <= 0 {
  1504. return
  1505. }
  1506. var pptContent []services.PPTContent
  1507. for _, v := range pptList {
  1508. if v.PptPage == 0 && v.Content != "" {
  1509. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1510. if err != nil {
  1511. return
  1512. }
  1513. v.PptPage = len(pptContent)
  1514. }
  1515. tmpV := &models.RespGroupPptListItem{
  1516. GroupPptId: int64(v.PptId),
  1517. PptId: int64(v.PptId),
  1518. TemplateType: v.TemplateType,
  1519. BackgroundImg: v.BackgroundImg,
  1520. Title: v.Title,
  1521. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1522. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1523. AdminId: v.AdminId,
  1524. AdminRealName: v.AdminRealName,
  1525. PptVersion: v.PptVersion,
  1526. IsSingleShare: v.IsShare,
  1527. PptxUrl: v.PptxUrl,
  1528. ReportId: v.ReportId,
  1529. ReportCode: v.ReportCode,
  1530. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1531. PptPage: v.PptPage,
  1532. }
  1533. list = append(list, tmpV)
  1534. }
  1535. ret.List = list
  1536. ret.Total = len(list)
  1537. return
  1538. }
  1539. // GetSharePptList 公共目录下的ppt列表
  1540. // @Author roc
  1541. // @Time 2022-08-29 16:27:59
  1542. func GetSharePptList(adminId int, keyword string, isPrivate bool) (ret models.RespGroupPptList, err error) {
  1543. list := make([]*models.RespGroupPptListItem, 0)
  1544. ret.List = list
  1545. var condition string
  1546. var pars []interface{}
  1547. // 公开的ppt
  1548. condition += ` AND is_share=? `
  1549. if isPrivate {
  1550. pars = append(pars, 0)
  1551. } else {
  1552. pars = append(pars, 1)
  1553. }
  1554. if adminId > 0 {
  1555. condition += ` AND admin_id=? `
  1556. pars = append(pars, adminId)
  1557. }
  1558. if keyword != `` {
  1559. condition += ` AND (title LIKE ? OR admin_real_name LIKE ? ) `
  1560. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  1561. }
  1562. pptList, err := models.GetAllPptV2List(condition, pars)
  1563. if len(pptList) <= 0 {
  1564. return
  1565. }
  1566. var pptContent []services.PPTContent
  1567. for _, v := range pptList {
  1568. if v.PptPage == 0 {
  1569. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1570. if err != nil {
  1571. return
  1572. }
  1573. v.PptPage = len(pptContent)
  1574. }
  1575. tmpV := &models.RespGroupPptListItem{
  1576. GroupPptId: int64(v.PptId),
  1577. PptId: int64(v.PptId),
  1578. TemplateType: v.TemplateType,
  1579. BackgroundImg: v.BackgroundImg,
  1580. Title: v.Title,
  1581. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1582. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1583. AdminId: v.AdminId,
  1584. AdminRealName: v.AdminRealName,
  1585. PptVersion: v.PptVersion,
  1586. IsSingleShare: v.IsShare,
  1587. PptxUrl: v.PptxUrl,
  1588. ReportId: v.ReportId,
  1589. ReportCode: v.ReportCode,
  1590. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1591. PptPage: v.PptPage,
  1592. }
  1593. list = append(list, tmpV)
  1594. }
  1595. ret.List = list
  1596. ret.Total = len(list)
  1597. return
  1598. }
  1599. // GetGrantPptList 公共目录下的ppt列表
  1600. // @Author roc
  1601. // @Time 2022-09-05 15:50:25
  1602. func GetGrantPptList(adminId int, keyword, sourceType string) (ret models.RespGroupPptList, err error) {
  1603. list := make([]*models.RespGroupPptListItem, 0)
  1604. ret.List = list
  1605. var condition string
  1606. var pars []interface{}
  1607. switch sourceType {
  1608. case "my":
  1609. condition += ` AND a.admin_id = ? `
  1610. pars = append(pars, adminId)
  1611. case "other":
  1612. condition += ` AND a.admin_id != ? AND (b.department_id = 1 OR b.grant_admin_id = ?) `
  1613. pars = append(pars, adminId, adminId)
  1614. default:
  1615. err = errors.New("无效的来源")
  1616. return
  1617. }
  1618. if keyword != `` {
  1619. condition += ` AND a.title LIKE ? `
  1620. pars = utils.GetLikeKeywordPars(pars, keyword, 1)
  1621. }
  1622. pptList, err := models.GetGrantList(condition, pars)
  1623. if err != nil {
  1624. return
  1625. }
  1626. if len(pptList) <= 0 {
  1627. return
  1628. }
  1629. var pptContent []services.PPTContent
  1630. for _, v := range pptList {
  1631. if v.PptPage == 0 {
  1632. if v.Content != `` {
  1633. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1634. if err != nil {
  1635. return
  1636. }
  1637. }
  1638. v.PptPage = len(pptContent)
  1639. }
  1640. tmpV := &models.RespGroupPptListItem{
  1641. GroupPptId: int64(v.PptId),
  1642. PptId: int64(v.PptId),
  1643. TemplateType: v.TemplateType,
  1644. BackgroundImg: v.BackgroundImg,
  1645. Title: v.Title,
  1646. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1647. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1648. AdminId: v.AdminId,
  1649. AdminRealName: v.AdminRealName,
  1650. PptVersion: v.PptVersion,
  1651. IsSingleShare: v.IsShare,
  1652. PptxUrl: v.PptxUrl,
  1653. ReportId: v.ReportId,
  1654. ReportCode: v.ReportCode,
  1655. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1656. PptPage: v.PptPage,
  1657. }
  1658. list = append(list, tmpV)
  1659. }
  1660. ret.List = list
  1661. ret.Total = len(list)
  1662. return
  1663. }
  1664. // SearchPptList PPT搜索(我的/公开PPT)
  1665. func SearchPptList(adminId int, keyword string) (ret models.RespGroupPptList, err error) {
  1666. list := make([]*models.RespGroupPptListItem, 0)
  1667. ret.List = list
  1668. var condition string
  1669. var pars []interface{}
  1670. // 公开的PPT或是我的非公开PPT
  1671. condition += ` AND (is_share = 1 OR (admin_id = ? AND is_share = 0)) `
  1672. pars = append(pars, adminId)
  1673. if keyword != `` {
  1674. kw := fmt.Sprint("%", keyword, "%")
  1675. condition += ` AND (title LIKE ? OR admin_real_name LIKE ? ) `
  1676. pars = append(pars, kw, kw)
  1677. }
  1678. pptList, err := models.GetAllPptV2List(condition, pars)
  1679. if len(pptList) <= 0 {
  1680. return
  1681. }
  1682. var pptContent []services.PPTContent
  1683. for _, v := range pptList {
  1684. if v.PptPage == 0 {
  1685. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1686. if err != nil {
  1687. return
  1688. }
  1689. v.PptPage = len(pptContent)
  1690. }
  1691. tmpV := &models.RespGroupPptListItem{
  1692. GroupPptId: int64(v.PptId),
  1693. PptId: int64(v.PptId),
  1694. TemplateType: v.TemplateType,
  1695. BackgroundImg: v.BackgroundImg,
  1696. Title: v.Title,
  1697. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1698. AdminId: v.AdminId,
  1699. AdminRealName: v.AdminRealName,
  1700. PptVersion: v.PptVersion,
  1701. IsSingleShare: v.IsShare,
  1702. PptxUrl: v.PptxUrl,
  1703. ReportId: v.ReportId,
  1704. ReportCode: v.ReportCode,
  1705. PptPage: v.PptPage,
  1706. }
  1707. list = append(list, tmpV)
  1708. }
  1709. ret.List = list
  1710. ret.Total = len(list)
  1711. return
  1712. }