فهرست منبع

feat: EK-856: 管理员增加“Country”属性.

kevinElken 10 ماه پیش
والد
کامیت
fe3130f02c
1فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 12 0
      backendApi/modules/v1/controllers/SiteController.php

+ 12 - 0
backendApi/modules/v1/controllers/SiteController.php

@@ -7,6 +7,7 @@
  */
 namespace backendApi\modules\v1\controllers;
 
+use backendApi\modules\v1\models\AdminCountry;
 use common\helpers\snowflake\PageSnowFake;
 use common\helpers\Tool;
 use common\models\CurrencyConversions;
@@ -179,6 +180,17 @@ class SiteController extends BaseController
     {
         // 国家
         $countries = Cache::getCountries();
+
+        if (\Yii::$app->request->hasProperty('filter')) {
+            $filter = \Yii::$app->request->get('filter');
+            if ($filter) {
+                $adminId = Yii::$app->getUser()->getUserInfo()['id'];
+                $adminCountry = AdminCountry::getCountry($adminId);
+
+                $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
+            }
+        }
+
         // 货币
         $currencies = Cache::getCurrencies();
         $currencies = array_column($currencies, NULL, 'ID');