You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
declare(strict_types=1);/** * This file is part of Hyperf. * * @link https://www.hyperf.io * @document https://doc.hyperf.io * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */namespace App\Controller;
use Hyperf\HttpServer\Contract\ResponseInterface;use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
class BaseController extends AbstractController{ public function result($code, $data, $message = '成功'):Psr7ResponseInterface { $status = 'ok'; if($code>0){ $status = 'error'; } $content = [ "status"=>$status, "code" => $code, "result" => $data ? collect($data)->toArray() : [], "message" => $message ]; return $this->response->json($content); }
public function success($data, $message = '成功') { return $this->result(0,$data, $message); }}
|