DatumCate.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. /**
  8. * 目录
  9. * Class DatumCate
  10. * @package app\nutrition\controller
  11. */
  12. class DatumCate extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'DatumCate';
  19. /**
  20. * 目录列表
  21. * @auth true
  22. * @menu true
  23. * @throws \think\Exception
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. * @throws \think\exception\PDOException
  28. */
  29. public function index()
  30. {
  31. $this->title = '目录列表';
  32. $query = $this->_query($this->table)
  33. ->like('title')
  34. ->where('is_deleted',0)->order('sort desc,id asc')->page(false);
  35. }
  36. /**
  37. * 添加目录
  38. * @auth true
  39. * @menu true
  40. * @throws \think\Exception
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @throws \think\exception\DbException
  44. * @throws \think\exception\PDOException
  45. */
  46. public function add()
  47. {
  48. $this->title = '添加目录';
  49. $this->_form($this->table, 'form');
  50. }
  51. /**
  52. * 编辑目录
  53. * @auth true
  54. * @menu true
  55. * @throws \think\Exception
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. * @throws \think\exception\PDOException
  60. */
  61. public function edit()
  62. {
  63. $this->title = '编辑目录';
  64. $this->_form($this->table, 'form');
  65. }
  66. /**
  67. * 表单数据处理
  68. * @param array $vo
  69. * @throws \ReflectionException
  70. * @throws \think\db\exception\DataNotFoundException
  71. * @throws \think\db\exception\ModelNotFoundException
  72. * @throws \think\exception\DbException
  73. */
  74. protected function _form_filter(&$vo)
  75. {
  76. }
  77. /**
  78. * 启用
  79. * @auth true
  80. * @menu true
  81. * @throws \think\Exception
  82. * @throws \think\exception\PDOException
  83. */
  84. public function resume()
  85. {
  86. $this->_save($this->table, ['status' => '1']);
  87. }
  88. /**
  89. * 禁用
  90. * @auth true
  91. * @menu true
  92. * @throws \think\Exception
  93. * @throws \think\db\exception\DataNotFoundException
  94. * @throws \think\db\exception\ModelNotFoundException
  95. * @throws \think\exception\DbException
  96. * @throws \think\exception\PDOException
  97. */
  98. public function forbid()
  99. {
  100. $this->_save($this->table, ['status' => '0']);
  101. }
  102. /**
  103. * 删除
  104. * @auth true
  105. * @menu true
  106. * @throws \think\Exception
  107. * @throws \think\exception\PDOException
  108. */
  109. public function remove()
  110. {
  111. $this->_save($this->table, ['is_deleted' => 1]);
  112. }
  113. }