浏览代码

feat: policy estate

jiangzixin 1 年之前
父节点
当前提交
95cbc5bdb2

+ 1 - 1
server/api/modules/v1/controllers/SurveyController.php

@@ -345,7 +345,7 @@ class SurveyController extends Controller {
 
 
         foreach($list as $k => $v){
-            $zclist = Policy::find()->where(['type' => Policy::TYPE_SURVEY])->andWhere(['like','cengci',"{$v['level']}"])->all();
+            $zclist = Policy::find()->where(['type' => Policy::TYPE_SURVEY, 'estate' => $type])->andWhere(['like','cengci',"{$v['level']}"])->all();
             $list[$k]['policy'] = $zclist;
         }
 

+ 9 - 2
server/backend/controllers/PolicyController.php

@@ -3,6 +3,7 @@
 namespace backend\controllers;
 
 use common\components\Controller;
+use common\enums\PolicyEnum;
 use common\models\Policy;
 use Yii;
 use yii\base\Exception;
@@ -111,7 +112,8 @@ class PolicyController extends Controller
             }
             return $this->goBack();
 		}
-    
+
+        $model->estate = PolicyEnum::POLICY_INDUSTRY;// 默认现代产业
 		return $this->render('create', [
 			'model' => $model,
 			'configModels' => $configModels,
@@ -189,6 +191,11 @@ class PolicyController extends Controller
 	    $model->type = explode(',',$model->type);
 //		$model->filter = $filterArr;
         $model->filter = json_decode($model->filter,true);
+
+        if (empty($model->estate)) {
+            $model->estate = PolicyEnum::POLICY_INDUSTRY;//默认现代产业
+        }
+
 		return $this->render('update', [
 			'model' => $model,
 			'configModels' => $configModels,
@@ -216,7 +223,7 @@ class PolicyController extends Controller
      *
      * @param int $id
      *
-     * @return Survey the loaded model
+     * @return Policy the loaded model
      *
      * @throws NotFoundHttpException if the model cannot be found
      */

+ 1 - 0
server/backend/views/policy/_form.php

@@ -17,6 +17,7 @@ use backend\widgets\ActiveForm;
         <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
         <?= $form->field($model, 'author')->textInput(['maxlength' => true]) ?>
         <?= $form->field($model, 'type')->checkboxList(\common\models\Policy::getTypeList()) ?>
+        <?= $form->field($model, 'estate')->radioList(\common\enums\PolicyEnum::$list) ?>
 		<?php
 
         foreach ($configModels as $index => $configModel) {

+ 18 - 0
server/common/enums/PolicyEnum.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace common\enums;
+
+class PolicyEnum
+{
+    const POLICY_INDUSTRY = 'industry';
+    const POLICY_EDUCATION = 'education';
+    const POLICY_MEDICAL = 'medical';
+    const POLICY_CIRCUIT = 'circuit';
+
+    public static $list = [
+        self::POLICY_INDUSTRY => '现代产业',
+        self::POLICY_EDUCATION => '高等教育',
+        self::POLICY_MEDICAL => '医疗卫生',
+        self::POLICY_CIRCUIT => '集成电路',
+    ];
+}

+ 3 - 1
server/common/models/Policy.php

@@ -18,6 +18,7 @@ use yii\helpers\StringHelper;
  * @property string $cengci
  * @property integer $markdown
  * @property string $type
+ * @property string $estate
  */
 class Policy extends \yii\db\ActiveRecord
 {
@@ -48,7 +49,7 @@ class Policy extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['content', 'title', 'summary', 'type','cengci'], 'required'],
+            [['content', 'title', 'summary', 'type','cengci', 'estate'], 'required'],
             [['content'], 'string'],
 			[['filter','cengci'], 'string'],
             ['markdown', 'default', 'value' => $this->getIsMarkdown()],
@@ -95,6 +96,7 @@ class Policy extends \yii\db\ActiveRecord
             'title' => '标题',
             'author'=>'作者',
             'type'=>'类型',//类型:0 匹配,1 查询
+            'estate'=>'产业',
             'created_at'=>'发布时间'
         ];
     }

+ 1 - 0
server/database/202310291848

@@ -0,0 +1 @@
+ALTER TABLE `dd_policy` ADD `estate` VARCHAR(255) NOT NULL  DEFAULT 'industry' COMMENT '产业分类' AFTER `type`;