feat: command
Some checks are pending
Build Docker / build (push) Waiting to run
Some checks are pending
Build Docker / build (push) Waiting to run
This commit is contained in:
47
app/Lib/AdminReturn.php
Normal file
47
app/Lib/AdminReturn.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
|
||||
use App\Constants\ReturnCode;
|
||||
|
||||
class AdminReturn
|
||||
{
|
||||
/**
|
||||
* 后台通用返回
|
||||
* @param string $msg
|
||||
* @param array $data
|
||||
* @param int $code
|
||||
* @param array $debug
|
||||
* @return array
|
||||
*/
|
||||
public static function success(string $msg = 'success', array $data = [], int $code = ReturnCode::SUCCESS, array $debug = []): array
|
||||
{
|
||||
$res = [
|
||||
'code' => $code,
|
||||
'message' => $msg,
|
||||
'data' => $data
|
||||
];
|
||||
|
||||
return array_merge($res, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用api返回
|
||||
* @param string $msg
|
||||
* @param array $data
|
||||
* @param int $code
|
||||
* @param array $debug
|
||||
* @return array
|
||||
*/
|
||||
public static function error(string $msg = 'error', array $data = [], int $code = ReturnCode::ERROR, array $debug = []): array
|
||||
{
|
||||
$res = [
|
||||
'code' => $code,
|
||||
'message' => $msg,
|
||||
'data' => $data
|
||||
];
|
||||
|
||||
return array_merge($res, $debug);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user