Helius
2021-12-14 37e53ee529f13b6058698eb97390dca1752843bb
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
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.VideoMasterSourceEntity;
import cc.mrbird.febs.video.service.IVideoCategoryService;
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;
 
    @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")
    public FebsResponse addVideoSource(VideoMasterSourceEntity source) {
        this.videoMasterSourceService.save(source);
        return new FebsResponse().success();
    }
 
    @PostMapping("/source/update")
    @RequiresPermissions("source:update")
    public FebsResponse updateVideoSource(VideoMasterSourceEntity source) {
        this.videoMasterSourceService.modifySourceById(source);
        return new FebsResponse().success();
    }
 
    @GetMapping("/source/delete/{ids}")
    @RequiresPermissions("source:delete")
    public FebsResponse delSource(@PathVariable String ids) {
        this.videoMasterSourceService.delSource(ids);
        return new FebsResponse().success();
    }
 
}