| | |
| | | import cn.lili.modules.lmk.domain.form.VideoHomePageInfoForm; |
| | | import cn.lili.modules.lmk.domain.form.WxVideoForm; |
| | | import cn.lili.modules.lmk.domain.query.*; |
| | | import cn.lili.modules.lmk.domain.vo.WxVideoVO; |
| | | import cn.lili.modules.lmk.service.VideoService; |
| | | import cn.lili.utils.COSUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 视频内容 前端控制器 |
| | |
| | | public class VideoController { |
| | | |
| | | private final VideoService videoService; |
| | | private COSUtil cOSUtil; |
| | | |
| | | @PostMapping("/publish") |
| | | @ApiOperation(value = "发布视频", notes = "发布视频") |
| | |
| | | @GetMapping("/author-collect-video-page") |
| | | @ApiOperation(value = "获取视频主页作者收藏的视频分页", notes = "获取视频主页作者收藏的视频分页") |
| | | public Result getAuthorCollectVideoPage(AuthorVideoQuery query) { |
| | | return videoService.getAuthorCollectVideoPage(query); |
| | | Result result = videoService.getAuthorCollectVideoPage(query); |
| | | List<WxVideoVO> list = Optional.ofNullable(result.get("data")) |
| | | .filter(data -> data instanceof List<?>) |
| | | .map(data -> (List<?>) data) |
| | | .orElse(Collections.emptyList()) |
| | | .stream() |
| | | .filter(WxVideoVO.class::isInstance) |
| | | .map(WxVideoVO.class::cast) |
| | | .collect(Collectors.toList()); |
| | | for (WxVideoVO wxVideoVO : list){ |
| | | if (!CollectionUtils.isEmpty(wxVideoVO.getImgs())){ |
| | | List<String> newImages = wxVideoVO |
| | | .getImgs().stream().map(item -> cOSUtil.getPreviewUrl(item)).collect(Collectors.toList()); |
| | | wxVideoVO.setImgs(newImages); |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @GetMapping("/author-like-video-page") |