Quellcode durchsuchen

修复:强类型传参报错

小白菜白 vor 5 Jahren
Ursprung
Commit
04f21d2199

+ 2 - 2
app/admin/model/store/Api.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\admin\model\store;
 
@@ -117,7 +117,7 @@ class Api extends ApiModel
         $data = [];
         foreach ($list as $key => $item) {
             if ($item['parent_id'] == $parentId) {
-                $children = $this->getTreeData($list, $item['api_id']);
+                $children = $this->getTreeData($list, (int)$item['api_id']);
                 !empty($children) && $item['children'] = $children;
                 $data[] = $item;
                 unset($list[$key]);

+ 2 - 2
app/common/model/store/Menu.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\common\model\store;
 
@@ -82,7 +82,7 @@ class Menu extends BaseModel
         $data = [];
         foreach ($menuList as $key => $item) {
             if ($item['parent_id'] == $parentId) {
-                $children = $this->getTreeData($menuList, $item['menu_id']);
+                $children = $this->getTreeData($menuList, (int)$item['menu_id']);
                 !empty($children) && $item['children'] = $children;
                 $data[] = $item;
                 unset($menuList[$key]);

+ 2 - 7
app/common/model/store/User.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\common\model\store;
 
@@ -67,11 +67,6 @@ class User extends BaseModel
      */
     public static function detail($where, array $with = [])
     {
-        $model = (new static)->with($with);
-        if (is_array($where)) {
-            return $model->where($where)->find();
-        }
-        return $model->find($where);
+        return static::get($where, $with);
     }
-
 }

+ 2 - 2
app/common/service/store/User.php

@@ -42,7 +42,7 @@ class User extends BaseService
      */
     public static function getLoginUserId()
     {
-        return static::getLoginInfo()['user']['store_user_id'];
+        return (int)static::getLoginInfo()['user']['store_user_id'];
     }
 
     /**
@@ -53,7 +53,7 @@ class User extends BaseService
     public static function login(array $userInfo)
     {
         // 生成token
-        $token = self::makeToken((int)$userInfo['store_user_id']);
+        $token = self::makeToken((int)$userInfo['store_user_id']);
         // 记录缓存, 7天
         Cache::set($token, [
             'user' => $userInfo,

+ 2 - 2
app/store/controller/Passport.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\store\controller;
 
@@ -46,7 +46,7 @@ class Passport extends Controller
             return $this->renderError($model->getError() ?: '登录失败');
         }
         return $this->renderSuccess([
-            'userId' => $userInfo['store_user_id'],
+            'userId' => (int)$userInfo['store_user_id'],
             'token' => $model->getToken()
         ], '登录成功');
     }

+ 2 - 2
app/store/service/store/Role.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\store\service\store;
 
@@ -37,7 +37,7 @@ class Role extends BaseService
         // 获取当前登录用户的ID
         $userInfo = UserService::getLoginInfo();
         // 根据当前用户ID获取有权限的菜单列表
-        $permittedMenuList = static::getPermittedMenuList($userInfo['user']['store_user_id']);
+        $permittedMenuList = static::getPermittedMenuList((int)$userInfo['user']['store_user_id']);
         // 生成权限列表
         $permissions = static::buildPermissions($permittedMenuList);
         return [