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();
|
}
|
|
}
|