RecruitCate.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. namespace app\operate\controller;
  3. use library\Controller;
  4. use library\service\MenuService;
  5. use library\tools\Data;
  6. use think\Db;
  7. /**
  8. * 招聘分类
  9. * Class RecruitCate
  10. * @package app\operate\controller
  11. */
  12. class RecruitCate extends Controller
  13. {
  14. /**
  15. * 绑定数据表
  16. * @var string
  17. */
  18. protected $table = 'RecruitCate';
  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)->where('is_deleted',0)->like('title')->where('pid',0)->order('sort desc,id asc')->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. * @param array $vo
  79. * @throws \ReflectionException
  80. * @throws \think\db\exception\DataNotFoundException
  81. * @throws \think\db\exception\ModelNotFoundException
  82. * @throws \think\exception\DbException
  83. */
  84. protected function _form_filter(&$data)
  85. {
  86. if($this->request->action() == 'edit') unset($data['pid']);
  87. }
  88. /**
  89. * 启用
  90. * @auth true
  91. * @menu true
  92. * @throws \think\Exception
  93. * @throws \think\exception\PDOException
  94. */
  95. public function resume()
  96. {
  97. $this->_save($this->table, ['status' => '1']);
  98. }
  99. /**
  100. * 禁用
  101. * @auth true
  102. * @menu true
  103. * @throws \think\Exception
  104. * @throws \think\db\exception\DataNotFoundException
  105. * @throws \think\db\exception\ModelNotFoundException
  106. * @throws \think\exception\DbException
  107. * @throws \think\exception\PDOException
  108. */
  109. public function forbid()
  110. {
  111. $this->_save($this->table, ['status' => '0']);
  112. }
  113. /**
  114. * 删除
  115. * @auth true
  116. * @menu true
  117. * @throws \think\Exception
  118. * @throws \think\exception\PDOException
  119. */
  120. public function remove()
  121. {
  122. $this->_save($this->table, ['is_deleted' => 1]);
  123. }
  124. /**
  125. * 二级分类列表
  126. * @auth true
  127. * @menu true
  128. * @throws \think\Exception
  129. * @throws \think\exception\PDOException
  130. */
  131. public function second(){
  132. $this->title ='二级分类';
  133. $pid = input('pid');
  134. $list = $this->_query('RecruitCate')
  135. ->where(['is_deleted'=>0,'pid'=>$pid])
  136. ->like('title')
  137. ->order('id desc')->page();
  138. $this->assign('list',$list);
  139. $this->fetch('');
  140. }
  141. /**
  142. * 三级分类列表
  143. * @auth true
  144. * @menu true
  145. * @throws \think\Exception
  146. * @throws \think\exception\PDOException
  147. */
  148. public function third(){
  149. $this->title ='三级分类';
  150. $pid = input('pid');
  151. $list = $this->_query('RecruitCate')
  152. ->where(['is_deleted'=>0,'pid'=>$pid])
  153. ->like('title')
  154. ->order('id desc')->page();
  155. $this->assign('list',$list);
  156. $this->fetch('');
  157. }
  158. }