From 2634aeebaec43f541582a3b9514454de2ea7bef7 Mon Sep 17 00:00:00 2001
From: liumiao <495261512@qq.com>
Date: 星期三, 31 三月 2021 14:58:16 +0800
Subject: [PATCH] 请假

---
 app/Http/Controllers/Api/v1/AskForLeaveController.php |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/app/Http/Controllers/Api/v1/AskForLeaveController.php b/app/Http/Controllers/Api/v1/AskForLeaveController.php
index 16783e9..3c250d3 100644
--- a/app/Http/Controllers/Api/v1/AskForLeaveController.php
+++ b/app/Http/Controllers/Api/v1/AskForLeaveController.php
@@ -31,54 +31,51 @@
     public function addAskForLeave(Request $request)
     {
         $rule = [
-            'coursetableId' => 'required',
-            'attendRecordId' => 'required',
             "approvalStatus" => 'required',
-            "approvalUserId" => 'required',
             "approvalOpinion" => 'required',
             "classHour" => 'required',
+            "param" => 'required',
         ];
         $message = $this->_validate($request, $rule);
         if(!empty($message))
         {
             return $this->_response(null, ResponseCode::PARAM_ERROR, $message);
         }
-        $coursetableId = explode(',', $request->post("coursetableId"));
-        $attendRecordId = explode(',', $request->post("attendRecordId"));
-        $approvalStatus = explode(',', $request->post("approvalStatus"));
-        $approvalUserId = explode(',', $request->post("approvalUserId"));
-        $approvalOpinion = explode(',', $request->post("approvalOpinion"));
-        $classHour = explode(',', $request->post("classHour"));
+        $approvalStatus = $request->post("approvalStatus");
+        $approvalUserId = $this->getAndCheckTeacherId();
+        $approvalOpinion = $request->post("approvalOpinion");
+        $classHour = $request->post("classHour");
+        $param = !empty($request->post("param")) ? json_decode($request->post("param"), true) : [];
 
         DB::beginTransaction(); //寮�鍚簨鍔�
         try
         {
-            foreach($attendRecordId as $key => $val)
+            foreach($param as $key => $val)
             {
                 // 鏇存柊瀹℃壒鏁版嵁
                 $arrData = [
-                    "approvalOpinion" => $approvalOpinion[$key],
-                    "approvalUserId" => $approvalUserId[$key],
+                    "approvalOpinion" => $approvalOpinion,
+                    "approvalUserId" => $approvalUserId,
                     "approvalTime" => date("Y-m-d H:i:s"),
-                    "approvalStatus" => $approvalStatus[$key],
-                    "classHour" => $classHour[$key],
+                    "approvalStatus" => $approvalStatus,
+                    "classHour" => $classHour,
                 ];
-                if($approvalStatus[$key] == 2)
+                if($approvalStatus == 2)
                 {
                     $arrData["classStatus"] = 4;
                 }
-                if($approvalStatus[$key] == 3)
+                if($approvalStatus == 3)
                 {
                     $arrData["status"] = 2;
                 }
-                AttendRecordModel::updateRecordORM($val, $arrData);
+                AttendRecordModel::updateRecordORM($val['attendRecordId'], $arrData);
 
                 //瀛﹀憳璇峰亣鏃ュ織鏁版嵁
                 $data = [
-                    "coursetableId" => $coursetableId[$key],
-                    "attendRecordId" => $val,
+                    "coursetableId" => $val["coursetableId"],
+                    "attendRecordId" => $val["attendRecordId"],
                 ];
-                AttendApprovalLogModel::updateRecordMass(["status" => $approvalStatus[$key]], $data);
+                AttendApprovalLogModel::updateRecordMass(["status" => $approvalStatus], $data);
             }
 
             DB::commit();

--
Gitblit v1.8.0