From 4f1486056f358d24c4f8ceaf552e2ade043278f9 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 17 Dec 2025 14:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=B9=95=E4=B8=8D=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/BarrageController.php | 22 +++++++++++++++++++++ app/common/service/BarrageService.php | 1 + app/common/service/SkuAttributeService.php | 6 ++++-- config/route.php | 3 ++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/common/controller/BarrageController.php b/app/common/controller/BarrageController.php index 942ca73..023070e 100644 --- a/app/common/controller/BarrageController.php +++ b/app/common/controller/BarrageController.php @@ -17,6 +17,28 @@ class BarrageController extends BaseController $this->service = new BarrageService(); } + /** + * 获取列表 + * + * @param Request $request 请求对象 + * @return mixed 返回分页数据及总数 + */ + public function preset(Request $request) + { + try { + $raw = $this->service->serviceListAll($request); + $data = []; + foreach ($raw as $item) { + unset($item['created_at']); + unset($item['updated_at']); + $data[] = $this->indexFormat($item); + } + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + /** * 获取列表 * diff --git a/app/common/service/BarrageService.php b/app/common/service/BarrageService.php index b599a58..d590f14 100644 --- a/app/common/service/BarrageService.php +++ b/app/common/service/BarrageService.php @@ -42,6 +42,7 @@ class BarrageService $config['model'] = $this->modelClass; switch ($scene) { case 'default': + $config['order']['is_blocked'] = '0'; $config['order']['sort'] = 'desc'; $config['order']['id'] = 'desc'; break; diff --git a/app/common/service/SkuAttributeService.php b/app/common/service/SkuAttributeService.php index c25b095..d1a4c80 100644 --- a/app/common/service/SkuAttributeService.php +++ b/app/common/service/SkuAttributeService.php @@ -86,8 +86,10 @@ class SkuAttributeService public function beforeServiceUpdate($data, Request $request) { $options = []; - foreach ($data['options_json'] as $v){ - $options[] = $v['value']; + if (!empty($data['options_json'])) { + foreach ($data['options_json'] as $v){ + $options[] = $v['value']; + } } $data['options_json'] = json_encode($options, JSON_UNESCAPED_UNICODE); return $data; diff --git a/config/route.php b/config/route.php index 27f717d..232d48e 100644 --- a/config/route.php +++ b/config/route.php @@ -104,12 +104,13 @@ Route::group('/common', function () { // sku Route::group('/sku', function () { Route::any('/list', [app\common\controller\SkuController::class, 'index']); - Route::any('/preset', [app\common\controller\SkuController::class, 'preset']); + Route::any('/all', [app\common\controller\SkuController::class, 'preset']); }); // 弹幕 Route::group('/barrage', function () { Route::any('/list', [app\common\controller\BarrageController::class, 'index']); + Route::any('/all', [app\common\controller\BarrageController::class, 'preset']); Route::any('/store', [app\common\controller\BarrageController::class, 'store']); });