xiaoyong931011
2021-12-22 db755501635521cf10bfe89ecd7ee977f384b968
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
132
133
134
135
136
137
138
139
140
141
142
143
package cc.mrbird.febs.video.controller;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.DeptTree;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.system.entity.Dept;
import cc.mrbird.febs.video.entity.VideoCategoryEntity;
import cc.mrbird.febs.video.entity.VideoMasterInfoEntity;
import cc.mrbird.febs.video.entity.VideoMasterSourceEntity;
import cc.mrbird.febs.video.service.IVideoCategoryService;
import cc.mrbird.febs.video.service.IVideoMasterInfoService;
import cc.mrbird.febs.video.service.IVideoMasterSourceService;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
 
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * @author wzy
 * @date 2021-12-13
 **/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("video")
public class AdminVideoController extends BaseController {
 
    private final IVideoCategoryService videoCategoryService;
    private final IVideoMasterSourceService videoMasterSourceService;
    private final IVideoMasterInfoService videoMasterInfoService;
 
    @GetMapping("/allCategory")
    public List<DeptTree<VideoCategoryEntity>> allCategory() {
        return this.videoCategoryService.findVideoCategory();
    }
 
    @GetMapping("/categoryTree")
    @ControllerEndpoint(exceptionMessage = "获取视频分类失败")
    public FebsResponse categoryTree(VideoCategoryEntity category) {
        List<DeptTree<VideoCategoryEntity>> depts = this.videoCategoryService.categoryTree(category);
        return new FebsResponse().success().data(depts);
    }
 
    @PostMapping("/addCate")
    @RequiresPermissions("category:add")
    @ControllerEndpoint(operation = "新增分类", exceptionMessage = "新增分类失败")
    public FebsResponse addCate(VideoCategoryEntity category) {
        this.videoCategoryService.save(category);
        return new FebsResponse().success();
    }
 
    @PostMapping("/updateCate")
    @RequiresPermissions("category:update")
    @ControllerEndpoint(operation = "修改分类", exceptionMessage = "修改分类失败")
    public FebsResponse updateCate(VideoCategoryEntity category) {
        category.setUpdatedTime(new Date());
        this.videoCategoryService.updateById(category);
        return new FebsResponse().success();
    }
 
    @GetMapping("/delCate/{cateIds}")
    @RequiresPermissions("category:update")
    @ControllerEndpoint(operation = "修改分类", exceptionMessage = "修改分类失败")
    public FebsResponse delCate(@NotBlank(message = "{required}") @PathVariable String cateIds) {
        List<String> ids = StrUtil.split(cateIds, ',');
        this.videoCategoryService.removeByIds(ids);
        return new FebsResponse().success();
    }
 
    @GetMapping("/sourceInPage")
    @RequiresPermissions("source:view")
    @ControllerEndpoint(operation = "资源列表", exceptionMessage = "获取资源列表失败")
    public FebsResponse findVideoSourceInPage(VideoMasterSourceEntity source, QueryRequest request) {
        Map<String, Object> dataTable = getDataTable(this.videoMasterSourceService.findInPage(source, request));
        return new FebsResponse().success().data(dataTable);
    }
 
    @PostMapping("/source/add")
    @RequiresPermissions("source:add")
    @ControllerEndpoint(operation = "新增资源", exceptionMessage = "新增资源失败")
    public FebsResponse addVideoSource(VideoMasterSourceEntity source) {
        this.videoMasterSourceService.addSource(source);
        return new FebsResponse().success();
    }
 
    @PostMapping("/source/update")
    @RequiresPermissions("source:update")
    @ControllerEndpoint(operation = "修改资源", exceptionMessage = "修改资源失败")
    public FebsResponse updateVideoSource(VideoMasterSourceEntity source) {
        this.videoMasterSourceService.modifySourceById(source);
        return new FebsResponse().success();
    }
 
    @GetMapping("/source/delete/{ids}")
    @RequiresPermissions("source:delete")
    @ControllerEndpoint(operation = "删除资源", exceptionMessage = "删除资源失败")
    public FebsResponse delSource(@PathVariable String ids) {
        this.videoMasterSourceService.delSource(ids);
        return new FebsResponse().success();
    }
 
    @GetMapping("/video/list")
    @RequiresPermissions("source:view")
    @ControllerEndpoint(operation = "视频列表", exceptionMessage = "获取视频列表失败")
    public FebsResponse videoList(VideoMasterInfoEntity info, QueryRequest request) {
        return new FebsResponse().success().data(getDataTable(this.videoMasterInfoService.findInPage(info, request)));
    }
 
    @PostMapping("/video/add")
    @RequiresPermissions("source:add")
    @ControllerEndpoint(operation = "添加视频", exceptionMessage = "添加视频失败")
    public FebsResponse videoAdd(@RequestBody VideoMasterInfoEntity info) {
        this.videoMasterInfoService.addVideo(info);
        return new FebsResponse().success();
    }
 
    @PostMapping("/video/update")
    @RequiresPermissions("source:update")
    @ControllerEndpoint(operation = "修改视频", exceptionMessage = "修改视频失败")
    public FebsResponse videoUpdate(@RequestBody VideoMasterInfoEntity info) {
        this.videoMasterInfoService.updateVideo(info);
        return new FebsResponse().success();
    }
 
    @PostMapping("/video/changeIsUp/{id}")
    @RequiresPermissions("source:update")
    @ControllerEndpoint(operation = "上下架", exceptionMessage = "上下架失败")
    public FebsResponse changeIsUp(@PathVariable("id") Long id) {
        this.videoMasterInfoService.changeIsUp(id);
        return new FebsResponse().success();
    }
 
}