lisy
2023-07-14 a1d8bead115c7749571dacbdea01f4b2c6caf4d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.dsh.activity.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.activity.entity.BenefitsVideos;
import com.dsh.activity.model.BenefitsVideoClassificationListVo;
import com.dsh.activity.model.BenefitsVideosInfoVo;
import com.dsh.activity.model.BenefitsVideosListVo;
import com.dsh.activity.service.BenefitsVideosService;
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.*;
 
import java.util.List;
 
@RestController
@RequestMapping("")
public class BenefitVideoController {
 
 
    @Autowired
    private BenefitsVideosService bfvService;
 
    @Autowired
    private TokenUtil tokenUtil;
 
 
 
 
    @PostMapping("base/benefitVideo/getList")
    public BenefitsVideos getVideosWithIds(@RequestBody Integer id){
        return bfvService.getOne(new QueryWrapper<BenefitsVideos>().eq("id",id).eq("state",1));
    }
 
 
 
 
    @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("/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(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<BenefitsVideosListVo>> queryBenefitsVideosList(Integer classificationId, Integer pageSize, Integer pageNo){
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<BenefitsVideosListVo> benefitsVideosListVos = bfvService.queryBenefitsVideosList(uid, classificationId, 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();
        }
    }
}