From 47cfb7dcafebcaff2ef33bcadec88be1a85e45c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E5=BC=BA?= <357099073@qq.com> Date: Thu, 29 May 2025 17:33:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/YunzeradminController.php | 144 ++++++++++++++++++ app/admin/model/ContentPush.php | 17 +++ app/admin/view/yunzeradmin/contentpush.php | 135 ++++++++++++++++ app/admin/view/yunzeradmin/contentpushadd.php | 113 ++++++++++++++ .../view/yunzeradmin/contentpushedit.php | 108 +++++++++++++ 5 files changed, 517 insertions(+) create mode 100644 app/admin/model/ContentPush.php create mode 100644 app/admin/view/yunzeradmin/contentpush.php create mode 100644 app/admin/view/yunzeradmin/contentpushadd.php create mode 100644 app/admin/view/yunzeradmin/contentpushedit.php diff --git a/app/admin/controller/YunzeradminController.php b/app/admin/controller/YunzeradminController.php index 8aeba9c..9dc7d5c 100644 --- a/app/admin/controller/YunzeradminController.php +++ b/app/admin/controller/YunzeradminController.php @@ -9,6 +9,7 @@ use app\admin\model\AdminSysMenu; use app\admin\model\AdminUserGroup; use app\admin\model\AdminUser; use app\admin\model\Banner; +use app\admin\model\ContentPush; class YunzeradminController extends Base @@ -451,4 +452,147 @@ class YunzeradminController extends Base } return json(['code' => 1, 'msg' => '请求方法无效']); } + + //内容推送 + public function contentpush() + { + return View::fetch(); + } + + // 内容推送列表 + public function contentpushlist() + { + if (Request::isGet()) { + $page = intval(input('post.page', 1)); + $limit = intval(input('post.limit', 10)); + + $query = ContentPush::where('delete_time', null) + ->field('id, title, type, status, sort, create_time, update_time'); + + // 获取总记录数 + $count = $query->count(); + + // 获取分页数据 + $lists = $query->order(['sort DESC', 'id DESC']) + ->page($page, $limit) + ->select() + ->toArray(); + + // 处理数据 + foreach ($lists as &$item) { + $item['create_time'] = is_numeric($item['create_time']) ? date('Y-m-d H:i:s', $item['create_time']) : $item['create_time']; + $item['update_time'] = is_numeric($item['update_time']) ? date('Y-m-d H:i:s', $item['update_time']) : $item['update_time']; + } + + return json([ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $lists + ]); + } + return json(['code' => 1, 'msg' => '请求方法无效']); + } + + // 添加内容推送 + public function contentpushadd() + { + if (Request::isPost()) { + $data = [ + 'title' => input('post.title'), + 'content' => input('post.content'), + 'image' => input('post.image'), + 'url' => input('post.url'), + 'type' => input('post.type', 1), + 'status' => input('post.status', 1), + 'sort' => input('post.sort', 0), + 'create_time' => time() + ]; + + $res = ContentPush::insert($data); + if (!$res) { + Log::record('添加内容推送', 0, '添加内容推送失败', '内容推送管理'); + return json(['code' => 1, 'msg' => '添加内容推送失败']); + } + Log::record('添加内容推送', 1, '', '内容推送管理'); + return json(['code' => 0, 'msg' => '添加成功']); + } + return json(['code' => 1, 'msg' => '请求方法无效']); + } + + // 编辑内容推送 + public function contentpushedit() + { + if (Request::isPost()) { + $id = input('post.id'); + if (empty($id)) { + Log::record('编辑内容推送', 0, 'ID不能为空', '内容推送管理'); + return json(['code' => 1, 'msg' => 'ID不能为空']); + } + + $data = [ + 'title' => input('post.title'), + 'content' => input('post.content'), + 'image' => input('post.image'), + 'url' => input('post.url'), + 'type' => input('post.type', 1), + 'status' => input('post.status', 1), + 'sort' => input('post.sort', 0), + 'update_time' => time() + ]; + + $res = ContentPush::where('id', $id)->update($data); + if ($res === false) { + Log::record('编辑内容推送', 0, '更新内容推送失败', '内容推送管理'); + return json(['code' => 1, 'msg' => '更新内容推送失败']); + } + Log::record('编辑内容推送', 1, '', '内容推送管理'); + return json(['code' => 0, 'msg' => '更新成功']); + } + return json(['code' => 1, 'msg' => '请求方法无效']); + } + + // 删除内容推送 + public function contentpushdel() + { + if (Request::isPost()) { + $id = input('post.id'); + if (empty($id)) { + Log::record('删除内容推送', 0, 'ID不能为空', '内容推送管理'); + return json(['code' => 1, 'msg' => 'ID不能为空']); + } + + $res = ContentPush::where('id', $id)->update(['delete_time' => time()]); + if (!$res) { + Log::record('删除内容推送', 0, '删除内容推送失败', '内容推送管理'); + return json(['code' => 1, 'msg' => '删除内容推送失败']); + } + Log::record('删除内容推送', 1, '', '内容推送管理'); + return json(['code' => 0, 'msg' => '删除成功']); + } + return json(['code' => 1, 'msg' => '请求方法无效']); + } + + // 修改内容推送状态 + public function contentpushstatus() + { + if (Request::isPost()) { + $id = input('post.id'); + $status = input('post.status'); + + if (empty($id)) { + Log::record('修改内容推送状态', 0, 'ID不能为空', '内容推送管理'); + return json(['code' => 1, 'msg' => 'ID不能为空']); + } + + $res = ContentPush::where('id', $id)->update(['status' => $status]); + if ($res === false) { + Log::record('修改内容推送状态', 0, '更新状态失败', '内容推送管理'); + return json(['code' => 1, 'msg' => '更新状态失败']); + } + Log::record('修改内容推送状态', 1, '', '内容推送管理'); + return json(['code' => 0, 'msg' => '更新成功']); + } + return json(['code' => 1, 'msg' => '请求方法无效']); + } } \ No newline at end of file diff --git a/app/admin/model/ContentPush.php b/app/admin/model/ContentPush.php new file mode 100644 index 0000000..f99e657 --- /dev/null +++ b/app/admin/model/ContentPush.php @@ -0,0 +1,17 @@ + + +
+
+ + 内容推送列表 +
+
+
+ + +
+
+
+ +
+ + + + + + + +{include file="public/tail" /} \ No newline at end of file diff --git a/app/admin/view/yunzeradmin/contentpushadd.php b/app/admin/view/yunzeradmin/contentpushadd.php new file mode 100644 index 0000000..c879de6 --- /dev/null +++ b/app/admin/view/yunzeradmin/contentpushadd.php @@ -0,0 +1,113 @@ +{include file="public/header" /} +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+
+ + +
+
+
+
+ + + +{include file="public/tail" /} diff --git a/app/admin/view/yunzeradmin/contentpushedit.php b/app/admin/view/yunzeradmin/contentpushedit.php new file mode 100644 index 0000000..37689f4 --- /dev/null +++ b/app/admin/view/yunzeradmin/contentpushedit.php @@ -0,0 +1,108 @@ +{include file="public/header" /} +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+
+ + +
+
+
+
+ + + +{include file="public/tail" /}