labwork done

This commit is contained in:
Макс Бондаренко 2023-02-06 21:36:17 +04:00
parent 02eae37b14
commit 673233ea88

View File

@ -5,27 +5,33 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
@RestController
public class UserController {
@GetMapping("/sum")
public String workSum(@RequestParam Integer num1, @RequestParam Integer num2){
public String workSum(HttpServletResponse response, @RequestParam Integer num1, @RequestParam Integer num2){
response.addHeader("Access-Control-Allow-Origin", "*");
return String.format("Result = %s", num1 + num2);
}
@GetMapping("/split")
public String workSprit(@RequestParam String str1, @RequestParam String str2){
public String workSprit(HttpServletResponse response, @RequestParam String str1, @RequestParam String str2){
response.addHeader("Access-Control-Allow-Origin", "*");
String[] array = str1.split(str2);
return String.format("Result = %s", String.join(" ", array));
}
@GetMapping("/upper")
public String workUpper(@RequestParam String str){
return String.format(str.toUpperCase());
@GetMapping("/uplow")
public String workUpper(HttpServletResponse response, @RequestParam String str1, @RequestParam String str2){
response.addHeader("Access-Control-Allow-Origin", "*");
return String.format(str1.toUpperCase() + str2.toLowerCase());
}
@GetMapping("/avg")
public String workAvarage(@RequestParam Integer num1, @RequestParam Integer num2){
public String workAvarage(HttpServletResponse response, @RequestParam Integer num1, @RequestParam Integer num2){
response.addHeader("Access-Control-Allow-Origin", "*");
return String.format("Min = %s Max = %s Avg = %s", Math.min(num1, num2), Math.max(num1, num2), (num1 + num2) / 2);
}
}