diff --git a/app/admin/controller/NoticeController.php b/app/admin/controller/NoticeController.php new file mode 100644 index 0000000..52e2e1f --- /dev/null +++ b/app/admin/controller/NoticeController.php @@ -0,0 +1,33 @@ +service = new NoticeService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/controller/NoticeController.php b/app/common/controller/NoticeController.php new file mode 100644 index 0000000..9ceb5a1 --- /dev/null +++ b/app/common/controller/NoticeController.php @@ -0,0 +1,33 @@ +service = new NoticeService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/logic/NoticeLogic.php b/app/common/logic/NoticeLogic.php new file mode 100644 index 0000000..a48ca31 --- /dev/null +++ b/app/common/logic/NoticeLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['where']['status'] = 1; + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + break; + case 'index': +// $config['where']['status'] = 1; + if (isset($p['status']) && !empty($p['status'])) { + $config['where']['status'] = $p['status']; + } + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + $config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/common/validate/NoticeValidate.php b/app/common/validate/NoticeValidate.php new file mode 100644 index 0000000..75e58e9 --- /dev/null +++ b/app/common/validate/NoticeValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index 0b39ab2..e333380 100644 --- a/config/route.php +++ b/config/route.php @@ -106,6 +106,12 @@ Route::group('/common', function () { Route::any('/list', [app\common\controller\SkuController::class, 'index']); Route::any('/preset', [app\common\controller\SkuController::class, 'preset']); }); + + // 公告 + Route::group('/notice', function () { + Route::any('/list', [app\admin\controller\NoticeController::class, 'index']); + Route::any('/show', [app\admin\controller\NoticeController::class, 'show']); + }); }); @@ -227,6 +233,15 @@ Route::group('/admin', function () { Route::any('/update', [app\admin\controller\SkuController::class, 'update']); Route::any('/destroy', [app\admin\controller\SkuController::class, 'destroy']); }); + + // 公告 + Route::group('/notice', function () { + Route::any('/list', [app\admin\controller\NoticeController::class, 'index']); + Route::any('/show', [app\admin\controller\NoticeController::class, 'show']); + Route::any('/store', [app\admin\controller\NoticeController::class, 'store']); + Route::any('/update', [app\admin\controller\NoticeController::class, 'update']); + Route::any('/destroy', [app\admin\controller\NoticeController::class, 'destroy']); + }); });