From b631520f575ddbaef61c65a48bfb135b2a55dc0e Mon Sep 17 00:00:00 2001 From: limu <610543851@qq.com> Date: Fri, 15 Dec 2023 21:43:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=AE=A1=E5=90=8E=E5=8F=B0=E5=93=81?= =?UTF-8?q?=E7=89=8C=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/StoreCategoryRepository.php | 1 + app/controller/admin/store/StoreBrand.php | 25 ++++++++++++------- route/admin/product.php | 3 +++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/common/repositories/store/StoreCategoryRepository.php b/app/common/repositories/store/StoreCategoryRepository.php index 461d789..ad5a38b 100644 --- a/app/common/repositories/store/StoreCategoryRepository.php +++ b/app/common/repositories/store/StoreCategoryRepository.php @@ -107,6 +107,7 @@ class StoreCategoryRepository extends BaseRepository */ public function getBrandList() { + return app()->make(StoreBrandRepository::class)->getAll(); } diff --git a/app/controller/admin/store/StoreBrand.php b/app/controller/admin/store/StoreBrand.php index 3065060..3d4558a 100644 --- a/app/controller/admin/store/StoreBrand.php +++ b/app/controller/admin/store/StoreBrand.php @@ -40,8 +40,8 @@ class StoreBrand extends BaseController */ public function lst() { - [$page , $limit] = $this->getPage(); - $where = $this->request->params(['brand_category_id','brand_name']); + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['brand_category_id', 'brand_name']); return app('json')->success($this->repository->getList($where, $page, $limit)); } @@ -57,23 +57,23 @@ class StoreBrand extends BaseController return app('json')->success('添加成功'); } - public function update($id,validate $validate) + public function update($id, validate $validate) { $data = $this->checkParams($validate); - if(!$this->repository->meExists($id)) + if (!$this->repository->meExists($id)) return app('json')->fail('数据不存在'); if (!$this->repository->parentExists($data['brand_category_id'])) return app('json')->fail('上级分类不存在'); - $this->repository->update($id,$data); + $this->repository->update($id, $data); return app('json')->success('编辑成功'); } public function delete($id) { - if(!$this->repository->meExists($id)) + if (!$this->repository->meExists($id)) return app('json')->fail('数据不存在'); - if($this->repository->getBrandHasProduct($id)) + if ($this->repository->getBrandHasProduct($id)) return app('json')->fail('该品牌下存在商品'); $this->repository->delete($id); return app('json')->success('删除成功'); @@ -85,16 +85,17 @@ class StoreBrand extends BaseController return app('json')->fail('数据不存在'); return app('json')->success($this->repository->get($id)); } + /** * 验证 - * @param validate $validate + * @param validate $validate * @param bool $isCreate * @return array * @author Qinii */ public function checkParams(validate $validate) { - $data = $this->request->params(['brand_category_id','brand_name','is_show','sort','pic']); + $data = $this->request->params(['brand_category_id', 'brand_name', 'is_show', 'sort', 'pic']); $validate->check($data); return $data; } @@ -137,4 +138,10 @@ class StoreBrand extends BaseController $this->repository->update($id, ['is_show' => $status]); return app('json')->success('修改成功'); } + + public function all() + { + $data = $this->repository->getAll(); + return app('json')->success($data); + } } diff --git a/route/admin/product.php b/route/admin/product.php index 6c64907..0da4320 100644 --- a/route/admin/product.php +++ b/route/admin/product.php @@ -150,6 +150,9 @@ Route::group(function () { Route::get('lst', '/lst')->name('systemStoreBrandLst')->option([ '_alias' => '列表', ]); + Route::get('brandList', '/all')->name('systemStoreBrandAll')->option([ + '_alias' => '列表', + ]); Route::post('status/:id', '/switchStatus')->name('systemStoreBrandSwithStatus')->option([ '_alias' => '修改状态', ]);