瀏覽代碼

feat: EK-2806: 会员端Promo和banner图增加分国家设置.

kevin 3 月之前
父節點
當前提交
b59b72f2d1

+ 4 - 3
backendApi/modules/v1/controllers/ArticleController.php

@@ -9,7 +9,7 @@ namespace backendApi\modules\v1\controllers;
 
 use backendApi\modules\v1\models\Admin;
 use backendApi\modules\v1\models\AdminCountry;
-use backendApi\modules\v1\models\lists\user\IndexList;
+use backendApi\modules\v1\models\lists\article\IndexList;
 use common\helpers\Cache;
 use common\helpers\Form;
 use common\models\Article;
@@ -106,8 +106,9 @@ class ArticleController extends BaseController
         }
 
         $filter = $this->filterCondition([
-            'TITLE' => 'TITLE',
-            'COUNTRY_ID' => 'COUNTRY_ID',
+            'ART.TITLE' => 'TITLE',
+            'ART.COUNTRY_ID' => 'COUNTRY_ID',
+            'ART.STATUS' => 'STATUS',
         ]);
         $condition = $filter['condition'];
         $params = $filter['params'];

+ 99 - 0
backendApi/modules/v1/models/lists/article/IndexList.php

@@ -0,0 +1,99 @@
+<?php
+namespace backendApi\modules\v1\models\lists\article;
+
+use backendApi\modules\v1\models\Admin;
+use backendApi\modules\v1\models\AdminCountry;
+use common\helpers\Cache;
+use common\helpers\http\BackendToFrontendApi;
+use common\helpers\LoggerTool;
+use common\libs\dataList\DataListInterface;
+use common\models\Article;
+use common\models\Countries;
+use common\models\DecRole;
+use common\models\EliteLevel;
+use common\models\EmployLevel;
+use common\models\Language;
+use common\models\OpenBank;
+use common\models\User;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\libs\dataList\column\YesNo;
+use Yii;
+
+class IndexList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '文章列表';
+    }
+
+    public function dataHandle()
+    {
+        $this->condition .= '';
+        $this->listData = Article::lists($this->condition, $this->params, [
+            'select' => 'ART.ID,ART.TITLE,ART.CID,ART.COUNTRY_ID,ART.STATUS,ART.SORT,ART.CREATED_AT,,ADC.NAME AS COUNTRY_NAME, ADC.CODE AS COUNTRY_CODE',
+            'from' => Article::tableName().' AS ART',
+            'join' => [
+                ['INNER JOIN', Countries::tableName() . ' AS ADC', 'ADC.ID=ART.COUNTRY_ID'],
+            ],
+            'orderBy' => 'ART.SORT ASC,ART.CREATED_AT DESC',
+        ]);
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if (!$this->filterTypes) {
+            $this->filterTypes = [
+                'TITLE'=> ['name'=> Yii::t('ctx', 'title')],
+                'COUNTRY'=> [
+                    'name'=> \Yii::t('ctx', 'country'),
+                    'other'=> 'select',
+                    'selectData'=> self::getCountry()
+                ],
+                'STATUS'=> [
+                    'name'=> Yii::t('ctx', 'activeStatus'),
+                    'other'=> 'select',
+                    'selectData'=> [
+                        ['id'=> 0, 'name'=> Yii::t('ctx', 'Hide')],
+                        ['id'=> 1, 'name'=> Yii::t('ctx', 'Show')]
+                    ]
+                ],
+            ];
+        }
+        return $this->filterTypes;
+    }
+
+    public function getCountry()
+    {
+        $admin = Admin::findOne(Yii::$app->user->id);
+        $roleId = $admin->ROLE_ID;
+        if ($roleId == \Yii::$app->params['superAdminRoleId']) {
+            $countries = Countries::find()->asArray()->all();
+        } else {
+            $countries = Countries::find()
+                ->select('COU.ID, COU.CODE, COU.NAME')
+                ->from(['COU' => Countries::tableName()])
+                ->join('INNER JOIN', AdminCountry::tableName() . ' AS ADL', 'ADL.COUNTRY_ID = COU.ID')
+                ->where(['ADL.ADMIN_ID' => $admin->ID])
+                ->asArray()
+                ->all();
+        }
+
+        $data = [];
+        foreach ($countries as $country) {
+            $data[] = [
+                'id' => $country['ID'],
+                'name' => $country['NAME'],
+            ];
+        }
+
+        return $data;
+    }
+}

+ 1 - 80
common/models/Article.php

@@ -2,10 +2,6 @@
 
 namespace common\models;
 
-use backendApi\modules\v1\models\Admin;
-use backendApi\modules\v1\models\AdminCountry;
-use common\helpers\Tool;
-use common\libs\dataList\DataListInterface;
 use Yii;
 
 /**
@@ -20,7 +16,7 @@ use Yii;
  * @property int $SORT 排序值
  * @property int $CREATED_AT 创建时间
  */
-class Article extends \common\libs\dataList\DataList implements DataListInterface
+class Article extends \common\components\ActiveRecord
 {
     /**
      * @inheritdoc
@@ -30,27 +26,6 @@ class Article extends \common\libs\dataList\DataList implements DataListInterfac
         return '{{%ARTICLE}}';
     }
 
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '会员列表';
-    }
-
-    public function dataHandle()
-    {
-        $this->condition .= '';
-        $this->listData = Article::lists($this->condition, $this->params, [
-            'select' => 'ART.ID,ART.TITLE,ART.CID,ART.COUNTRY_ID,ART.STATUS,ART.SORT,ART.CREATED_AT,,ADC.NAME AS COUNTRY_NAME, ADC.CODE AS COUNTRY_CODE',
-            'from' => Article::tableName().' AS ART',
-            'join' => [
-                ['INNER JOIN', Countries::tableName() . ' AS ADC', 'ADC.ID=ART.COUNTRY_ID'],
-            ],
-            'orderBy' => 'ART.SORT ASC,ART.CREATED_AT DESC',
-        ]);
-    }
-
     /**
      * @inheritdoc
      */
@@ -84,58 +59,4 @@ class Article extends \common\libs\dataList\DataList implements DataListInterfac
             'CREATED_AT' => Yii::t('app', 'createAt'),
         ];
     }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if (!$this->filterTypes) {
-            $this->filterTypes = [
-                'TITLE'=> ['name'=> Yii::t('ctx', 'title')],
-                'COUNTRY'=> [
-                    'name'=> \Yii::t('ctx', 'country'),
-                    'other'=> 'select',
-                    'selectData'=> self::getCountry()
-                ],
-                'STATUS'=> [
-                    'name'=> Yii::t('ctx', 'activeStatus'),
-                    'other'=> 'select',
-                    'selectData'=> [
-                        ['id'=> 0, 'name'=> Yii::t('ctx', 'Hide')],
-                        ['id'=> 1, 'name'=> Yii::t('ctx', 'Show')]
-                    ]
-                ],
-            ];
-        }
-        return $this->filterTypes;
-    }
-
-    public function getCountry()
-    {
-        $admin = Admin::findOne(Yii::$app->user->id);
-        $roleId = $admin->ROLE_ID;
-        if ($roleId == \Yii::$app->params['superAdminRoleId']) {
-            $countries = Countries::find()->asArray()->all();
-        } else {
-            $countries = Countries::find()
-                ->select('COU.ID, COU.CODE, COU.NAME')
-                ->from(['COU' => Countries::tableName()])
-                ->join('INNER JOIN', AdminCountry::tableName() . ' AS ADL', 'ADL.COUNTRY_ID = COU.ID')
-                ->where(['ADL.ADMIN_ID' => $admin->ID])
-                ->asArray()
-                ->all();
-        }
-
-        $data = [];
-        foreach ($countries as $country) {
-            $data[] = [
-                'id' => $country['ID'],
-                'name' => $country['NAME'],
-            ];
-        }
-
-        return $data;
-    }
 }