作者 liyuhang

gx

... ... @@ -5,7 +5,23 @@ namespace App\Enums\Common;
use BenSampo\Enum\Contracts\LocalizedEnum;
use BenSampo\Enum\Enum;
/**
* 状态码类
* @method static static SUCCESS()
* @method static static USER_ERROR()
* @method static static USER_REGISTER_ERROE()
* @method static static USER_LOGIN_ERROE()
* @method static static USER_PERMISSION_ERROE()
* @method static static USER_PARAMS_ERROE()
* @method static static USER_UPLOAD_ERROE()
* @method static static USER_VERSION_ERROE()
* @method static static SYSTEM_ERROR()
* @method static static SYSTEM_TIMEOUT_ERROR()
* @method static static SERVER_ERROR()
* @method static static SERVER_MYSQL_ERROR()
* @method static static SERVER_REDIS_ERROR()
* @method static static USER_MODEL_NOTFOUND_ERROE()
*/
final class Code extends Enum implements LocalizedEnum
{
public $statusTexts = [
... ...
... ... @@ -34,7 +34,7 @@ class ComController extends BaseController
];
$validate = Validator::make($this->param, $rules, $message);
if($validate->errors()->first()){
return $this->response($validate->errors()->first(),'b00001',$this->param);
return $this->response($validate->errors()->first(),Code::USER_ERROR,$this->param);
}
//TODO::参数验
$comLogic = new ComLogic();
... ...
... ... @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
class MenuController extends BaseController
{
public function lists(){
... ... @@ -11,7 +13,7 @@ class MenuController extends BaseController
$userLogic = new UserLogic();
$lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']);
if(empty($lists)){
$this->response('请求失败','b00001',[]);
$this->response('请求失败',Code::USER_ERROR,[]);
}
$this->result($lists);
}
... ...
... ... @@ -22,7 +22,7 @@ class UserController extends BaseController
$userLogic = new UserLogic();
$lists = $userLogic->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']);
if(empty($lists)){
$this->response('请求失败','b00001',[]);
$this->response('请求失败',Code::USER_ERROR,[]);
}
$this->result($lists);
}
... ...
... ... @@ -19,27 +19,6 @@ class BaseLogic
}
/**
* @notes: 请简要描述方法功能
* @param array $data
* @return array
*/
public function success(array $data): array
{
return $data;
}
/**
* @notes: 错误抛出
* @param string $code
* @param string $message
* @throws AsideGlobalException
*/
public function fail(string $code = Code::SYSTEM_ERROR, $message = "")
{
throw new AsideGlobalException($code, $message);
}
/**
* @notes: 统一格式化分页返回
* @return array
*/
... ...