OMEGA\ericyh.huang hace 1 año
padre
commit
b5975bf9ca

+ 17
- 0
src/be/app/Http/Controllers/HealthyPassPortController.php Ver fichero

106
             return response()->json(["result" => 'failed'] );
106
             return response()->json(["result" => 'failed'] );
107
         }
107
         }
108
     }
108
     }
109
+    public function clearProfile(Request $request){
110
+        $lineUserId = $request->lineUserId; //line UID
111
+        $survey_data = Survey::where('line_user_id',$lineUserId)->first();
112
+        if(!empty($survey_data->id)){
113
+            $filler_content = json_decode($survey_data->filler_content, true);
114
+            $clearAction = [];
115
+            foreach($filler_content as $key => $content){
116
+                array_push($clearAction, $this->buildActionsRequest("removeTag", $content));
117
+            }
118
+            array_push($clearAction, $this->buildActionsRequest("removeTag", config("botApi.doneSurvey")));
119
+            array_push($clearAction, $this->buildActionsRequest("setMenu", "default"));
120
+            $statusCode = $this->botActionsSend($lineUserId,$clearAction);
121
+            if($statusCode == 200){
122
+                $survey_data->delete();
123
+            }
124
+        }
125
+    }
109
 
126
 
110
     function buildActionsRequest($type, $values, $groupId = null, $paramName = ""){
127
     function buildActionsRequest($type, $values, $groupId = null, $paramName = ""){
111
         if($type == "addTag" || $type == "removeTag"){
128
         if($type == "addTag" || $type == "removeTag"){

+ 1
- 0
src/be/routes/api.php Ver fichero

24
         Route::get('/profile', [HealthyPassPortController::class, 'profile']);
24
         Route::get('/profile', [HealthyPassPortController::class, 'profile']);
25
         Route::post('/post', [HealthyPassPortController::class, 'post']);
25
         Route::post('/post', [HealthyPassPortController::class, 'post']);
26
         Route::post('/stickerUpdate', [HealthyPassPortController::class, 'sticker']);
26
         Route::post('/stickerUpdate', [HealthyPassPortController::class, 'sticker']);
27
+        Route::post('/clearProfile', [HealthyPassPortController::class, 'clearProfile']);
27
     });
28
     });
28
 });
29
 });
29
 
30