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']); });