chenhao 4 anni fa
parent
commit
9b4c069fd0

+ 179 - 0
application/api/controller/Building.php

@@ -0,0 +1,179 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use app\common\model\BuildingModel;
+use app\common\model\BusinessModel;
+use think\Db;
+
+/**
+ * 智慧党建
+ */
+class Building extends Api
+{
+    protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 智慧党建轮播图
+     */
+    public function banner()
+    {
+        $data = Db::name('building_banner')
+            ->where('switch',1)
+            ->order('sort desc')
+            ->select();
+
+        if ($data) {
+            foreach ($data as &$v) {
+                $v['image'] = config('site.httpurl') . $v['image'];
+            }
+            return $this->success('', $data);
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+
+    /**
+     * 党建资讯列表
+     * @param string $page 页数
+     * @param string $limit 条数
+     */
+    public function lists()
+    {
+
+        $page = $this->request->get('page');
+
+        $limit = $this->request->get('limit');
+
+        if (!$page) {
+            $pages = '0,10';
+        } else {
+            $page = $page - 1;
+            if ($page < 0) $page = 0;
+            $pages = $page . ',' . $limit;
+        }
+
+        $buildingModel = new BuildingModel();
+
+        $data = $buildingModel->where('switch', 1)
+            ->order('sort desc')
+            ->limit($pages)
+            ->select();
+
+        if ($data) {
+            return $this->success('', $data);
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+
+    /**
+     * 党建资讯详情
+     * @param string $id id
+     *
+     */
+    public function listInfo()
+    {
+        $id = $this->request->get('id');
+
+        if (!isset($id) || empty($id)) return $this->error('缺少参数');
+
+        $buildingModel = new BuildingModel();
+
+        $data = $buildingModel->where('switch', 1)
+            ->where('id', $id)
+            ->order('sort desc')
+            ->find();
+
+        if ($data) {
+            return $this->success('', $data);
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+
+
+    /**
+     * 党组织介绍
+     */
+    public function buildInfo()
+    {
+        $data = Db::name('building_info')
+            ->where('id',1)
+
+            ->find();
+
+        if ($data) {
+
+            $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
+
+            return $this->success('', $data);
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+    /**
+     * 党建常见问题
+     * @param string $page 页数
+     * @param string $limit 条数
+     */
+    public function qustion()
+    {
+
+        $page = $this->request->get('page');
+
+        $limit = $this->request->get('limit');
+
+        if (!$page) {
+            $pages = '0,10';
+        } else {
+            $page = $page - 1;
+            if ($page < 0) $page = 0;
+            $pages = $page . ',' . $limit;
+        }
+
+
+        $data = Db::name('building_qustion')->where('switch', 1)
+            ->order('sort desc')
+            ->limit($pages)
+            ->select();
+
+        if ($data) {
+            foreach ($data as &$v) {
+                $v['content'] = str_replace('src="','src="'.config('site.httpurl'),$v['content']);
+            }
+            return $this->success('', $data);
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+
+    /**
+     * 常见问题详情
+     * @param string $id id
+     *
+     */
+    public function qustionInfo()
+    {
+        $id = $this->request->get('id');
+
+        if (!isset($id) || empty($id)) return $this->error('缺少参数');
+
+        $data = Db::name('building_qustion')->where('switch', 1)
+            ->where('id', $id)
+            ->order('sort desc')
+            ->find();
+
+        if ($data) {
+
+            $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
+
+            return $this->success('', $data);
+
+        } else {
+            return $this->error('暂无数据');
+        }
+    }
+}

+ 25 - 0
application/common/model/BuildingModel.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace app\common\model;
+
+use think\Cache;
+use think\Model;
+
+/**
+ * 政策集锦模型
+ */
+class BuildingModel extends Model
+{
+    protected $name = 'business_lists';
+
+
+    public function getImageAttr($value)
+    {
+        return config('site.httpurl').$value;
+    }
+
+    public function getContentAttr($value)
+    {
+        return str_replace('src="','src="'.config('site.httpurl'),$value);
+    }
+}