|
|
@@ -14,6 +14,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.zjrs.spbb.video.entity.SppbVideo;
|
|
|
+import org.jeecg.modules.zjrs.spbb.video.service.ISppbFavoriteService;
|
|
|
import org.jeecg.modules.zjrs.spbb.video.service.ISppbVideoService;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
@@ -40,6 +41,8 @@ import java.util.Map;
|
|
|
public class SppbVideoController extends JeecgController<SppbVideo, ISppbVideoService> {
|
|
|
@Autowired
|
|
|
private ISppbVideoService sppbVideoService;
|
|
|
+ @Autowired
|
|
|
+ private ISppbFavoriteService sppbFavoriteService;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
@@ -204,4 +207,81 @@ public class SppbVideoController extends JeecgController<SppbVideo, ISppbVideoSe
|
|
|
return Result.OK(resultList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 收藏视频
|
|
|
+ */
|
|
|
+ @AutoLog(value = "视频帮办-视频管理-收藏视频")
|
|
|
+ @Operation(summary="视频帮办-视频管理-收藏视频")
|
|
|
+ @PostMapping(value = "/favorite")
|
|
|
+ public Result<String> favorite(@RequestBody Map<String, String> params) {
|
|
|
+ String videoId = params.get("videoId");
|
|
|
+ String userId = params.get("userId");
|
|
|
+ String userSource = params.get("userSource");
|
|
|
+ if (oConvertUtils.isEmpty(videoId) || oConvertUtils.isEmpty(userId)) {
|
|
|
+ return Result.error("参数videoId和userId不能为空");
|
|
|
+ }
|
|
|
+ sppbFavoriteService.favorite(videoId, userId, userSource);
|
|
|
+ return Result.OK("收藏成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消收藏
|
|
|
+ */
|
|
|
+ @AutoLog(value = "视频帮办-视频管理-取消收藏")
|
|
|
+ @Operation(summary="视频帮办-视频管理-取消收藏")
|
|
|
+ @DeleteMapping(value = "/unfavorite")
|
|
|
+ public Result<String> unfavorite(@RequestParam(name="videoId") String videoId,
|
|
|
+ @RequestParam(name="userId") String userId) {
|
|
|
+ if (oConvertUtils.isEmpty(videoId) || oConvertUtils.isEmpty(userId)) {
|
|
|
+ return Result.error("参数videoId和userId不能为空");
|
|
|
+ }
|
|
|
+ sppbFavoriteService.unfavorite(videoId, userId);
|
|
|
+ return Result.OK("取消收藏成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户收藏视频列表
|
|
|
+ */
|
|
|
+ @Operation(summary="视频帮办-视频管理-查询用户收藏视频列表")
|
|
|
+ @GetMapping(value = "/listFavorites")
|
|
|
+ public Result<IPage<SppbVideo>> listFavorites(@RequestParam(name="userId") String userId,
|
|
|
+ @RequestParam(name="userSource") String userSource,
|
|
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
|
|
+ if (oConvertUtils.isEmpty(userId)) {
|
|
|
+ return Result.error("参数userId不能为空");
|
|
|
+ }
|
|
|
+ IPage<SppbVideo> pageList = sppbFavoriteService.listFavorites(userId, userSource, pageNo, pageSize);
|
|
|
+ return Result.OK(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户是否已收藏某个视频
|
|
|
+ */
|
|
|
+ @Operation(summary="视频帮办-视频管理-查询是否已收藏")
|
|
|
+ @GetMapping(value = "/hasFavorited")
|
|
|
+ public Result<Boolean> hasFavorited(@RequestParam(name="videoId") String videoId,
|
|
|
+ @RequestParam(name="userId") String userId,
|
|
|
+ @RequestParam(name="userSource") String userSource) {
|
|
|
+ if (oConvertUtils.isEmpty(videoId) || oConvertUtils.isEmpty(userId)) {
|
|
|
+ return Result.error("参数videoId和userId不能为空");
|
|
|
+ }
|
|
|
+ boolean favorited = sppbFavoriteService.hasFavorited(videoId, userId, userSource);
|
|
|
+ return Result.OK(favorited);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 记录视频播放次数(Redis 计数,由定时任务批量刷库)
|
|
|
+ */
|
|
|
+ @AutoLog(value = "视频帮办-视频管理-记录播放")
|
|
|
+ @Operation(summary="视频帮办-视频管理-记录播放")
|
|
|
+ @PutMapping(value = "/{videoId}/play")
|
|
|
+ public Result<String> recordPlay(@PathVariable(name="videoId") String videoId) {
|
|
|
+ if (oConvertUtils.isEmpty(videoId)) {
|
|
|
+ return Result.error("参数videoId不能为空");
|
|
|
+ }
|
|
|
+ sppbVideoService.recordPlay(videoId);
|
|
|
+ return Result.OK("ok");
|
|
|
+ }
|
|
|
+
|
|
|
}
|