ZeroUserListResponseEntity.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\entity\admin\response\user;
  3. use app\entity\admin\response\AdminCommonResponseEntity;
  4. use think\response\Json;
  5. /**
  6. * 零号线用户响应实体
  7. * 继承自 AdminCommonResponseEntity,用于零号线用户相关操作的响应
  8. * 此接口只需要返回成功或失败状态
  9. */
  10. class ZeroUserListResponseEntity extends AdminCommonResponseEntity
  11. {
  12. /**
  13. * 创建零号线用户操作成功响应
  14. * @param null $data
  15. * @param string $message
  16. * @param int $code
  17. * @return AdminCommonResponseEntity
  18. */
  19. public static function success(string $message = '获取列表成功', int $code = 200, $data = null): AdminCommonResponseEntity {
  20. return parent::success($message);
  21. }
  22. /**
  23. * 创建零号线用户操作失败响应
  24. * @param string $message
  25. * @param int $code
  26. * @param null $data
  27. * @return AdminCommonResponseEntity
  28. */
  29. public static function error(string $message = '获取列表失败', int $code = 400, $data = null): AdminCommonResponseEntity {
  30. return parent::error($message, $code);
  31. }
  32. /**
  33. * @param bool $isPage
  34. * @param $data
  35. */
  36. public static function response(array $data, bool $isPage=true) : Json
  37. {
  38. // if (empty($data['data'])) {
  39. // return app('json')->fail(self::error()->toResponseArray());
  40. // }
  41. // 返回列表实体
  42. $list = parent::paginate($data['data'],$data['total'],$data['current_page'],$data['per_page']);
  43. return app('json')->success($list->toResponseArray());
  44. }
  45. }