VideoClassify.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. namespace app\Nutrition\controller;
  3. use library\Controller;
  4. use library\service\MenuService;
  5. use library\tools\Data;
  6. use think\Db;
  7. use think\db\Where;
  8. /**
  9. * 分类
  10. * Class VideoClassify
  11. * @package app\nutrition\controller
  12. */
  13. class VideoClassify extends Controller
  14. {
  15. /**
  16. * 绑定数据表
  17. * @var string
  18. */
  19. protected $table = 'SeriesVideoCate';
  20. /**
  21. * 分类列表
  22. * @auth true
  23. * @menu true
  24. * @throws \think\Exception
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\ModelNotFoundException
  27. * @throws \think\exception\DbException
  28. * @throws \think\exception\PDOException
  29. */
  30. public function index()
  31. {
  32. $this->title = '分类列表';
  33. $query = $this->_query($this->table)->where('is_deleted',0)->like('title')
  34. ->where('pid',0)
  35. ->order('sort desc,id asc')->page();
  36. }
  37. /**
  38. * 添加分类
  39. * @auth true
  40. * @menu true
  41. * @throws \think\Exception
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @throws \think\exception\DbException
  45. * @throws \think\exception\PDOException
  46. */
  47. public function add()
  48. {
  49. $this->title = '添加分类';
  50. $this->_form($this->table, 'form');
  51. }
  52. /**
  53. * 编辑分类
  54. * @auth true
  55. * @menu true
  56. * @throws \think\Exception
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\ModelNotFoundException
  59. * @throws \think\exception\DbException
  60. * @throws \think\exception\PDOException
  61. */
  62. public function edit()
  63. {
  64. $this->title = '编辑分类';
  65. $this->_form($this->table, 'form');
  66. }
  67. /**
  68. * 表单数据处理
  69. * @param array $vo
  70. * @throws \ReflectionException
  71. * @throws \think\db\exception\DataNotFoundException
  72. * @throws \think\db\exception\ModelNotFoundException
  73. * @throws \think\exception\DbException
  74. */
  75. protected function _form_filter(&$data)
  76. {
  77. if($this->request->action() == 'edit') unset($data['pid']);
  78. }
  79. /**
  80. * 启用
  81. * @auth true
  82. * @menu true
  83. * @throws \think\Exception
  84. * @throws \think\exception\PDOException
  85. */
  86. public function resume()
  87. {
  88. $this->_save($this->table, ['status' => '1']);
  89. }
  90. /**
  91. * 禁用
  92. * @auth true
  93. * @menu true
  94. * @throws \think\Exception
  95. * @throws \think\db\exception\DataNotFoundException
  96. * @throws \think\db\exception\ModelNotFoundException
  97. * @throws \think\exception\DbException
  98. * @throws \think\exception\PDOException
  99. */
  100. public function forbid()
  101. {
  102. $this->_save($this->table, ['status' => '0']);
  103. }
  104. /**
  105. * 删除
  106. * @auth true
  107. * @menu true
  108. * @throws \think\Exception
  109. * @throws \think\exception\PDOException
  110. */
  111. public function remove()
  112. {
  113. $this->_save($this->table, ['is_deleted' => 1]);
  114. }
  115. /**
  116. * 二级分类列表
  117. * @auth true
  118. * @menu true
  119. * @throws \think\Exception
  120. * @throws \think\exception\PDOException
  121. */
  122. public function second(){
  123. $this->title ='二级分类';
  124. $pid = input('pid');
  125. $list = $this->_query('SeriesVideoCate')
  126. ->where(['is_deleted'=>0,'pid'=>$pid])
  127. ->like('title')
  128. ->order('id desc')->page();
  129. $this->assign('list',$list);
  130. $this->fetch('');
  131. }
  132. }