diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index 06cf1b1..2ee9ac5 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -49,44 +49,52 @@ class Article extends AuthController } /** - * 更新 - * @param Request $request + * 保存 + * @param string $id * @return mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException * @author 李玉坤 - * @date 2021-02-16 21:15 + * @date 2021-02-28 22:43 */ - public function update(Request $request) + public function save($id="") { $data = Util::postMore([ ['id',''], + ['writer',''], ['title',''], ['category_id',''], + ['type','article'], + ['abstract',''], ['keywords',''], ['description',''], - ['type','article'], ['is_recommend',0], ['is_top',0], + ['is_hot',0], ['link_str',''], ['cover_path',''], ['display',1], + ['tag',''], ['sort',''], ['status',1], ]); - if ($data['id'] == '') return app("json")->fail("参数有误,Id为空!"); - $id = $data['id']; - unset($data['id']); - $saveData = []; - foreach ($data as $key=>$value){ - if ($value !== ''){ - $saveData[$key] = $value; - } + if ($data['title'] == "") return app("json")->fail("文章名称不能为空"); + if ($data['category_id'] == "") return app("json")->fail("栏目分类不能为空"); + if ($data['cover_path'] == "") return app("json")->fail("主图不能为空"); + $data['writer'] = $data['writer']?:$this->adminInfo['nickname']; + $data['uid'] = $this->adminId; + if ($id=="") + { + $data['writer'] = $data['writer']?:$this->adminInfo['nickname']; + $res = aModel::save($data); + }else + { + $ainfo = aModel::get($id); + if (!$ainfo)return app("json")->fail("数据不存在"); + $res = aModel::where('id',$id)->save($data); } - return aModel::update($saveData,['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); + return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败"); } + /** * 修改字段 * @param $id @@ -139,5 +147,4 @@ class Article extends AuthController return $this->fetch(); } - } \ No newline at end of file diff --git a/app/admin/view/article/add.html b/app/admin/view/article/add.html index 28c4ecb..3527993 100644 --- a/app/admin/view/article/add.html +++ b/app/admin/view/article/add.html @@ -1,156 +1,156 @@ - - - CMS - 派后台管理系统 - - - - - - - - - - - - - - + 添加文章 - {:system_config("title")}后台管理系统 + {include file="public/header" /} + + -
-
-
-
-
-
-
- - -
-
- -
- +
+
+
+
+

基本样式

+
    +
  • + +
  • +
+
+
+ +
+
+ +
+ +
-
-
- - -
-
- -
- - -
+
+ +
+ +
-
-
-
推荐
-
- +
+ +
-
-
-
热门
-
- +
+ +
+
    + +
  • + + + +
  • +
+
-
-
-
顶置
-
- +
+ +
-
-
-
显示
-
- +
+ +
-
-
- - -
-
- - -
-
- - -
-
- -
- +
+ +
-
-
- - -
-
- - -
-
- - -
-
- -
- +
+ + +
+
+ +
+ +
+
+
+
+
推荐
+
+ +
+
+
+
热门
+
+ +
+
+
+
顶置
+
+ +
+
+
+
显示
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
- - - - - - - - - - - - - - - +{include file="public/footer"/} - + + + + diff --git a/app/admin/view/article/edit.html b/app/admin/view/article/edit.html index f7aaabc..5eb36af 100644 --- a/app/admin/view/article/edit.html +++ b/app/admin/view/article/edit.html @@ -1,156 +1,156 @@ - - - CMS - 派后台管理系统 - - - - - - - - - - - - - - + 添加文章 - {:system_config("title")}后台管理系统 + {include file="public/header" /} + + -
-
-
-
-
-
-
- - -
-
- -
- +
+
+
+
+

基本样式

+
    +
  • + +
  • +
+
+
+ +
+
+ +
+ +
-
-
- - -
-
- -
- - -
+
+ +
+ +
-
-
-
推荐
-
- +
+ +
-
-
-
热门
-
- +
+ +
+
    + +
  • + + + +
  • +
+
-
-
-
顶置
-
- +
+ +
-
-
-
显示
-
- +
+ +
-
-
- - -
-
- - -
-
- - -
-
- -
- +
+ +
-
-
- - -
-
- - -
-
- - -
-
- -
- +
+ + +
+
+ +
+ +
+
+
+
+
推荐
+
+ +
+
+
+
热门
+
+ +
+
+
+
顶置
+
+ +
+
+
+
显示
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
- - - - - - - - - - - - - - - +{include file="public/footer"/} - + + + + diff --git a/app/admin/view/article/index.html b/app/admin/view/article/index.html index a92199b..66e923e 100644 --- a/app/admin/view/article/index.html +++ b/app/admin/view/article/index.html @@ -37,7 +37,7 @@
@@ -124,7 +124,7 @@ title: '操作', formatter:function (value,row,index) { let html ='\n' + - ''; + ''; return html; }, events : {