正在显示
5 个修改的文件
包含
22 行增加
和
25 行删除
| @@ -5,7 +5,23 @@ namespace App\Enums\Common; | @@ -5,7 +5,23 @@ namespace App\Enums\Common; | ||
| 5 | use BenSampo\Enum\Contracts\LocalizedEnum; | 5 | use BenSampo\Enum\Contracts\LocalizedEnum; |
| 6 | use BenSampo\Enum\Enum; | 6 | use BenSampo\Enum\Enum; |
| 7 | 7 | ||
| 8 | - | 8 | +/** |
| 9 | + * 状态码类 | ||
| 10 | + * @method static static SUCCESS() | ||
| 11 | + * @method static static USER_ERROR() | ||
| 12 | + * @method static static USER_REGISTER_ERROE() | ||
| 13 | + * @method static static USER_LOGIN_ERROE() | ||
| 14 | + * @method static static USER_PERMISSION_ERROE() | ||
| 15 | + * @method static static USER_PARAMS_ERROE() | ||
| 16 | + * @method static static USER_UPLOAD_ERROE() | ||
| 17 | + * @method static static USER_VERSION_ERROE() | ||
| 18 | + * @method static static SYSTEM_ERROR() | ||
| 19 | + * @method static static SYSTEM_TIMEOUT_ERROR() | ||
| 20 | + * @method static static SERVER_ERROR() | ||
| 21 | + * @method static static SERVER_MYSQL_ERROR() | ||
| 22 | + * @method static static SERVER_REDIS_ERROR() | ||
| 23 | + * @method static static USER_MODEL_NOTFOUND_ERROE() | ||
| 24 | + */ | ||
| 9 | final class Code extends Enum implements LocalizedEnum | 25 | final class Code extends Enum implements LocalizedEnum |
| 10 | { | 26 | { |
| 11 | public $statusTexts = [ | 27 | public $statusTexts = [ |
| @@ -34,7 +34,7 @@ class ComController extends BaseController | @@ -34,7 +34,7 @@ class ComController extends BaseController | ||
| 34 | ]; | 34 | ]; |
| 35 | $validate = Validator::make($this->param, $rules, $message); | 35 | $validate = Validator::make($this->param, $rules, $message); |
| 36 | if($validate->errors()->first()){ | 36 | if($validate->errors()->first()){ |
| 37 | - return $this->response($validate->errors()->first(),'b00001',$this->param); | 37 | + return $this->response($validate->errors()->first(),Code::USER_ERROR,$this->param); |
| 38 | } | 38 | } |
| 39 | //TODO::参数验 | 39 | //TODO::参数验 |
| 40 | $comLogic = new ComLogic(); | 40 | $comLogic = new ComLogic(); |
| @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Bside; | @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Bside; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | +use App\Enums\Common\Code; | ||
| 8 | + | ||
| 7 | class MenuController extends BaseController | 9 | class MenuController extends BaseController |
| 8 | { | 10 | { |
| 9 | public function lists(){ | 11 | public function lists(){ |
| @@ -11,7 +13,7 @@ class MenuController extends BaseController | @@ -11,7 +13,7 @@ class MenuController extends BaseController | ||
| 11 | $userLogic = new UserLogic(); | 13 | $userLogic = new UserLogic(); |
| 12 | $lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']); | 14 | $lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']); |
| 13 | if(empty($lists)){ | 15 | if(empty($lists)){ |
| 14 | - $this->response('请求失败','b00001',[]); | 16 | + $this->response('请求失败',Code::USER_ERROR,[]); |
| 15 | } | 17 | } |
| 16 | $this->result($lists); | 18 | $this->result($lists); |
| 17 | } | 19 | } |
| @@ -22,7 +22,7 @@ class UserController extends BaseController | @@ -22,7 +22,7 @@ class UserController extends BaseController | ||
| 22 | $userLogic = new UserLogic(); | 22 | $userLogic = new UserLogic(); |
| 23 | $lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']); | 23 | $lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']); |
| 24 | if(empty($lists)){ | 24 | if(empty($lists)){ |
| 25 | - $this->response('请求失败','b00001',[]); | 25 | + $this->response('请求失败',Code::USER_ERROR,[]); |
| 26 | } | 26 | } |
| 27 | $this->result($lists); | 27 | $this->result($lists); |
| 28 | } | 28 | } |
| @@ -19,27 +19,6 @@ class BaseLogic | @@ -19,27 +19,6 @@ class BaseLogic | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | - * @notes: 请简要描述方法功能 | ||
| 23 | - * @param array $data | ||
| 24 | - * @return array | ||
| 25 | - */ | ||
| 26 | - public function success(array $data): array | ||
| 27 | - { | ||
| 28 | - return $data; | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * @notes: 错误抛出 | ||
| 33 | - * @param string $code | ||
| 34 | - * @param string $message | ||
| 35 | - * @throws AsideGlobalException | ||
| 36 | - */ | ||
| 37 | - public function fail(string $code = Code::SYSTEM_ERROR, $message = "") | ||
| 38 | - { | ||
| 39 | - throw new AsideGlobalException($code, $message); | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - /** | ||
| 43 | * @notes: 统一格式化分页返回 | 22 | * @notes: 统一格式化分页返回 |
| 44 | * @return array | 23 | * @return array |
| 45 | */ | 24 | */ |
-
请 注册 或 登录 后发表评论