Skip to content

Commit

Permalink
use multivaluemap instead of requestparam
Browse files Browse the repository at this point in the history
  • Loading branch information
Yinnii committed Oct 11, 2024
1 parent b57eca4 commit b34f9ba
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.util.MultiValueMap;

import com.google.gson.Gson;

Expand Down Expand Up @@ -478,16 +479,24 @@ public ResponseEntity<String> getAnalyzedText(@PathVariable("label1") String lab
@ApiResponse(responseCode = "500", description = "Response failed.")
})
@PostMapping(value = "/compareText", produces = MediaType.APPLICATION_JSON)
public ResponseEntity<String> compareText(@RequestParam("label1") String label1, @RequestParam("label2") String label2, @RequestParam("file") MultipartFile file,
@RequestParam("type") String type, @RequestParam("template") String template,
@RequestParam("wordSpec") String wordSpec,@RequestParam("email") String email,@RequestParam("courseId") int courseId, @RequestParam("sbfmURL") String sbfmURL) throws ParseException, IOException {
public ResponseEntity<String> compareText(@RequestParam MultiValueMap<String,String> fileMp, @RequestParam("file") MultipartFile file) throws ParseException, IOException {
String label1 = fileMp.getFirst("label1");
String label2 = fileMp.getFirst("label2");
String type = fileMp.getFirst("type");
String template = fileMp.getFirst("template");
String wordSpec = fileMp.getFirst("wordSpec");
String email = fileMp.getFirst("email");
Integer courseId = Integer.parseInt(fileMp.getFirst("courseId"));
String sbfmURL = fileMp.getFirst("sbfmURL");


if (service.isActive.getOrDefault(label1, false)) {
JSONObject err = new JSONObject();
err.put("errorMessage", "User: " + label1 + " currently busy.");
err.put("error", true);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(err.toJSONString());
}

File templatePath = new File("tmitocar/templates/" + template);
if (!templatePath.exists()){
JSONObject err = new JSONObject();
Expand Down

0 comments on commit b34f9ba

Please sign in to comment.