route()->getActionName(); $flag = preg_match("/Controllers\\\(.*)@(.*)/",$controllerName,$match); if($flag){ $controllerName = $match[1]; $actionName = $match[2]; $class = "\\App\\Http\\Validate\\$controllerName"."Validate"; //判断验证是否存在 if(class_exists($class) && method_exists($class,$actionName)){ $instance = new $class(); $validateFlag = $instance->$actionName($request->all()); if(!$validateFlag){ throw new ValidateException($instance->getError(),501); } } } } /** * 成功返回 * @param array $data * @param int $code * @param string $msg * @param string $url * @return \Illuminate\Http\JsonResponse */ public function success($data = [], $code = 200, $msg = "", $url = "") { return response()->json( [ "status"=>true, "data"=>$data, "code"=>$code, "msg"=>$msg, "url"=>$url ] ); } /** * 错误返回 * @param $msg * @param string $code * @param string $url */ public function error($msg,$code="500",$url="") { return response()->json( [ "status"=>false, "data"=>"", "code"=>$code, "msg"=>$msg, "url"=>$url ] ); } /** * 生成swagger.json文件 */ public function swagger() { $swagger=\Swagger\scan(__DIR__."/../"); $swagger->saveAs('./swagger.json'); return $this->success(); } /** * 读取swagger内容 */ public function loadSwagger() { $data = json_decode(file_get_contents("./swagger.json"),true); return $data; } public function test() { // $data = TaobaoLianMengUtil::getActivityInfo("111538400047","20150318020002597"); $data = MeituanLianmengUtil::generateLink(22,"ceshi",MeiTuanLinkTypeEnum::MINIPROGRAME,env("MEITUAN_LIANMENG_KEY")); // $data = WechatAccountModel::findByWechatAppCode("fanbuting"); return $data; } }