ソースを参照

增加根据城市ID获取模板名称接口

duqinya 6 年 前
コミット
888182c517
共有3 個のファイルを変更した21 個の追加0 個の削除を含む
  1. 13 0
      app/Http/Controllers/CmsContentTemplateSetController.php
  2. 6 0
      app/Repositories/CmsContentTemplateSetRepository.php
  3. 2 0
      routes/api.php

+ 13 - 0
app/Http/Controllers/CmsContentTemplateSetController.php

@@ -115,5 +115,18 @@ class CmsContentTemplateSetController extends BaseController
 
     }
 
+    //根据城市ID获取首页模板名称
+    public function templateName(Request $request)
+    {
+        $validator = Validator::make($request->all(), [
+            'city_id' => 'required|integer'
+        ]);
+        if ($validator->fails()) {
+            return $this->response->error($validator->errors()->first(), 500);
+        }
+        return $this->cmsContentSetTemplate->getTemplate($request->only('city_id'));
+
+    }
+
 
 }

+ 6 - 0
app/Repositories/CmsContentTemplateSetRepository.php

@@ -217,4 +217,10 @@ class CmsContentTemplateSetRepository {
 
     }
 
+    public function getTemplate($cityId)
+    {
+        return $this->cmsContentTemplate->select('title','apply_type')->where(['city_id'=>$cityId,'is_open'=>1])->orderBy('apply_type','asc')->get();
+
+    }
+
 }

+ 2 - 0
routes/api.php

@@ -81,5 +81,7 @@ $api->version('v1', [
         //内容预览
         $api->post('/templateSet/preview', 'CmsContentTemplateSetController@preview');
 
+        //获取对应城市模板名称
+        $api->post('templateName', 'CmsContentTemplateSetController@templateName');
     });
 });