ppt_group.go 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817
  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 && err.Error() != utils.ErrNoRow() {
  173. err = errors.New("目录查询出错:" + err.Error())
  174. return
  175. }
  176. if item != nil {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 && err.Error() != utils.ErrNoRow() {
  425. err = errors.New("目录查询出错:" + err.Error())
  426. return
  427. }
  428. if item != nil {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 tErr.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 tErr.Error() != utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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 err.Error() == utils.ErrNoRow() {
  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. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1633. if err != nil {
  1634. return
  1635. }
  1636. v.PptPage = len(pptContent)
  1637. }
  1638. tmpV := &models.RespGroupPptListItem{
  1639. GroupPptId: int64(v.PptId),
  1640. PptId: int64(v.PptId),
  1641. TemplateType: v.TemplateType,
  1642. BackgroundImg: v.BackgroundImg,
  1643. Title: v.Title,
  1644. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1645. PptModifyTime: v.ModifyTime.Format(utils.FormatDateTime),
  1646. AdminId: v.AdminId,
  1647. AdminRealName: v.AdminRealName,
  1648. PptVersion: v.PptVersion,
  1649. IsSingleShare: v.IsShare,
  1650. PptxUrl: v.PptxUrl,
  1651. ReportId: v.ReportId,
  1652. ReportCode: v.ReportCode,
  1653. PublishTime: utils.DealDateTimeZero(v.PublishTime, utils.FormatDateTime),
  1654. PptPage: v.PptPage,
  1655. }
  1656. list = append(list, tmpV)
  1657. }
  1658. ret.List = list
  1659. ret.Total = len(list)
  1660. return
  1661. }
  1662. // SearchPptList PPT搜索(我的/公开PPT)
  1663. func SearchPptList(adminId int, keyword string) (ret models.RespGroupPptList, err error) {
  1664. list := make([]*models.RespGroupPptListItem, 0)
  1665. ret.List = list
  1666. var condition string
  1667. var pars []interface{}
  1668. // 公开的PPT或是我的非公开PPT
  1669. condition += ` AND (is_share = 1 OR (admin_id = ? AND is_share = 0)) `
  1670. pars = append(pars, adminId)
  1671. if keyword != `` {
  1672. kw := fmt.Sprint("%", keyword, "%")
  1673. condition += ` AND (title LIKE ? OR admin_real_name LIKE ? ) `
  1674. pars = append(pars, kw, kw)
  1675. }
  1676. pptList, err := models.GetAllPptV2List(condition, pars)
  1677. if len(pptList) <= 0 {
  1678. return
  1679. }
  1680. var pptContent []services.PPTContent
  1681. for _, v := range pptList {
  1682. if v.PptPage == 0 {
  1683. err = json.Unmarshal([]byte(v.Content), &pptContent)
  1684. if err != nil {
  1685. return
  1686. }
  1687. v.PptPage = len(pptContent)
  1688. }
  1689. tmpV := &models.RespGroupPptListItem{
  1690. GroupPptId: int64(v.PptId),
  1691. PptId: int64(v.PptId),
  1692. TemplateType: v.TemplateType,
  1693. BackgroundImg: v.BackgroundImg,
  1694. Title: v.Title,
  1695. PptCreateTime: v.CreateTime.Format(utils.FormatDateTime),
  1696. AdminId: v.AdminId,
  1697. AdminRealName: v.AdminRealName,
  1698. PptVersion: v.PptVersion,
  1699. IsSingleShare: v.IsShare,
  1700. PptxUrl: v.PptxUrl,
  1701. ReportId: v.ReportId,
  1702. ReportCode: v.ReportCode,
  1703. PptPage: v.PptPage,
  1704. }
  1705. list = append(list, tmpV)
  1706. }
  1707. ret.List = list
  1708. ret.Total = len(list)
  1709. return
  1710. }