作者 Your Name

gx

@@ -110,14 +110,6 @@ class Handler extends ExceptionHandler @@ -110,14 +110,6 @@ class Handler extends ExceptionHandler
110 $code = $exception->getCode(); 110 $code = $exception->getCode();
111 }elseif ($exception instanceof BsideGlobalException) { 111 }elseif ($exception instanceof BsideGlobalException) {
112 $code = $exception->getCode(); 112 $code = $exception->getCode();
113 - } elseif ($exception instanceof ValidationException) {  
114 - $code = Code::USER_PARAMS_ERROE();  
115 - } elseif ($exception instanceof \RedisException) {  
116 - $code = Code::SERVER_REDIS_ERROR();  
117 - } elseif ($exception instanceof \PDOException) {  
118 - $code = Code::SERVER_MYSQL_ERROR();  
119 - } elseif ($exception instanceof ModelNotFoundException) {  
120 - $code = Code::USER_MODEL_NOTFOUND_ERROE();  
121 } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) { 113 } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) {
122 return response('404 Not Found', 404); 114 return response('404 Not Found', 404);
123 } else { 115 } else {
@@ -31,25 +31,12 @@ class BaseController extends Controller @@ -31,25 +31,12 @@ class BaseController extends Controller
31 $this->request = $request; 31 $this->request = $request;
32 $this->param = $this->request->all(); 32 $this->param = $this->request->all();
33 $this->token = $this->request->header('token'); 33 $this->token = $this->request->header('token');
34 - $this->get_param();  
35 - $this->auth_token();  
36 - }  
37 -  
38 - /**  
39 - * @name  
40 - * @return void  
41 - * @author :liyuhang  
42 - * @method  
43 - */  
44 - public function auth_token(){ 34 + if(!empty($this->token) && !empty(Cache::get($this->token))){
45 $info = Cache::get($this->token); 35 $info = Cache::get($this->token);
46 - if(!empty($info)){  
47 $this->user = $info; 36 $this->user = $info;
48 $this->uid = $info['id']; 37 $this->uid = $info['id'];
49 - }else{  
50 - $this->response('当前用户未登录',Code::USER_ERROR);  
51 } 38 }
52 - 39 + $this->get_param();
53 } 40 }
54 /** 41 /**
55 * 成功返回 42 * 成功返回
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Logic\Bside\UserLogic; 6 use App\Http\Logic\Bside\UserLogic;
7 use App\Models\User as UserModel; 7 use App\Models\User as UserModel;
  8 +use Illuminate\Support\Facades\Cache;
8 use Illuminate\Support\Facades\Response; 9 use Illuminate\Support\Facades\Response;
9 use Illuminate\Support\Facades\Validator; 10 use Illuminate\Support\Facades\Validator;
10 use Symfony\Component\HttpFoundation; 11 use Symfony\Component\HttpFoundation;
@@ -25,8 +26,7 @@ class UserController extends BaseController @@ -25,8 +26,7 @@ class UserController extends BaseController
25 if(empty($lists)){ 26 if(empty($lists)){
26 $this->response('请求失败',Code::USER_ERROR,[]); 27 $this->response('请求失败',Code::USER_ERROR,[]);
27 } 28 }
28 - $this->allCount = $userModel->allCount;  
29 - $this->result($lists); 29 + $this->response('列表',Code::SUCCESS,$lists);
30 } 30 }
31 31
32 /** 32 /**
@@ -23,11 +23,15 @@ class LoginAuthMiddleware @@ -23,11 +23,15 @@ class LoginAuthMiddleware
23 { 23 {
24 $token = $request->header('token'); 24 $token = $request->header('token');
25 if(!isset($token) || empty($token)){ 25 if(!isset($token) || empty($token)){
26 - $this->response('当前用户未登录',Code::USER_ERROR); 26 + $res = [
  27 + 'code'=>'A00010',
  28 + 'msg' =>'当前用户未登录'
  29 + ];
  30 + return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']);
27 } 31 }
28 $info = Cache::get($token); 32 $info = Cache::get($token);
29 if(empty($info)){ 33 if(empty($info)){
30 - $this->response('当前用户未登录',Code::USER_ERROR); 34 + return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']);
31 } 35 }
32 //操作权限设置 36 //操作权限设置
33 $projectRoleModel = new ProjectRoleModel(); 37 $projectRoleModel = new ProjectRoleModel();
@@ -39,27 +43,10 @@ class LoginAuthMiddleware @@ -39,27 +43,10 @@ class LoginAuthMiddleware
39 $menu_id = $projectMenuModel->read(['action'=>$action['as']],['id']); 43 $menu_id = $projectMenuModel->read(['action'=>$action['as']],['id']);
40 if($menu_id !== false){ 44 if($menu_id !== false){
41 if(strpos($role_info['role_menu'], $menu_id['id']) < 0){ 45 if(strpos($role_info['role_menu'], $menu_id['id']) < 0){
42 - $this->response('当前用户没有权限',Code::USER_ERROR); 46 + return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户没有权限']);
43 } 47 }
44 } 48 }
45 return $next($request); 49 return $next($request);
46 } 50 }
47 - /**  
48 - * @name 统一返回参数  
49 - * @return void  
50 - * @author :liyuhang  
51 - * @method  
52 - */  
53 - public function response($msg,$code,$data = [],$result_code = 200,$type = 'application/json'){  
54 - $code === null && $code = $result_code;  
55 - $result = [  
56 - 'msg' =>$msg,  
57 - 'code'=>$code,  
58 - 'data'=>$data  
59 - ];  
60 - $header['token'] = $type;  
61 - $response = response($result,$result_code,$header);  
62 - throw new HttpResponseException($response);  
63 - }  
64 51
65 } 52 }
@@ -37,7 +37,7 @@ class Base extends Model @@ -37,7 +37,7 @@ class Base extends Model
37 */ 37 */
38 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){ 38 public function lists($map, $p, $row, $order = 'id', $fields = ['*']){
39 //TODO::where(['id'=>'','name'=>'']) 39 //TODO::where(['id'=>'','name'=>''])
40 - $lists = $this->select($fields)->where($map)->forPage($p,$row)->orderBy($order)->get(); 40 + $lists = DB::table($this->table)->select($fields)->where($map)->orderBy($order)->paginate($row, ['*'], 'page', $p);
41 if (empty($lists)) { 41 if (empty($lists)) {
42 return false; 42 return false;
43 } 43 }
@@ -14,5 +14,5 @@ use Illuminate\Support\Facades\Route; @@ -14,5 +14,5 @@ use Illuminate\Support\Facades\Route;
14 */ 14 */
15 15
16 Route::get('/', function () { 16 Route::get('/', function () {
17 - return view('welcome'); 17 +// return view('welcome');
18 }); 18 });