ppt_group.go 50 KB

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