From 36d104332ac763de97951f93c2977b8cbc0716dc Mon Sep 17 00:00:00 2001 From: tensent Date: Sun, 10 May 2020 22:15:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/admin/Base.php | 3 +-- app/controller/api/Attach.php | 36 ++++++++++++++++++++++++++++++++++ app/controller/api/Content.php | 7 +++++-- app/controller/api/Message.php | 33 +++++++++++++++++++++++++++++++ app/controller/front/Base.php | 3 +-- app/controller/user/Base.php | 3 +-- route/app.php | 11 ++++++----- 7 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 app/controller/api/Attach.php create mode 100644 app/controller/api/Message.php diff --git a/app/controller/admin/Base.php b/app/controller/admin/Base.php index f78f4343..c3afbbbf 100644 --- a/app/controller/admin/Base.php +++ b/app/controller/admin/Base.php @@ -8,7 +8,6 @@ // +---------------------------------------------------------------------- namespace app\controller\admin; -use app\controller\Base as BaseC; use app\model\Addons; use app\model\AuthGroup; use app\model\Menu; @@ -16,7 +15,7 @@ use app\model\Model; use think\facade\View; use think\facade\Config; -class Base extends BaseC { +class Base extends \app\controller\Base { // 使用内置PHP模板引擎渲染模板输出 protected $tpl_config = [ diff --git a/app/controller/api/Attach.php b/app/controller/api/Attach.php new file mode 100644 index 00000000..3d0ebdf6 --- /dev/null +++ b/app/controller/api/Attach.php @@ -0,0 +1,36 @@ + +// +---------------------------------------------------------------------- +namespace app\controller\api; + +use app\model\Attach as AttachModel; + +/** + * @title 附件管理 + */ +class Attach extends Base { + + /** + * @title 附件列表 + */ + public function index(){ + $param = $this->request->param(); + $map = []; + $order = "id desc"; + + if(isset($param['type']) && $param['type']){ + $map[] = ['type', '=', $param['type']]; + } + + $list = AttachModel::where($map)->order($order)->paginate($this->request->pageConfig); + + $this->data['data'] = $list; + $this->data['code'] = 1; + return $this->data; + } +} \ No newline at end of file diff --git a/app/controller/api/Content.php b/app/controller/api/Content.php index 985b019c..dd7109f9 100644 --- a/app/controller/api/Content.php +++ b/app/controller/api/Content.php @@ -8,7 +8,10 @@ // +---------------------------------------------------------------------- namespace app\controller\api; +use think\facade\Db; use app\model\Category; +use app\model\Model; +use app\model\Attribute; /** * @title 内容管理 @@ -40,7 +43,7 @@ class Content extends Base { } $list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig); - + $this->data['code'] = 1; $this->data['data'] = $list; return $this->data; } @@ -56,7 +59,7 @@ class Content extends Base { return $this->error("非法操作!"); } $info = $this->model->find($id); - + $this->data['code'] = 1; $this->data['data'] = $info; return $this->data; } diff --git a/app/controller/api/Message.php b/app/controller/api/Message.php new file mode 100644 index 00000000..5ef08525 --- /dev/null +++ b/app/controller/api/Message.php @@ -0,0 +1,33 @@ + +// +---------------------------------------------------------------------- +namespace app\controller\api; + +use think\facade\Db; + +/** + * @title 消息管理 + */ +class Message extends Base { + + /** + * @title 消息列表 + */ + public function index(){ + $this->data['code'] = 1; + return $this->data; + } + + /** + * @title 通知列表 + */ + public function notice(){ + $this->data['code'] = 1; + return $this->data; + } +} \ No newline at end of file diff --git a/app/controller/front/Base.php b/app/controller/front/Base.php index 3d14aa86..853bd896 100644 --- a/app/controller/front/Base.php +++ b/app/controller/front/Base.php @@ -10,9 +10,8 @@ namespace app\controller\front; use think\facade\View; use think\facade\Cache; -use app\controller\Base as BaseC; -class Base extends BaseC { +class Base extends \app\controller\Base { protected function fetch($template = '') { $config = Cache::get('system_config_data'); diff --git a/app/controller/user/Base.php b/app/controller/user/Base.php index b91eda34..8ac4958d 100644 --- a/app/controller/user/Base.php +++ b/app/controller/user/Base.php @@ -8,14 +8,13 @@ // +---------------------------------------------------------------------- namespace app\controller\user; -use app\controller\Base as BaseC; use app\model\Form; use app\model\Model; use think\facade\Cache; use think\facade\Config; use think\facade\View; -class Base extends BaseC { +class Base extends \app\controller\Base { protected $outAuthUrl = ['user/index/login', 'user/index/logout', 'user/index/verify', 'user/index/register', 'user/index/forget', 'user/index/resetpasswd']; diff --git a/route/app.php b/route/app.php index e7f9dc69..20f96d6c 100755 --- a/route/app.php +++ b/route/app.php @@ -22,11 +22,12 @@ if (!$model) { if (!empty($model)) { foreach ($model as $value) { - Route::rule('/admin/' . $value['name'] . '/:function', 'admin.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]); - Route::rule($value['name'] . '/index', 'front.content/index')->append(['name'=>$value['name'], 'model_id' => $value['id']]); - Route::rule($value['name'] . '/list/:id', 'front.content/lists')->append(['name'=>$value['name'], 'model_id' => $value['id']]); - Route::rule($value['name'] . '/detail-:id', 'front.content/detail')->append(['name'=>$value['name'], 'model_id' => $value['id']]); - Route::rule('/user/' . $value['name'] . '/:function', 'user.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule('/admin/' . $value['name'] . '/:function', 'admin.Content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule($value['name'] . '/index', 'front.Content/index')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule($value['name'] . '/list/:id', 'front.Content/lists')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule($value['name'] . '/detail-:id', 'front.Content/detail')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule('/user/' . $value['name'] . '/:function', 'user.Content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]); + Route::rule('/api/' . $value['name'] . '/:function', 'api.Content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]); } }