From 7aa55a7c1cf87835b565dae621df57e7ab088557 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, 3 Jul 2025 11:51:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E9=85=8D=E7=BD=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/YunzeradminController.php | 100 +++++++++++++++- .../model/{ => ContentPush}/ContentPush.php | 2 +- .../model/ContentPush/ContentPushSetting.php | 34 ++++++ app/admin/view/yunzeradmin/contentpush.php | 14 +++ .../view/yunzeradmin/contentpushsetting.php | 109 ++++++++++++++++++ .../yunzeradmin/contentpushsettingadd.php | 75 ++++++++++++ 6 files changed, 331 insertions(+), 3 deletions(-) rename app/admin/model/{ => ContentPush}/ContentPush.php (95%) create mode 100644 app/admin/model/ContentPush/ContentPushSetting.php create mode 100644 app/admin/view/yunzeradmin/contentpushsetting.php create mode 100644 app/admin/view/yunzeradmin/contentpushsettingadd.php diff --git a/app/admin/controller/YunzeradminController.php b/app/admin/controller/YunzeradminController.php index 44b55a7..0c15039 100644 --- a/app/admin/controller/YunzeradminController.php +++ b/app/admin/controller/YunzeradminController.php @@ -28,7 +28,8 @@ use app\admin\model\AdminUser; use app\admin\model\User\Users; use app\admin\model\User\UsersGroup; use app\admin\model\Banner; -use app\admin\model\ContentPush; +use app\admin\model\ContentPush\ContentPush; +use app\admin\model\ContentPush\ContentPushSetting; class YunzeradminController extends Base @@ -737,8 +738,9 @@ class YunzeradminController extends Base } Log::record('添加内容推送', 1, '', '内容推送管理'); return json(['code' => 0, 'msg' => '添加成功']); + } else { + return View::fetch(); } - return json(['code' => 1, 'msg' => '请求方法无效']); } // 编辑内容推送 @@ -817,6 +819,100 @@ class YunzeradminController extends Base return json(['code' => 1, 'msg' => '请求方法无效']); } + //推送配置列表(渲染列表) + public function contentpushsetting() + { + if (Request::isAjax() || Request::isPost()) { + $page = intval(input('get.page', 1)); + $limit = intval(input('get.limit', 10)); + + $query = ContentPushSetting::where('delete_time', null) + ->field('id, title, value, status, sort, create_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']; + } + + return json([ + 'code' => 0, + 'msg' => '获取成功', + 'count' => $count, + 'data' => $lists + ]); + } else { + return View::fetch(); + } + } + + //推送配置添加和编辑通用方法 + public function contentpushsettingadd() + { + if (Request::isPost()) { + $params = input('post.'); + $id = isset($params['id']) ? intval($params['id']) : 0; + + if ($id > 0) { + // 编辑 + $res = ContentPushSetting::update($params, ['id' => $id]); + if ($res === false) { + Log::record('编辑推送配置', 0, '编辑推送配置失败', '推送配置管理'); + return json(['code' => 1, 'msg' => '编辑推送配置失败']); + } + Log::record('编辑推送配置', 1, '', '推送配置管理'); + return json(['code' => 0, 'msg' => '编辑成功']); + } else { + // 添加 + $res = ContentPushSetting::create($params); + if (!$res) { + Log::record('添加推送配置', 0, '添加推送配置失败', '推送配置管理'); + return json(['code' => 1, 'msg' => '添加推送配置失败']); + } + Log::record('添加推送配置', 1, '', '推送配置管理'); + return json(['code' => 0, 'msg' => '添加成功']); + } + } else { + $id = input('get.id', 0); + $info = []; + if ($id) { + $info = ContentPushSetting::where('id', $id)->find(); + if ($info) { + $info = $info->toArray(); + } + } + return View::fetch('', ['info' => $info]); + } + } + + //推送配置软删除 + public function contentpushsettingdel() + { + if (Request::isPost()) { + $id = intval(input('post.id', 0)); + if (!$id) { + return json(['code' => 1, 'msg' => '参数错误']); + } + $setting = ContentPushSetting::where('id', $id)->find(); + if (!$setting) { + return json(['code' => 1, 'msg' => '配置不存在']); + } + $res = ContentPushSetting::where('id', $id)->update(['delete_time' => date('Y-m-d H:i:s')]); + 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 materialcenter() { diff --git a/app/admin/model/ContentPush.php b/app/admin/model/ContentPush/ContentPush.php similarity index 95% rename from app/admin/model/ContentPush.php rename to app/admin/model/ContentPush/ContentPush.php index abe4a10..652375d 100644 --- a/app/admin/model/ContentPush.php +++ b/app/admin/model/ContentPush/ContentPush.php @@ -16,7 +16,7 @@ * 3. 禁止转售或分发 */ -namespace app\admin\model; +namespace app\admin\model\ContentPush; use think\Model; diff --git a/app/admin/model/ContentPush/ContentPushSetting.php b/app/admin/model/ContentPush/ContentPushSetting.php new file mode 100644 index 0000000..224b763 --- /dev/null +++ b/app/admin/model/ContentPush/ContentPushSetting.php @@ -0,0 +1,34 @@ + 添加推送 + + + 推送配置 刷新 @@ -119,6 +122,17 @@ }, 'json'); } + //配置 + function setting(){ + layer.open({ + type: 2, + title: '推送配置', + shade: 0.3, + area: ['1000px', '800px'], + content: "{$config['admin_route']}yunzeradmin/contentpushsetting" + }); + } + // 刷新列表 function refresh() { layui.table.reload('contentPushTable'); diff --git a/app/admin/view/yunzeradmin/contentpushsetting.php b/app/admin/view/yunzeradmin/contentpushsetting.php new file mode 100644 index 0000000..0c0eef0 --- /dev/null +++ b/app/admin/view/yunzeradmin/contentpushsetting.php @@ -0,0 +1,109 @@ +{include file="public/header" /} + + + + + 推送配置列表 + + + + + 添加配置 + + + 刷新 + + + + + + + + + + + +{include file="public/tail" /} diff --git a/app/admin/view/yunzeradmin/contentpushsettingadd.php b/app/admin/view/yunzeradmin/contentpushsettingadd.php new file mode 100644 index 0000000..cba0435 --- /dev/null +++ b/app/admin/view/yunzeradmin/contentpushsettingadd.php @@ -0,0 +1,75 @@ +{include file="public/header" /} + + + {if isset($info.id)} + + {/if} + + 配置标题 + + + + + + + 配置值 + + {$info.value|default=''} + + + + + 状态 + + + + + + + + 排序 + + + + + + + + 立即提交 + 重置 + + + + + + + +{include file="public/tail" /} \ No newline at end of file