HealthyFoodController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\validate\life\HealthyFoodValidate;
  4. use app\controller\Curd;
  5. use app\model\HealthyFood;
  6. use support\Request;
  7. use support\Response;
  8. class HealthyFoodController extends Curd
  9. {
  10. public function __construct()
  11. {
  12. $this->model = new HealthyFood();
  13. $this->validate = true;
  14. $this->validateClass = new HealthyFoodValidate();
  15. }
  16. /**
  17. * @Desc 列表
  18. * @Author Gorden
  19. * @Date 2024/2/29 10:26
  20. *
  21. * @param Request $request
  22. * @return Response
  23. * @throws \support\exception\BusinessException
  24. */
  25. public function select(Request $request): Response
  26. {
  27. [$where, $format, $limit, $field, $order] = $this->selectInput($request);
  28. $order = $request->get('order', 'desc');
  29. $field = $field ?? 'food_addTime';
  30. $where['food_is_del'] = 0;
  31. $query = $this->doSelect($where, $field, $order);
  32. return $this->doFormat($query, $format, $limit);
  33. }
  34. /**
  35. * @Desc 删除
  36. * @Author Gorden
  37. * @Date 2024/2/29 10:27
  38. *
  39. * @param Request $request
  40. * @return Response
  41. * @throws \support\exception\BusinessException
  42. */
  43. public function delete(Request $request): Response
  44. {
  45. $ids = $this->deleteInput($request);
  46. $this->doSoftDelete($ids, ['food_is_del' => 1]);
  47. return json_success('success');
  48. }
  49. /**
  50. * @Desc 修改状态
  51. * @Author Gorden
  52. * @Date 2024/2/29 10:29
  53. *
  54. * @param Request $request
  55. * @return Response
  56. */
  57. public function updateStatus(Request $request)
  58. {
  59. return $this->updateField($request->post('food_id'), 'food_status', $request->post('food_status'));
  60. }
  61. }