ppt_english_group.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_mobile/models"
  5. "eta/eta_mobile/models/ppt_english"
  6. "eta/eta_mobile/services/ppt"
  7. )
  8. type PptEnglishGroupController struct {
  9. BaseAuthController
  10. }
  11. // GroupList
  12. // @Title 获取可见的目录列表
  13. // @Description 获取可见的目录列表接口
  14. // @Success 200 {object} ppt_english.RespGroupList
  15. // @router /groups [get]
  16. func (this *PptEnglishGroupController) GroupList() {
  17. br := new(models.BaseResponse).Init()
  18. defer func() {
  19. this.Data["json"] = br
  20. this.ServeJSON()
  21. }()
  22. data, err := ppt.GetEnglishGroupsByAdminId(this.SysUser.AdminId)
  23. if err != nil {
  24. br.Msg = err.Error()
  25. return
  26. }
  27. br.Ret = 200
  28. br.Success = true
  29. br.Msg = "查询成功"
  30. br.Data = data
  31. return
  32. }
  33. // AddGroup
  34. // @Title 新增ppt目录
  35. // @Description 新增ppt目录接口
  36. // @Param request body ppt_english.ReqAddPptGroup true "type json string"
  37. // @Success 200 {object} ppt_english.RespAddPptGroup
  38. // @router /group/add [post]
  39. func (this *PptEnglishGroupController) AddGroup() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. this.Data["json"] = br
  43. this.ServeJSON()
  44. }()
  45. var req ppt_english.ReqAddPptGroup
  46. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  47. if err != nil {
  48. br.Msg = "参数解析异常!"
  49. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  50. return
  51. }
  52. if req.GroupName == "" {
  53. br.Msg = "请输入目录名称"
  54. return
  55. }
  56. newId, err := ppt.AddEnglishGroup(req.GroupName, this.SysUser.AdminId, 0, 0)
  57. if err != nil {
  58. br.Msg = err.Error()
  59. return
  60. }
  61. resp := ppt_english.RespAddPptGroup{
  62. GroupId: newId,
  63. }
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "新增成功"
  67. br.Data = resp
  68. }
  69. // DeleteGroup
  70. // @Title 删除ppt目录
  71. // @Description 删除ppt目录接口
  72. // @Param request body ppt_english.ReqPptGroup true "type json string"
  73. // @Success 200 Ret=200 删除成功
  74. // @router /group/delete [post]
  75. func (this *PptEnglishGroupController) DeleteGroup() {
  76. br := new(models.BaseResponse).Init()
  77. defer func() {
  78. this.Data["json"] = br
  79. this.ServeJSON()
  80. }()
  81. var req ppt_english.ReqPptGroup
  82. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  83. if err != nil {
  84. br.Msg = "参数解析异常!"
  85. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  86. return
  87. }
  88. if req.GroupId <= 0 {
  89. br.Msg = "请输入目录ID"
  90. return
  91. }
  92. err = ppt.DelEnglishGroup(req.GroupId, this.SysUser.AdminId)
  93. if err != nil {
  94. br.Msg = err.Error()
  95. return
  96. }
  97. br.Ret = 200
  98. br.Success = true
  99. br.Msg = "删除成功"
  100. }
  101. // ShareGroup
  102. // @Title 共享/取消共享目录
  103. // @Description 共享/取消共享目录接口
  104. // @Param request body ppt_english.ReqPptGroup true "type json string"
  105. // @Success 200 {object} ppt_english.RespPptGroupShare
  106. // @router /group/share [post]
  107. func (this *PptEnglishGroupController) ShareGroup() {
  108. br := new(models.BaseResponse).Init()
  109. defer func() {
  110. this.Data["json"] = br
  111. this.ServeJSON()
  112. }()
  113. var req ppt_english.ReqPptGroup
  114. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  115. if err != nil {
  116. br.Msg = "参数解析异常!"
  117. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  118. return
  119. }
  120. if req.GroupId <= 0 {
  121. br.Msg = "请输入目录ID"
  122. return
  123. }
  124. data, err := ppt.ShareEnglishGroup(req.GroupId, this.SysUser.AdminId)
  125. if err != nil {
  126. br.Msg = err.Error()
  127. return
  128. }
  129. br.Ret = 200
  130. br.Success = true
  131. br.Msg = "操作成功"
  132. br.Data = data
  133. return
  134. }
  135. // CopyGroup
  136. // @Title 复制目录
  137. // @Description 复制目录接口
  138. // @Param request body ppt_english.ReqPptGroup true "type json string"
  139. // @Success 200 Ret=200 复制成功
  140. // @router /group/copy [post]
  141. func (this *PptEnglishGroupController) CopyGroup() {
  142. br := new(models.BaseResponse).Init()
  143. defer func() {
  144. this.Data["json"] = br
  145. this.ServeJSON()
  146. }()
  147. var req ppt_english.ReqPptGroup
  148. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  149. if err != nil {
  150. br.Msg = "参数解析异常!"
  151. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  152. return
  153. }
  154. if req.GroupId <= 0 {
  155. br.Msg = "请输入目录ID"
  156. return
  157. }
  158. err = ppt.CopyEnglishGroup(req.GroupId, this.SysUser.AdminId, this.SysUser.RealName)
  159. if err != nil {
  160. br.Msg = err.Error()
  161. return
  162. }
  163. br.Ret = 200
  164. br.Success = true
  165. br.Msg = "复制成功"
  166. return
  167. }
  168. // RenameGroup
  169. // @Title 目录重命名
  170. // @Description 目录重命名接口
  171. // @Param request body ppt_english.ReqRenamePptGroup true "type json string"
  172. // @Success 200 Ret=200 重命名成功
  173. // @router /group/rename [post]
  174. func (this *PptEnglishGroupController) RenameGroup() {
  175. br := new(models.BaseResponse).Init()
  176. defer func() {
  177. this.Data["json"] = br
  178. this.ServeJSON()
  179. }()
  180. var req ppt_english.ReqRenamePptGroup
  181. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  182. if err != nil {
  183. br.Msg = "参数解析异常!"
  184. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  185. return
  186. }
  187. if req.GroupId <= 0 {
  188. br.Msg = "请输入目录ID"
  189. return
  190. }
  191. if req.GroupName == "" {
  192. br.Msg = "请输入目录名称"
  193. return
  194. }
  195. err = ppt.RenameEnglishGroupName(req.GroupId, req.GroupName, this.SysUser.AdminId)
  196. if err != nil {
  197. br.Msg = err.Error()
  198. return
  199. }
  200. br.Ret = 200
  201. br.Success = true
  202. br.Msg = "重命名成功"
  203. return
  204. }
  205. // SharePpt
  206. // @Title 共享/取消共享单个ppt
  207. // @Description 共享/取消共享单个ppt接口
  208. // @Param request body ppt_english.ReqPptShare true "type json string"
  209. // @Success 200 {object} ppt_english.RespPptShare
  210. // @router /share [post]
  211. func (this *PptEnglishGroupController) SharePpt() {
  212. br := new(models.BaseResponse).Init()
  213. defer func() {
  214. this.Data["json"] = br
  215. this.ServeJSON()
  216. }()
  217. var req ppt_english.ReqPptShareEnglish
  218. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  219. if err != nil {
  220. br.Msg = "参数解析异常!"
  221. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  222. return
  223. }
  224. if req.PptId <= 0 {
  225. br.Msg = "请输入目录里的ppt序号"
  226. return
  227. }
  228. pptInfo, err := ppt.ShareSingleGroupPptEnglish(req.PptId, this.SysUser.AdminId)
  229. if err != nil {
  230. br.Msg = err.Error()
  231. return
  232. }
  233. br.Ret = 200
  234. br.Success = true
  235. br.Msg = "操作成功"
  236. br.Data = ppt_english.RespPptShareEnglish{
  237. PptId: pptInfo.PptId,
  238. IsShare: pptInfo.IsShare,
  239. }
  240. return
  241. }
  242. // GroupPptList
  243. // @Title 获取默认的ppt列表或者单个目录内的ppt列表
  244. // @Description 获取可见的目录列表接口
  245. // @Param GroupId query int true "目录ID"
  246. // @Success 200 {object} ppt_english.RespGroupPptList
  247. // @router /group/ppt/list [get]
  248. func (this *PptEnglishGroupController) GroupPptList() {
  249. br := new(models.BaseResponse).Init()
  250. defer func() {
  251. this.Data["json"] = br
  252. this.ServeJSON()
  253. }()
  254. groupId, _ := this.GetInt("GroupId")
  255. data, err := ppt.GetGroupPptEnglishList(int64(groupId), this.SysUser.AdminId)
  256. if err != nil {
  257. br.Msg = err.Error()
  258. br.IsSendEmail = false
  259. return
  260. }
  261. br.Ret = 200
  262. br.Success = true
  263. br.Msg = "查询成功"
  264. br.Data = data
  265. return
  266. }
  267. // MoveGroupPpt
  268. // @Title 移动目录里的ppt
  269. // @Description 移动目录里的ppt接口
  270. // @Param request body ppt_english.ReqMoveGroupPpt true "type json string"
  271. // @Success 200 Ret=200 移动成功
  272. // @router /move [post]
  273. func (this *PptEnglishGroupController) MoveGroupPpt() {
  274. br := new(models.BaseResponse).Init()
  275. defer func() {
  276. this.Data["json"] = br
  277. this.ServeJSON()
  278. }()
  279. var req ppt_english.ReqMoveGroupPpt
  280. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  281. if err != nil {
  282. br.Msg = "参数解析异常!"
  283. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  284. return
  285. }
  286. if req.GroupId <= 0 {
  287. br.Msg = "请输入目录ID"
  288. return
  289. }
  290. err = ppt.MoveGroupPptEnglish(req.GroupId, req.GroupPptId, req.PrevGroupPptId, req.NextGroupPptId, this.SysUser.AdminId)
  291. if err != nil {
  292. br.Msg = err.Error()
  293. return
  294. }
  295. br.Ret = 200
  296. br.Success = true
  297. br.Msg = "移动成功"
  298. }
  299. // MoveGroup
  300. // @Title 移动目录
  301. // @Description 移动目录接口
  302. // @Param request body ppt_english.ReqMoveGroup true "type json string"
  303. // @Success 200 Ret=200 移动成功
  304. // @router /group/move [post]
  305. func (this *PptEnglishGroupController) MoveGroup() {
  306. br := new(models.BaseResponse).Init()
  307. defer func() {
  308. this.Data["json"] = br
  309. this.ServeJSON()
  310. }()
  311. var req ppt_english.ReqMoveGroup
  312. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  313. if err != nil {
  314. br.Msg = "参数解析异常!"
  315. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  316. return
  317. }
  318. if req.GroupId <= 0 {
  319. br.Msg = "请输入目录ID"
  320. return
  321. }
  322. err = ppt.MoveEnglishGroup(req.GroupId, req.PrevGroupId, req.NextGroupId, this.SysUser.AdminId)
  323. if err != nil {
  324. br.Msg = err.Error()
  325. return
  326. }
  327. br.Ret = 200
  328. br.Success = true
  329. br.Msg = "移动成功"
  330. }
  331. // CopyPpt
  332. // @Title 复制单个ppt
  333. // @Description 复制目录接口
  334. // @Param request body ppt_english.ReqCopyPpt true "type json string"
  335. // @Success 200 Ret=200 复制成功
  336. // @router /copy [post]
  337. func (this *PptEnglishGroupController) CopyPpt() {
  338. br := new(models.BaseResponse).Init()
  339. defer func() {
  340. this.Data["json"] = br
  341. this.ServeJSON()
  342. }()
  343. var req ppt_english.ReqCopyPpt
  344. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  345. if err != nil {
  346. br.Msg = "参数解析异常!"
  347. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  348. return
  349. }
  350. if req.GroupId <= 0 {
  351. br.Msg = "请输入目录ID"
  352. return
  353. }
  354. if req.PptId <= 0 {
  355. br.Msg = "请输入ppt ID"
  356. return
  357. }
  358. data, err := ppt.CopyPptEnglish(req.PptId, req.GroupId, this.SysUser.AdminId, this.SysUser.RealName)
  359. if err != nil {
  360. br.Msg = err.Error()
  361. return
  362. }
  363. br.Ret = 200
  364. br.Success = true
  365. br.Msg = "复制成功"
  366. br.Data = data
  367. return
  368. }
  369. // GroupNameList
  370. // @Title 查询目录名称列表
  371. // @Description 查询目录名称列表接口
  372. // @Success 200 {object} ppt_english.RespPptGroupNameList
  373. // @router /group/name [get]
  374. func (this *PptEnglishGroupController) GroupNameList() {
  375. br := new(models.BaseResponse).Init()
  376. defer func() {
  377. this.Data["json"] = br
  378. this.ServeJSON()
  379. }()
  380. list, err := ppt_english.GetPptGroupIdAndGroupNameByAdminId(this.SysUser.AdminId)
  381. if err != nil {
  382. br.Msg = "查询目录名称出错" + err.Error()
  383. return
  384. }
  385. data := &ppt_english.RespPptGroupNameList{
  386. List: list,
  387. }
  388. br.Ret = 200
  389. br.Success = true
  390. br.Msg = "查询成功"
  391. br.Data = data
  392. return
  393. }
  394. // SearchGroupPptList
  395. // @Title 按ppt关键词搜索列表
  396. // @Description 按ppt关键词搜索列表接口
  397. // @Param KeyWord query int true "搜索关键词"
  398. // @Success 200 {object} ppt_english.RespSearchGroupPptList
  399. // @router /group/ppt/search [get]
  400. func (this *PptEnglishGroupController) SearchGroupPptList() {
  401. br := new(models.BaseResponse).Init()
  402. defer func() {
  403. this.Data["json"] = br
  404. this.ServeJSON()
  405. }()
  406. keyWord := this.GetString("KeyWord")
  407. data, err := ppt.SearchGroupPptEnglish(keyWord)
  408. if err != nil {
  409. br.Msg = err.Error()
  410. return
  411. }
  412. br.Ret = 200
  413. br.Success = true
  414. br.Msg = "查询成功"
  415. br.Data = data
  416. return
  417. }
  418. // SharePptList
  419. // @Title 获取用户开放的公共Ppt
  420. // @Description 获取用户开放的公共Ppt接口
  421. // @Param AdminId query int true "创建人ID"
  422. // @Param Keyword query string true "关键字"
  423. // @Param IsPrivate query bool false "是否为私有"
  424. // @Success 200 {object} ppt_english.RespGroupPptList
  425. // @router /share/ppt/list [get]
  426. func (this *PptEnglishGroupController) SharePptList() {
  427. br := new(models.BaseResponse).Init()
  428. defer func() {
  429. this.Data["json"] = br
  430. this.ServeJSON()
  431. }()
  432. adminId, _ := this.GetInt("AdminId")
  433. keyword := this.GetString("Keyword")
  434. isPrivate, _ := this.GetBool("IsPrivate", false)
  435. if isPrivate && adminId <= 0 {
  436. br.Msg = "参数有误, 私有PPT创建人ID不可为空"
  437. return
  438. }
  439. data, err := ppt.GetSharePptEnglishList(adminId, keyword, isPrivate)
  440. if err != nil {
  441. br.Msg = err.Error()
  442. return
  443. }
  444. br.Ret = 200
  445. br.Success = true
  446. br.Msg = "查询成功"
  447. br.Data = data
  448. return
  449. }
  450. // GrantPptList
  451. // @Title 获取用户共享的公共Ppt(分配权限的Ppt)
  452. // @Description 获取用户共享的公共Ppt(分配权限的Ppt)接口
  453. // @Param GroupId query int true "分组ID,唉,其实不知道用啥名,就这么用吧"
  454. // @Param Keyword query string true "关键字"
  455. // @Success 200 {object} ppt_english.RespGroupPptList
  456. // @router /grant/ppt/list [get]
  457. func (this *PptEnglishGroupController) GrantPptList() {
  458. br := new(models.BaseResponse).Init()
  459. defer func() {
  460. this.Data["json"] = br
  461. this.ServeJSON()
  462. }()
  463. groupId, _ := this.GetInt("GroupId")
  464. keyword := this.GetString("Keyword")
  465. var sourceType string
  466. switch groupId {
  467. case 1:
  468. sourceType = "my"
  469. case 2:
  470. sourceType = "other"
  471. default:
  472. br.Msg = "错误的来源"
  473. br.IsSendEmail = false
  474. return
  475. }
  476. data, err := ppt.GetGrantPptEnglishList(this.SysUser.AdminId, keyword, sourceType)
  477. if err != nil {
  478. br.Msg = err.Error()
  479. return
  480. }
  481. br.Ret = 200
  482. br.Success = true
  483. br.Msg = "查询成功"
  484. br.Data = data
  485. return
  486. }
  487. // PptList
  488. // @Title 获取Ppt
  489. // @Description 获取用户开放的公共Ppt接口
  490. // @Param Keyword query string true "关键字"
  491. // @Success 200 {object} models.RespGroupPptList
  492. // @router /ppt/list [get]
  493. func (this *PptEnglishGroupController) PptList() {
  494. br := new(models.BaseResponse).Init()
  495. defer func() {
  496. this.Data["json"] = br
  497. this.ServeJSON()
  498. }()
  499. keyword := this.GetString("Keyword")
  500. data, err := ppt.GetEnglishPptList(this.SysUser.AdminId, keyword)
  501. if err != nil {
  502. br.Msg = err.Error()
  503. return
  504. }
  505. br.Ret = 200
  506. br.Success = true
  507. br.Msg = "查询成功"
  508. br.Data = data
  509. return
  510. }