Video.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\logic\VideoLogic;
  4. use app\BaseController;
  5. use think\exception\ValidateException;
  6. use think\facade\Config;
  7. use think\facade\Validate;
  8. //视频
  9. class Video extends BaseController
  10. {
  11. //获取视频列表
  12. public function list()
  13. {
  14. $param = $this->request->only([
  15. 'page' => 1,
  16. 'size' => 10,
  17. 'status' => '',
  18. 'video_sn' => '',
  19. 'video_name' => '',
  20. 'video_url' => '',
  21. ], 'post');
  22. return VideoLogic::list($param);
  23. }
  24. //添加视频
  25. public function add()
  26. {
  27. $param = $this->request->only([
  28. 'video_name',
  29. 'video_url',
  30. 'video_img',
  31. 'weight' => '',
  32. 'remark' => '',
  33. ], 'post');
  34. $val = Validate::rule(Config::get('validate_rules.videoAdd'));
  35. if (!$val->check($param)) throw new ValidateException($val->getError());
  36. return VideoLogic::add($param);
  37. }
  38. //读取视频详情
  39. public function read()
  40. {
  41. $id = $this->request->post('id/d', 0);
  42. return VideoLogic::read($id);
  43. }
  44. //编辑视频
  45. public function edit()
  46. {
  47. $param = $this->request->only([
  48. 'id',
  49. 'video_name',
  50. 'video_url',
  51. 'video_img',
  52. 'weight' => '',
  53. 'remark' => '',
  54. ], 'post');
  55. $val = Validate::rule(Config::get('validate_rules.videoEdit'));
  56. if (!$val->check($param)) throw new ValidateException($val->getError());
  57. return VideoLogic::edit($param);
  58. }
  59. //视频启禁用
  60. public function change()
  61. {
  62. $param = $this->request->only(['id', 'status',], 'post');
  63. $val = Validate::rule(Config::get('validate_rules.status'));
  64. if (!$val->check($param)) throw new ValidateException($val->getError());
  65. return VideoLogic::change($param);
  66. }
  67. //删除视频
  68. public function delete()
  69. {
  70. $id = $this->request->post('id/d', 0);
  71. return VideoLogic::delete($id);
  72. }
  73. }