labwork done
This commit is contained in:
parent
02eae37b14
commit
673233ea88
@ -5,27 +5,33 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@GetMapping("/sum")
|
@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);
|
return String.format("Result = %s", num1 + num2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/split")
|
@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);
|
String[] array = str1.split(str2);
|
||||||
return String.format("Result = %s", String.join(" ", array));
|
return String.format("Result = %s", String.join(" ", array));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/upper")
|
@GetMapping("/uplow")
|
||||||
public String workUpper(@RequestParam String str){
|
public String workUpper(HttpServletResponse response, @RequestParam String str1, @RequestParam String str2){
|
||||||
return String.format(str.toUpperCase());
|
response.addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
return String.format(str1.toUpperCase() + str2.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/avg")
|
@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);
|
return String.format("Min = %s Max = %s Avg = %s", Math.min(num1, num2), Math.max(num1, num2), (num1 + num2) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user