后台服务
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

124 行
5.4 KiB

  1. package com.iformall.controller;
  2. import com.github.pagehelper.PageInfo;
  3. import com.iformall.common.ErrorCode;
  4. import com.iformall.common.ResultData;
  5. import com.iformall.domain.po.base.BaseEntity;
  6. import com.iformall.domain.po.sm.MouldPatch;
  7. import com.iformall.domain.po.sm.MouldPatchSign;
  8. import com.iformall.domain.po.sm.UserMouldVideo;
  9. import com.iformall.enums.EnumMouldSendType;
  10. import com.iformall.enums.EnumVideoStatus;
  11. import com.iformall.enums.EnumaMouldPatchStatus;
  12. import com.iformall.service.sm.MouldPatchService;
  13. import com.iformall.service.sm.MouldPatchSignService;
  14. import com.iformall.service.sm.UserMouldVideoService;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiImplicitParam;
  17. import io.swagger.annotations.ApiImplicitParams;
  18. import io.swagger.annotations.ApiOperation;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.web.bind.annotation.*;
  24. import java.util.Date;
  25. import java.util.List;
  26. @RestController
  27. @RequestMapping("/api/userVideo")
  28. @Api(description = "模板接口")
  29. public class UserMouldVideoController extends BaseController {
  30. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  31. @Autowired
  32. private UserMouldVideoService userMouldVideoService;
  33. @Autowired
  34. private MouldPatchService mouldPatchService;
  35. @ApiOperation("分页列表接口")
  36. @GetMapping("list")
  37. @ApiImplicitParams({
  38. @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
  39. @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
  40. public ResultData list(@ModelAttribute UserMouldVideo record, Integer pageNum, Integer pageSize) {
  41. logger.debug("[" + getIpAddr() + "] UserMouldVideoController::list");
  42. if (record == null) record = new UserMouldVideo();
  43. record.setUserId(getMemberId());
  44. record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC);
  45. final PageInfo<UserMouldVideo> page = userMouldVideoService.cListAsPage(record, pageNum, pageSize);
  46. return new ResultData(page);
  47. }
  48. @ApiOperation("根据id查询接口")
  49. @GetMapping("/findById")
  50. @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
  51. public ResultData findById(Long id) {
  52. logger.debug("[" + getIpAddr() + "] MouldPatchController::findById");
  53. UserMouldVideo mouldVideo = userMouldVideoService.getById(id);
  54. if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){
  55. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据");
  56. }
  57. if(mouldVideo.getPersonMouldId() != null){
  58. mouldVideo.setPersonMould(mouldPatchService.getDetailById(mouldVideo.getPersonMouldId()));
  59. }
  60. if(mouldVideo.getVoiceMouldId() != null){
  61. mouldVideo.setVoiceMould(mouldPatchService.getDetailById(mouldVideo.getVoiceMouldId()));
  62. }
  63. if(mouldVideo.getBackgroundMouldId() != null){
  64. mouldVideo.setBackgroundMould(mouldPatchService.getDetailById(mouldVideo.getBackgroundMouldId()));
  65. }
  66. return new ResultData(mouldVideo);
  67. }
  68. @ApiOperation("新增接口")
  69. @PostMapping("saveOrUpdate")
  70. public ResultData saveOrUpdate(@RequestBody UserMouldVideo record) {
  71. logger.debug("[" + getIpAddr() + "] MouldPatchController::saveOrUpdate");
  72. record.setUserId(getMemberId());
  73. return userMouldVideoService.saveOrUpdate(record);
  74. }
  75. @ApiOperation("生成视频")
  76. @PostMapping("createVideo")
  77. public ResultData create(@RequestBody UserMouldVideo record) {
  78. logger.debug("[" + getIpAddr() + "] MouldPatchController::saveOrUpdate");
  79. if(record.getId() == null){
  80. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
  81. }
  82. UserMouldVideo mouldVideo = userMouldVideoService.getById(record.getId());
  83. if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){
  84. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据");
  85. }
  86. if(StringUtils.isEmpty(mouldVideo.getPaperwork())){
  87. return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未填写视频文案");
  88. }
  89. if(EnumVideoStatus.ing.getCode().equals(mouldVideo.getVideoStatus())){
  90. return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"生成视频中");
  91. }
  92. UserMouldVideo mouldVideoUpd = new UserMouldVideo();
  93. mouldVideoUpd.setId(record.getId());
  94. mouldVideoUpd.setVideoStatus(EnumVideoStatus.ing.getCode());
  95. mouldVideoUpd.setCreateVideoDate(new Date());
  96. userMouldVideoService.saveOrUpdate(mouldVideoUpd);
  97. userMouldVideoService.createVideo(mouldVideo);
  98. return new ResultData();
  99. }
  100. @ApiOperation("根据id查询接口")
  101. @GetMapping("/findVideo")
  102. @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
  103. public ResultData findVideo(Long id) {
  104. logger.debug("[" + getIpAddr() + "] MouldPatchController::findVideo");
  105. UserMouldVideo userMouldVideo = userMouldVideoService.findVideo(id);
  106. return new ResultData(userMouldVideo);
  107. }
  108. }