wzj-boot/ruoyi-admin/src/main/java/org/dromara/app/AppVlogController.java

200 lines
6.9 KiB
Java
Raw Normal View History

2025-08-15 16:51:03 +08:00
package org.dromara.app;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
2025-08-21 15:47:21 +08:00
import com.wzj.soopin.content.domain.bo.*;
import com.wzj.soopin.content.domain.vo.IndexVlogVO;
import com.wzj.soopin.content.enums.VlogStatusEnum;
import com.wzj.soopin.content.enums.YesOrNo;
2025-08-28 15:43:21 +08:00
import com.wzj.soopin.content.service.IVlogPullService;
2025-08-15 16:51:03 +08:00
import com.wzj.soopin.content.service.VlogService;
import com.wzj.soopin.content.service.VlogUploadService;
import com.wzj.soopin.content.utils.QcCloud;
import io.swagger.v3.oas.annotations.Operation;
2025-08-15 16:51:03 +08:00
import io.swagger.v3.oas.annotations.tags.Tag;
2025-08-28 15:43:21 +08:00
import lombok.AllArgsConstructor;
2025-08-15 16:51:03 +08:00
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
2025-08-16 11:15:40 +08:00
import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.common.core.exception.ServiceException;
2025-08-28 15:43:21 +08:00
import org.dromara.common.redis.redis.RedisCache;
2025-08-16 11:15:40 +08:00
import org.dromara.common.satoken.utils.LoginHelper;
2025-08-15 16:51:03 +08:00
import org.springframework.web.bind.annotation.*;
2025-08-16 11:15:40 +08:00
2025-08-15 16:51:03 +08:00
@Slf4j
@Tag(name = "VlogController 短视频相关业务功能的接口")
2025-08-15 16:51:03 +08:00
@RequestMapping("/app/vlog")
@RestController
2025-08-28 15:43:21 +08:00
@AllArgsConstructor
2025-08-15 16:51:03 +08:00
public class AppVlogController {
2025-08-28 15:43:21 +08:00
private final VlogService vlogService;
private final QcCloud qcCloud;
private final VlogUploadService vlogUploadService;
public final RedisCache cache;
private final IVlogPullService pullService;
2025-08-15 16:51:03 +08:00
@Operation(summary = "首页视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/indexList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> indexList(@RequestBody IndexListBO bo, @RequestBody Page page) {
2025-08-25 14:35:44 +08:00
2025-09-05 11:22:00 +08:00
Page<IndexVlogVO> pages = pullService.pullFromMq(page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
2025-08-28 15:43:21 +08:00
@Operation(summary = "视频详情")
2025-08-21 15:47:21 +08:00
@GetMapping("/detail/{vlogId}")
2025-08-28 15:43:21 +08:00
public R<Object> detail(@PathVariable String vlogId) {
2025-08-21 15:47:21 +08:00
return R.ok(vlogService.getVlogDetailById(vlogId));
2025-08-15 16:51:03 +08:00
}
2025-08-21 15:47:21 +08:00
@Operation(summary = "修改视频为私密")
@PostMapping("/changeToPrivate")
public R<Void> changeToPrivate(@RequestParam String vlogId) {
vlogService.changeToPrivateOrPublic(vlogId, YesOrNo.YES.type);
return R.ok();
}
@Operation(summary = "修改视频为公开")
@PostMapping("/changeToPublic")
public R<Void> changeToPublic(@RequestParam String vlogId) {
vlogService.changeToPrivateOrPublic(vlogId, YesOrNo.NO.type);
return R.ok();
}
2025-08-21 15:47:21 +08:00
@Operation(summary = "我的私密视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/myPrivateList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> myPrivateList(@RequestBody MyListBO bo, @RequestBody Page page) {
2025-08-16 11:15:40 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-16 11:15:40 +08:00
}
bo.setUserId(String.valueOf(loginUser.getUserId()));
2025-08-21 15:47:21 +08:00
Page<IndexVlogVO> pages = vlogService.queryMyVlogList(bo, page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
@Operation(summary = "我点赞的视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/myLikedList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> myLikedList(@RequestBody MyLikedVlogBO bo, @RequestBody Page page) {
Page<IndexVlogVO> pages = vlogService.getMyLikedVlogList(page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
@Operation(summary = "我关注人的视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/followList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> followList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
2025-08-16 11:15:40 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-16 11:15:40 +08:00
}
bo.setMyId(String.valueOf(loginUser.getUserId()));
2025-08-28 15:43:21 +08:00
Page<IndexVlogVO> pages = vlogService.getMyFollowVlogList(page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
@Operation(summary = "好友视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/friendList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> friendList(@RequestBody SimpleListBO bo, @RequestBody Page page) {
2025-08-16 11:15:40 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-16 11:15:40 +08:00
}
bo.setMyId(String.valueOf(loginUser.getUserId()));
2025-08-28 15:43:21 +08:00
Page<IndexVlogVO> pages = vlogService.getMyFriendVlogList(page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
2025-08-28 15:43:21 +08:00
@Operation(summary = "上传视频到云点播")
2025-08-15 16:51:03 +08:00
@PostMapping("publish")
public R<Void> publish(@RequestBody VlogBO vlogBO) throws Exception {
vlogService.createVlog(vlogBO);
return R.ok();
}
2025-08-28 15:43:21 +08:00
@Operation(summary = "我的公开视频列表")
2025-08-15 16:51:03 +08:00
@PostMapping("/myPublicList")
2025-08-21 15:47:21 +08:00
public R<Page<IndexVlogVO>> myPublicList(@RequestBody MyListBO bo, @RequestBody Page page) {
Page<IndexVlogVO> pages = vlogService.queryMyVlogList(bo, page);
2025-08-15 16:51:03 +08:00
return R.ok(pages);
}
@Operation(summary = "点赞")
@PostMapping("/like")
public R<Void> like(@RequestBody VlogBO vlogBO) {
2025-08-16 11:15:40 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-16 11:15:40 +08:00
}
String userId = String.valueOf(loginUser.getUserId());
String vlogId = vlogBO.getId();
vlogService.userLikeVlog(userId,vlogId );
2025-08-15 16:51:03 +08:00
return R.ok();
}
@Operation(summary = "取消点赞")
@PostMapping("/unlike")
public R<Void> unlike(@RequestBody VlogBO vlogBO) {
2025-08-16 11:15:40 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-16 11:15:40 +08:00
}
String userId = String.valueOf(loginUser.getUserId());
String vlogId = vlogBO.getId();
2025-08-15 16:51:03 +08:00
vlogService.userUnLikeVlog(userId, vlogId);
return R.ok();
}
@Operation(summary = "已读视频")
@GetMapping("/read")
public R<Void> read(@RequestBody VlogBO vlogBO) {
2025-08-28 15:43:21 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
return R.notLogin();
2025-08-28 15:43:21 +08:00
}
vlogService.readVlog(loginUser.getUserId(), vlogBO.getId());
2025-08-28 15:43:21 +08:00
return R.ok();
}
@Operation(summary = "删除视频")
2025-09-28 16:50:26 +08:00
@GetMapping("/delete")
public R<Void> delete(@RequestParam String id) {
2025-09-15 17:29:57 +08:00
LoginUser loginUser = LoginHelper.getLoginUser();
if (loginUser == null) {
throw new ServiceException("用户未登录");
}
vlogService.removeById(id);
return R.ok();
}
@Operation(summary = "视频列表")
2025-09-15 17:29:57 +08:00
@PostMapping("/page")
public R<Page<IndexVlogVO>> page(@RequestBody VlogBO vlogBO) {
if(vlogBO.getMemberId()==null){
throw new ServiceException("用户id不能为空");
}
vlogBO.setStatus(VlogStatusEnum.APPROVED.type);
vlogBO.setIsPrivate(YesOrNo.NO.type);
2025-09-15 17:29:57 +08:00
return R.ok(vlogService.getIndexVlogList(vlogBO,vlogBO.getPage()));
}
2025-08-28 15:43:21 +08:00
@Operation(summary = "手动触发缓存点赞最多视频")
2025-08-15 16:51:03 +08:00
@PostMapping("/cacheTopLikedVlogs")
public R<Void> cacheTopLikedVlogs(@RequestParam(defaultValue = "100") int limit) {
try {
2025-08-28 15:43:21 +08:00
// vlogService.cacheTopLikedVlogs(limit);
2025-08-15 16:51:03 +08:00
return R.ok();
} catch (Exception e) {
log.error("手动触发缓存点赞最多视频失败", e);
return R.fail("缓存失败: " + e.getMessage());
}
}
}