VideoCate.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. namespace app\Nutrition\controller;
  3. use library\Controller;
  4. use think\Db;
  5. use app\common\model\VideoCate as VCM;
  6. /**
  7. * 视频分类
  8. * Class VideoCate
  9. * @package app\Nutrition\controller
  10. */
  11. class VideoCate extends Controller
  12. {
  13. /**
  14. * 绑定数据表
  15. * @var string
  16. */
  17. protected $table = 'VideoCate';
  18. /**
  19. * 分类列表
  20. * @auth true
  21. * @menu true
  22. * @throws \think\Exception
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\ModelNotFoundException
  25. * @throws \think\exception\DbException
  26. * @throws \think\exception\PDOException
  27. */
  28. public function index()
  29. {
  30. $this->title = '分类管理';
  31. $query = $this->_query($this->table)->where('is_deleted',0)->like('title');
  32. $query->dateBetween('create_at')->order('status desc ,sort desc , id desc')->page();
  33. }
  34. /**
  35. * 数据列表处理
  36. * @auth true
  37. * @menu true
  38. * @param array $data
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. */
  43. protected function _index_page_filter(&$data)
  44. {
  45. }
  46. /**
  47. * 添加分类
  48. * @auth true
  49. * @menu true
  50. * @throws \think\Exception
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. * @throws \think\exception\DbException
  54. * @throws \think\exception\PDOException
  55. */
  56. public function add()
  57. {
  58. $this->title = '添加分类';
  59. $this->_form($this->table, 'form');
  60. }
  61. /**
  62. * 编辑分类
  63. * @auth true
  64. * @menu true
  65. * @throws \think\Exception
  66. * @throws \think\db\exception\DataNotFoundException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. * @throws \think\exception\DbException
  69. * @throws \think\exception\PDOException
  70. */
  71. public function edit()
  72. {
  73. $this->title = '编辑分类';
  74. $this->_form($this->table, 'form');
  75. }
  76. /**
  77. * 禁用
  78. * @auth true
  79. * @menu true
  80. * @throws \think\Exception
  81. * @throws \think\db\exception\DataNotFoundException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. * @throws \think\exception\DbException
  84. * @throws \think\exception\PDOException
  85. */
  86. public function forbidden()
  87. {
  88. $this->_save($this->table, ['status' => '0']);
  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 enable()
  101. {
  102. $this->_save($this->table, ['status' => 1]);
  103. }
  104. /**
  105. * 删除分类
  106. * @auth true
  107. * @menu true
  108. * @throws \think\Exception
  109. * @throws \think\db\exception\DataNotFoundException
  110. * @throws \think\db\exception\ModelNotFoundException
  111. * @throws \think\exception\DbException
  112. * @throws \think\exception\PDOException
  113. */
  114. public function del()
  115. {
  116. $this->_save($this->table, ['is_deleted' => 1]);
  117. }
  118. /**
  119. * 表单数据处理
  120. * @auth true
  121. * @menu true
  122. * @param array $data
  123. */
  124. protected function _form_filter(&$data)
  125. {
  126. }
  127. }