Made Lecturer service to work

This commit is contained in:
Filip Izydorczyk
2020-08-04 17:30:03 +02:00
parent 821f1ffa75
commit 90cc284f7a
8 changed files with 82 additions and 31 deletions

View File

@ -1,14 +0,0 @@
package com.plannaplan;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@CrossOrigin
public class TestController {
@GetMapping("/")
public String xd() {
return "<h1>xd</h1>";
}
}

View File

@ -0,0 +1,36 @@
package com.plannaplan.controllers;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import com.plannaplan.Controller;
import com.plannaplan.models.ConfigData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@RestController
@CrossOrigin
public class ConfigController {
@Autowired
private Controller contrl;
@PostMapping("/config")
public ResponseEntity<String> configApp(@RequestParam("file") MultipartFile file) {
try {
ConfigData data = new ConfigData(null, null, file.getInputStream());
this.contrl.config(data);
return new ResponseEntity<>("Sucess", HttpStatus.OK);
} catch (IOException e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}