统一规范状态码
This commit is contained in:
22
server/app/api/util/ReturnCode.php
Normal file
22
server/app/api/util/ReturnCode.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\api\util;
|
||||
|
||||
/**
|
||||
* API 状态码统一管理
|
||||
*/
|
||||
class ReturnCode
|
||||
{
|
||||
/** 200 成功 */
|
||||
public const SUCCESS = 200;
|
||||
|
||||
/** 201 请携带 token(auth-token / user-token) */
|
||||
public const MISSING_TOKEN = 201;
|
||||
|
||||
/** 202 缺少参数 / 参数错误 / 业务校验不通过(如余额不足、购买抽奖券错误等) */
|
||||
public const EMPTY_PARAMS = 202;
|
||||
|
||||
/** 203 token 过期或无效(auth-token / user-token 过期、缓存已过期等) */
|
||||
public const TOKEN_TIMEOUT = 203;
|
||||
}
|
||||
Reference in New Issue
Block a user