6 changed files with 143 additions and 15 deletions
-
38app/Controller/BaseController.php
-
99app/Controller/CouponController.php
-
4app/Model/Coupon.php
-
4app/Model/CouponRec.php
-
4app/Model/CouponUserRecType.php
-
9config/routes.php
@ -0,0 +1,38 @@ |
|||||
|
<?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); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue