正在显示
5 个修改的文件
包含
22 行增加
和
7 行删除
| @@ -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 = [ |
| @@ -32,8 +32,6 @@ class BaseController extends Controller | @@ -32,8 +32,6 @@ class BaseController extends Controller | ||
| 32 | $this->token = $this->request->header('token'); | 32 | $this->token = $this->request->header('token'); |
| 33 | $this->get_param(); | 33 | $this->get_param(); |
| 34 | $this->auth_token(); | 34 | $this->auth_token(); |
| 35 | - | ||
| 36 | - return $this->success(); | ||
| 37 | } | 35 | } |
| 38 | 36 | ||
| 39 | /** | 37 | /** |
| @@ -47,7 +45,6 @@ class BaseController extends Controller | @@ -47,7 +45,6 @@ class BaseController extends Controller | ||
| 47 | if(isset($info) && !empty($info)){ | 45 | if(isset($info) && !empty($info)){ |
| 48 | $this->uid = $info['id']; | 46 | $this->uid = $info['id']; |
| 49 | } | 47 | } |
| 50 | - | ||
| 51 | } | 48 | } |
| 52 | /** | 49 | /** |
| 53 | * 成功返回 | 50 | * 成功返回 |
| @@ -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 | } |
-
请 注册 或 登录 后发表评论