cqpCow 1 éve
szülő
commit
e7190a95f9

+ 5 - 5
.idea/workspace.xml

@@ -3,10 +3,9 @@
   <component name="ChangeListManager">
     <list default="true" id="b5852db3-28ab-419d-82cf-b6c0f6b99397" name="变更" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Service/MaterialService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/MaterialService.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Service/ProcessService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/ProcessService.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Service/Service.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/Service.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/public/.htaccess" beforeDir="false" afterPath="$PROJECT_DIR$/public/.htaccess" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Api/TechnologyController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Api/TechnologyController.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Service/TechnologyService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/TechnologyService.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -157,7 +156,8 @@
       <workItem from="1685669123669" duration="2439000" />
       <workItem from="1685952381761" duration="726000" />
       <workItem from="1686021203384" duration="14595000" />
-      <workItem from="1686099374239" duration="19440000" />
+      <workItem from="1686099374239" duration="19779000" />
+      <workItem from="1686185795830" duration="871000" />
     </task>
     <servers />
   </component>

+ 13 - 0
app/Http/Controllers/Api/TechnologyController.php

@@ -58,4 +58,17 @@ class TechnologyController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function technologyCopy(Request $request)
+    {
+        $service = new TechnologyService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->technologyCopy($request->all(),$request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 24 - 0
app/Service/TechnologyService.php

@@ -69,4 +69,28 @@ class TechnologyService extends Service
 
         return [true,''];
     }
+
+    public function technologyCopy($data,$user){
+        list($status,$msg) = $this->technologyCopyRule($data);
+        if(! $status) return [$status,$msg];
+
+        $first = Technology::where('id',$data['id'])->where('del_time',0)->first();
+
+        $model = new Technology();
+        $model->title = $data['title'];
+        $model->process_id = $first->process_id;
+        $model->save();
+
+        return [true,'保存成功!'];
+    }
+
+    public function technologyCopyRule($data){
+        if($this->isEmpty($data,'id')) return [false,'复制的工序ID不能为空!'];
+        if($this->isEmpty($data,'title')) return [false,'名称不能为空!'];
+
+        $bool = Technology::where('title',$data['title'])->where('del_time',0)->exists();
+        if($bool) return [false,'名称已存在!'];
+
+        return [true,''];
+    }
 }

+ 1 - 0
routes/api.php

@@ -82,6 +82,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('technologyEdit', 'Api\TechnologyController@technologyEdit');
     $route->any('technologyAdd', 'Api\TechnologyController@technologyAdd');
     $route->any('technologyDel', 'Api\TechnologyController@technologyDel');
+    $route->any('technologyCopy', 'Api\TechnologyController@technologyCopy');
 
     $route->any('productList', 'Api\MaterialController@productList');
     $route->any('productEdit', 'Api\MaterialController@edit');