xielin 6 years ago
parent
commit
6a3934a687

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

@@ -33,5 +33,21 @@ class CmsContentTemplateSetController extends BaseController
 
     }
 
+    /**
+     * 获取城市模板名称及类型
+     * @param Request $request
+     * @return array
+     */
+    public function template(Request $request){
+        $validator = Validator::make($request->all(), [
+            'city_id' => 'required|integer'
+        ]);
+        if ($validator->fails()) {
+            return $this->jsonError($validator->errors()->first());
+        }
+        return $this->jsonSuccess($this->cmsContentSetTemplate->getTemplate($request->only('city_id')));
+    }
+
+
 
 }

+ 4 - 0
app/Http/Repositories/CmsContentTemplateSetRepository.php

@@ -95,4 +95,8 @@ class CmsContentTemplateSetRepository {
         return $group_array;
 
     }
+
+    public function getTemplate($cityId){
+        return $this->cmsContentTemplate->select('title','id')->where(['city_id'=>$cityId,'is_open'=>0])->get();
+    }
 }

+ 1 - 1
routes/api.php

@@ -22,8 +22,8 @@ $api->version('v1', [
     });
     //仅验签
     $api->group(['middleware' => 'chxq_sign'], function ($api) {
-
         //内容预览
         $api->post('/templateSet/preview', 'CmsContentTemplateSetController@preview');
+        $api->post('/templateSet/templateName', 'CmsContentTemplateSetController@template');
     });
 });