VideoApi.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package com.caimei.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.vo.VideoListVo;
  5. import com.caimei.service.VideoService;
  6. import com.github.pagehelper.PageInfo;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiImplicitParam;
  9. import io.swagger.annotations.ApiImplicitParams;
  10. import io.swagger.annotations.ApiOperation;
  11. import lombok.RequiredArgsConstructor;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.util.Map;
  15. /**
  16. * 资料库视频API
  17. *
  18. * @author : Aslee
  19. * @date : 2021/7/9
  20. */
  21. @Api(tags = "资料库视频API")
  22. @Slf4j
  23. @RestController
  24. @RequiredArgsConstructor
  25. @RequestMapping("/data/video")
  26. public class VideoApi {
  27. private final VideoService videoService;
  28. @ApiOperation("视频列表")
  29. @ApiImplicitParams({
  30. @ApiImplicitParam(name = "listType", required = false, value = "列表类型:1视频列表,2视频审核列表"),
  31. @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
  32. @ApiImplicitParam(name = "videoTitle", required = false, value = "视频标题"),
  33. @ApiImplicitParam(name = "auditStatus", required = false, value = "审核状态:0审核未通过,1审核通过,2待审核"),
  34. @ApiImplicitParam(name = "status", required = false, value = "视频状态:0已下线,1已上线,2待上线"),
  35. @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
  36. @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
  37. })
  38. @GetMapping("/list")
  39. public ResponseJson<PageInfo<VideoListVo>> getVideoList(Integer listType, Integer authUserId, String videoTitle, Integer auditStatus, Integer status,
  40. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  41. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  42. return videoService.getVideoList(listType, authUserId, videoTitle, auditStatus, status, pageNum, pageSize);
  43. }
  44. @ApiOperation("添加/编辑视频")
  45. @ApiImplicitParam(name = "params", required = false, value = "videoId:视频id;authUserId:供应商用户id;videoTitle:视频标题;videoName:视频名称;videoPreviewUrl:视频预览链接;videoDownloadUrl:oss名称")
  46. @PostMapping("/save")
  47. public ResponseJson saveVideo(@RequestBody String params) {
  48. JSONObject paramsMap = JSONObject.parseObject(params);
  49. Integer videoId = paramsMap.getInteger("videoId");
  50. Integer authUserId = paramsMap.getInteger("authUserId");
  51. String videoTitle = paramsMap.getString("videoTitle");
  52. String videoName = paramsMap.getString("videoName");
  53. String videoPreviewUrl = paramsMap.getString("videoPreviewUrl");
  54. String videoDownloadUrl = paramsMap.getString("videoDownloadUrl");
  55. return videoService.saveVideo(videoId, authUserId, videoTitle, videoName, videoPreviewUrl, videoDownloadUrl);
  56. }
  57. @ApiOperation("更新视频状态")
  58. @ApiImplicitParam(name = "params", value = "videoId:视频id;status:视频状态:0停用 1启用;", required = true)
  59. @PostMapping("/update/status")
  60. public ResponseJson updateVideoStatus(@RequestBody Map<String,Integer> params) {
  61. Integer videoId = params.get("videoId");
  62. Integer status = params.get("status");
  63. return videoService.updateVideoStatus(videoId, status);
  64. }
  65. @ApiOperation("删除视频")
  66. @ApiImplicitParam(name = "params", value = "videoId:视频id", required = true)
  67. @PostMapping("/delete")
  68. public ResponseJson deleteVideo(@RequestBody Map<String,Integer> params) {
  69. Integer videoId = params.get("videoId");
  70. return videoService.deleteVideo(videoId);
  71. }
  72. @ApiOperation("审核视频")
  73. @ApiImplicitParam(name = "params", value = "videoId:视频id;auditStatus:审核状态:0审核未通过,1审核通过,2待审核;invalidReason:审核不通过原因;auditBy:审核人用户id", required = true)
  74. @PostMapping("/audit")
  75. public ResponseJson auditVideo(@RequestBody String params) {
  76. JSONObject paramsMap = JSONObject.parseObject(params);
  77. Integer videoId = paramsMap.getInteger("videoId");
  78. Integer auditStatus = paramsMap.getInteger("auditStatus");
  79. String invalidReason = paramsMap.getString("invalidReason");
  80. Integer auditBy = paramsMap.getInteger("auditBy");
  81. return videoService.auditVideo(videoId, auditStatus, invalidReason, auditBy);
  82. }
  83. }