wesmiler 6 дней назад
Родитель
Сommit
a5128ec666

+ 1 - 5
app/Http/Controllers/Admin/GoodsCategoryController.php

@@ -58,11 +58,7 @@ class GoodsCategoryController extends Backend
      */
     public function edit()
     {
-        if ($this->service->edit()) {
-            return message($this->service->getError(), true);
-        } else {
-            return message($this->service->getError(), false);
-        }
+        $this->service->edit();
     }
 
     /**

+ 3 - 4
app/Services/Common/GoodsCategoryService.php

@@ -120,8 +120,7 @@ class GoodsCategoryService extends BaseService
 
         // 验证分类名称
         if (empty($param['name'])) {
-            $this->error = '分类名称不能为空';
-            return false;
+            return message('分类名称不能为空', false);
         }
 
         $id = isset($param['id'])?$param['id']:0;
@@ -129,8 +128,7 @@ class GoodsCategoryService extends BaseService
         $name = isset($param['name'])?$param['name']:'';
         $checkId = $this->model->where(['name'=>$name,'type'=>$type,'mark'=>1])->whereNotIn('id', [$id])->value('id');
         if($checkId){
-            $this->error = '分类名称已经存在';
-            return false;
+            return message('分类名称已经存在', false);
         }
 
         // 如果 pid 为 0,表示一级分类
@@ -161,6 +159,7 @@ class GoodsCategoryService extends BaseService
         //dump($param);
         $result = parent::edit($param);
         var_dump($result);
+        return $result;
     }
 
     /**