From 7238e1770cde9226de54b7bd8175fdb301b385fc Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 18 Apr 2020 20:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=87=E7=AB=A0=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + app/admin/controller/Post.php | 10 ++++ app/common/ColumnFormat.php | 52 +++++++++++++++- .../20200418120809_create_table_post.php | 60 +++++++++++++++++++ ...00418120814_create_table_post_category.php | 43 +++++++++++++ .../20200418120819_create_table_post_tag.php | 42 +++++++++++++ .../20200418120827_create_table_category.php | 43 +++++++++++++ .../20200418120831_create_table_tag.php | 40 +++++++++++++ view/admin/post/index.html | 19 +++++- 9 files changed, 305 insertions(+), 5 deletions(-) create mode 100644 database/migrations/20200418120809_create_table_post.php create mode 100644 database/migrations/20200418120814_create_table_post_category.php create mode 100644 database/migrations/20200418120819_create_table_post_tag.php create mode 100644 database/migrations/20200418120827_create_table_category.php create mode 100644 database/migrations/20200418120831_create_table_tag.php diff --git a/README.md b/README.md index 8079caa..0b5966d 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ php think reset_password - 文件管理 - 后台日志 - 支持轮播图,导航,小程序导航(打开方式)等设置 +- 实现CMS后台 - 适配手机端,实现table转卡片样式 diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index bee4c40..f14468f 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -189,5 +189,15 @@ class Post extends Common public function delete($id) { // + + $model_post = ModelPost::find($id); + + $model_post->delete(); + + PostCategory::where('post_id',$id)->delete(); + + PostTag::where('post_id',$id)->delete(); + + return json_message(); } } diff --git a/app/common/ColumnFormat.php b/app/common/ColumnFormat.php index 7cb484d..8db97b6 100644 --- a/app/common/ColumnFormat.php +++ b/app/common/ColumnFormat.php @@ -8,11 +8,57 @@ class ColumnFormat public static function timestamp($name){ return Column::make($name,'integer') ->setLimit(10) - ->setSigned(false); + ->setSigned(false) + ->setDefault(0); } - public static function loadDeleteTime(){ - return Column::make('delete_time','integer') + + public static function stringLong($name) + { + return Column::make($name,'string') + ->setLimit(500) + ->setDefault(''); + } + public static function stringNormal($name) + { + return Column::make($name,'string') + ->setLimit(100) + ->setDefault(''); + } + + public static function stringUrl($name) + { + return Column::make($name,'string') + ->setLimit(300) + ->setDefault(''); + } + + public static function stringMd5($name) + { + return Column::make($name,'string') + ->setLimit(32) + ->setDefault(''); + } + + public static function stringShort($name) + { + return Column::make($name,'string') + ->setLimit(20) + ->setDefault(''); + } + + public static function integerTypeStatus($name) + { + return Column::make($name,'integer') ->setLimit(10) + ->setSigned(false) + ->setDefault(0); + } + + public static function integer($name) + { + return Column::make($name,'integer') + ->setDefault(0) + ->setLimit(20) ->setSigned(false); } } diff --git a/database/migrations/20200418120809_create_table_post.php b/database/migrations/20200418120809_create_table_post.php new file mode 100644 index 0000000..f42d101 --- /dev/null +++ b/database/migrations/20200418120809_create_table_post.php @@ -0,0 +1,60 @@ +table('post',['comment'=>"内容文章"]); + $table->addColumn(ColumnFormat::stringNormal('title')->setComment('标题')); + $table->addColumn(ColumnFormat::stringUrl('poster')->setComment('封面')); + $table->addColumn(ColumnFormat::timestamp('create_time')); + $table->addColumn(ColumnFormat::timestamp('update_time')); + $table->addColumn(ColumnFormat::timestamp('delete_time')); + $table->addColumn(Column::make('content','text')); + $table->addColumn(Column::make('content_html','text')); + $table->addColumn(ColumnFormat::stringLong('desc')->setDefault('描述')); + $table->addColumn(ColumnFormat::integerTypeStatus('is_top')->setComment('是否置顶')); + $table->addColumn(ColumnFormat::integerTypeStatus('status')->setComment('1:显示,0:不显示')); + $table->addColumn(ColumnFormat::timestamp('publish_time')->setComment('发表时间')); + $table->addColumn(ColumnFormat::integer('hits')->setComment('访问量')); + $table->addColumn(ColumnFormat::stringUrl('jump_to_url')->setComment('跳转链接')); + $table->addColumn(ColumnFormat::integerTypeStatus('jump_to_url_status')->setComment('0:不显示,1:显示连接,2:自动跳转')); + $table->addColumn(ColumnFormat::integer('sort')->setComment('排序,越大越靠前')); + $table->addColumn(ColumnFormat::integerTypeStatus('type')->setComment('类型,1:文章,有分类有标签,2:页面,无分类无标签')); + $table->addColumn(Column::make('files','text')->setComment('附件')); + $table->addColumn(Column::make('pictures','text')->setComment('相册')); + $table->addIndex('type'); + $table->addIndex('status'); + $table->addIndex('delete_time'); + $table->addIndex('hits'); + $table->addIndex('is_top'); + $table->create(); + + + } +} diff --git a/database/migrations/20200418120814_create_table_post_category.php b/database/migrations/20200418120814_create_table_post_category.php new file mode 100644 index 0000000..15400b9 --- /dev/null +++ b/database/migrations/20200418120814_create_table_post_category.php @@ -0,0 +1,43 @@ +table('post_category',['comment'=>'文章分类关联表']); + $table->addColumn(ColumnFormat::integer('post_id')) + ->addColumn(ColumnFormat::integer('category_id')) + ->addColumn(ColumnFormat::timestamp('create_time')) + ->addColumn(ColumnFormat::timestamp('update_time')) + ->addColumn(ColumnFormat::timestamp('delete_time')) + ->addIndex('post_id') + ->addIndex('category_id') + ->create(); + + } +} diff --git a/database/migrations/20200418120819_create_table_post_tag.php b/database/migrations/20200418120819_create_table_post_tag.php new file mode 100644 index 0000000..b84a1ef --- /dev/null +++ b/database/migrations/20200418120819_create_table_post_tag.php @@ -0,0 +1,42 @@ +table('post_tag',['comment'=>'文章分类关联表']); + $table->addColumn(ColumnFormat::integer('post_id')) + ->addColumn(ColumnFormat::integer('tag_id')) + ->addColumn(ColumnFormat::timestamp('create_time')) + ->addColumn(ColumnFormat::timestamp('update_time')) + ->addColumn(ColumnFormat::timestamp('delete_time')) + ->addIndex('post_id') + ->addIndex('tag_id') + ->create(); + } +} diff --git a/database/migrations/20200418120827_create_table_category.php b/database/migrations/20200418120827_create_table_category.php new file mode 100644 index 0000000..b2cb3ea --- /dev/null +++ b/database/migrations/20200418120827_create_table_category.php @@ -0,0 +1,43 @@ +table('category') + ->setComment('分类表') + ->addColumn(ColumnFormat::stringNormal('title')) + ->addColumn(ColumnFormat::timestamp('create_time')) + ->addColumn(ColumnFormat::timestamp('update_time')) + ->addColumn(ColumnFormat::timestamp('delete_time')) + ->addColumn(ColumnFormat::integer('pid')->setComment('上级id')) + ->addColumn(ColumnFormat::integer('level')->setDefault(1)->setComment('层级')) + ->addIndex('pid') + ->create(); + } +} diff --git a/database/migrations/20200418120831_create_table_tag.php b/database/migrations/20200418120831_create_table_tag.php new file mode 100644 index 0000000..35deb93 --- /dev/null +++ b/database/migrations/20200418120831_create_table_tag.php @@ -0,0 +1,40 @@ +table('tag') + ->setComment('分类表') + ->addColumn(ColumnFormat::stringNormal('title')) + ->addColumn(ColumnFormat::timestamp('create_time')) + ->addColumn(ColumnFormat::timestamp('update_time')) + ->addColumn(ColumnFormat::timestamp('delete_time')) + ->create(); + } +} diff --git a/view/admin/post/index.html b/view/admin/post/index.html index c1b12ae..a182d3d 100644 --- a/view/admin/post/index.html +++ b/view/admin/post/index.html @@ -59,8 +59,7 @@ {$vo.sort}
- 编辑 + 编辑
删除
@@ -81,6 +80,22 @@ {include file="common/_footer"} + + + \ No newline at end of file