From e99324b70510afdff4175a484e976cb0e804411b Mon Sep 17 00:00:00 2001
From: luo <2855143437@qq.com>
Date: 星期一, 25 九月 2023 16:18:45 +0800
Subject: [PATCH] 9.25
---
cloud-server-activity/src/main/java/com/dsh/activity/controller/BenefitVideoController.java | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 208 insertions(+), 4 deletions(-)
diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/BenefitVideoController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/BenefitVideoController.java
index 971a10f..78a9cad 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/BenefitVideoController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/BenefitVideoController.java
@@ -2,13 +2,20 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dsh.activity.entity.BenefitsVideoClassification;
import com.dsh.activity.entity.BenefitsVideos;
+import com.dsh.activity.model.*;
import com.dsh.activity.service.BenefitsVideosService;
+import com.dsh.activity.service.IBenefitsVideoClassificationService;
+import com.dsh.activity.util.ResultUtil;
+import com.dsh.activity.util.TokenUtil;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
@RestController
@RequestMapping("")
@@ -17,8 +24,95 @@
@Autowired
private BenefitsVideosService bfvService;
+ @Autowired
+ private IBenefitsVideoClassificationService benefitsVideoClassificationService;
+
+ @Autowired
+ private TokenUtil tokenUtil;
+
+ /**
+ * 获取所有福利视频分类
+ * @return
+ */
+ @RequestMapping("/base/benefitVideo/list")
+ public List<TQueryBenefitsVO> listAll(@RequestBody QueryBenefitsVedioVO vo){
+
+ return benefitsVideoClassificationService.listAll(vo);
+ }
+
+ /**
+ * 查看详情/编辑
+ * @return
+ */
+ @RequestMapping("/base/benefitVideo/getById")
+ public BenefitsVideoClassification getById(@RequestBody Integer id){
+ return benefitsVideoClassificationService.getById(id);
+ }
+
+ /**
+ * 根据分类id查询福利视频分类下的视频
+ * @return
+ */
+ @RequestMapping("/base/benefitVideo/getBenefitVideoById")
+ @ResponseBody
+ public List<BenefitsVideos> getBenefitVideoById(@RequestBody Integer id){
+ return bfvService.getBenefitVideoById(id);
+ }
+
+ /**
+ * 根据福利视频id获取福利视频信息
+ * @return
+ */
+ @RequestMapping("/base/benefitVideo/getBenefitVideosById")
+ @ResponseBody
+ public BenefitsVideos getBenefitVideosById(@RequestBody Integer id){
+ return bfvService.getById(id);
+ }
+
+ /**
+ * 添加/修改福利视频分类
+ * @return
+ */
+ @RequestMapping("/base/benefitVideo/add")
+ public Object addSite(@RequestBody BenefitsVideoClassification site){
+ QueryWrapper<BenefitsVideoClassification> wrapper = new QueryWrapper<BenefitsVideoClassification>().eq("name", site.getName());
+ if (benefitsVideoClassificationService.list(wrapper).size()==0){
+ if(site.getId()!= null ){
+ benefitsVideoClassificationService.updateById(site);
+ return 200;
+ }else {
+ return benefitsVideoClassificationService.save(site);
+ }
+ }else return 500;
+ }
+
+ /**
+ * 添加/修改视频详情
+ * @return
+ */
+ @RequestMapping("/base/addBenefitsVideos")
+ public Object addBenefitsVideos(@RequestBody BenefitsVideos site){
+ // 通过分类Id和课程id 查询视频
+ List<BenefitsVideos> result = bfvService.getBybIdAndcId(site.getBenefitsVideoClassificationId(),site.getCourseId());
+ if (result.size()>0){
+ return 500;
+ }
+ if (site.getId() == null){
+ return bfvService.save(site);
+ }else {
+ return bfvService.updateById(site);
+ }
+ }
+ /**
+ * 上/下架、删除福利视频分类 type=1为上架 2为下架 3为删除
+ */
+ @RequestMapping("/base/benefitVideo/changeState")
+ public Object changeState(@RequestBody BenefitsVedioChangeStateVO vo){
+
+ return benefitsVideoClassificationService.changeState(vo);
+ }
@PostMapping("base/benefitVideo/getList")
public BenefitsVideos getVideosWithIds(@RequestBody Integer id){
@@ -26,4 +120,114 @@
}
+
+
+ @ResponseBody
+ @PostMapping("/api/benefitsVideo/queryClassificationBenefitsVideosList")
+ @ApiOperation(value = "获取视频列表", tags = {"APP-线上课得积分", "APP-看视频得奖励"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "位置(1=线上课得积分,2=看视频得奖励)", name = "position", dataType = "int", required = true),
+ @ApiImplicitParam(value = "搜索内容", name = "search", dataType = "string", required = false),
+ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+ })
+ public ResultUtil<List<BenefitsVideoClassificationListVo>> queryClassificationBenefitsVideosList(Integer position, String search){
+ try {
+ Integer uid = tokenUtil.getUserIdFormRedis();
+ if(null == uid){
+ return ResultUtil.tokenErr();
+ }
+ List<BenefitsVideoClassificationListVo> listVos = bfvService.queryClassificationBenefitsVideosList(uid, position, search);
+ return ResultUtil.success(listVos);
+ }catch (Exception e){
+ e.printStackTrace();
+ return ResultUtil.runErr();
+ }
+ }
+ @ResponseBody
+ @PostMapping("/base/benefitsVideo/queryClassificationBenefitsVideosListOne")
+ @ApiOperation(value = "获取视频列表", tags = {"APP-线上课得积分", "APP-看视频得奖励"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "位置(1=线上课得积分,2=看视频得奖励)", name = "position", dataType = "int", required = true),
+ @ApiImplicitParam(value = "搜索内容", name = "search", dataType = "string", required = false),
+ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+ })
+ public ResultUtil<List<BenefitsVideoClassificationListVo>> queryClassificationBenefitsVideosListOne(Integer position, String search){
+ try {
+ Integer uid = -1;
+ List<BenefitsVideoClassificationListVo> listVos = bfvService.queryClassificationBenefitsVideosListOne(uid, position, search);
+ return ResultUtil.success(listVos);
+ }catch (Exception e){
+ e.printStackTrace();
+ return ResultUtil.runErr();
+ }
+ }
+
+
+ @ResponseBody
+ @PostMapping("/api/benefitsVideo/queryBenefitsVideosList")
+ @ApiOperation(value = "获取视频列表", tags = {"APP-线上课得积分", "APP-看视频得奖励"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "视频分类id", name = "classificationId", dataType = "int", required = true),
+ @ApiImplicitParam(value = "页码,首页1", name = "pageSize", dataType = "int", required = true),
+ @ApiImplicitParam(value = "页条数", name = "pageNo", dataType = "int", required = true),
+ @ApiImplicitParam(value = "搜索内容", name = "search", dataType = "string", required = false),
+ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+ })
+ public ResultUtil<List<BenefitsVideosListVo>> queryBenefitsVideosList(Integer classificationId, String search, Integer pageSize, Integer pageNo){
+ try {
+ Integer uid = tokenUtil.getUserIdFormRedis();
+ if(null == uid){
+ return ResultUtil.tokenErr();
+ }
+ List<BenefitsVideosListVo> benefitsVideosListVos = bfvService.queryBenefitsVideosList(uid, classificationId, search, pageSize, pageNo);
+ return ResultUtil.success(benefitsVideosListVos);
+ }catch (Exception e){
+ e.printStackTrace();
+ return ResultUtil.runErr();
+ }
+ }
+
+
+
+ @ResponseBody
+ @PostMapping("/api/benefitsVideo/queryBenefitsVideosInfo")
+ @ApiOperation(value = "获取视频详情", tags = {"APP-线上课得积分", "APP-看视频得奖励"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "视频id", name = "id", dataType = "int", required = true),
+ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+ })
+ public ResultUtil<BenefitsVideosInfoVo> queryBenefitsVideosInfo(Integer id){
+ try {
+ Integer uid = tokenUtil.getUserIdFormRedis();
+ if(null == uid){
+ return ResultUtil.tokenErr();
+ }
+ BenefitsVideosInfoVo benefitsVideosInfoVo = bfvService.queryBenefitsVideosInfo(uid, id);
+ return ResultUtil.success(benefitsVideosInfoVo);
+ }catch (Exception e){
+ e.printStackTrace();
+ return ResultUtil.runErr();
+ }
+ }
+
+ @ResponseBody
+ @PostMapping("/api/benefitsVideo/receiveAward")
+ @ApiOperation(value = "观看视频结束后领取奖励", tags = {"APP-线上课得积分", "APP-看视频得奖励"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "视频id", name = "id", dataType = "int", required = true),
+ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
+ })
+ public ResultUtil receiveAward(Integer id) {
+ try {
+ Integer uid = tokenUtil.getUserIdFormRedis();
+ if(null == uid){
+ return ResultUtil.tokenErr();
+ }
+ bfvService.receiveAward(uid, id);
+ return ResultUtil.success();
+ }catch (Exception e){
+ e.printStackTrace();
+ return ResultUtil.runErr();
+ }
+ }
}
--
Gitblit v1.7.1