This commit is contained in:
AnnZhimol 2023-02-06 16:42:57 +04:00
parent 815967146e
commit a6d16481da

View File

@ -2,32 +2,39 @@ package ru.ulstu.is.cbapp;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication @SpringBootApplication
@RestController @RestController
@CrossOrigin
public class CbappApplication { public class CbappApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(CbappApplication.class, args); SpringApplication.run(CbappApplication.class, args);
} }
// http://localhost:8080/calc?v1=15&v2=3
@GetMapping("/calc") @GetMapping("/calc")
public Integer doSum(@RequestParam(defaultValue = "10") int val1, public Integer doProiz(@RequestParam(defaultValue = "10") int v1,
@RequestParam(defaultValue = "2") int val2, @RequestParam(defaultValue = "2") int v2) {
@RequestParam(defaultValue = "+") String value) { return v1*v2;
switch(value){ }
case "-": // http://localhost:8080/toUpperCase?value=internetprogramming
return val1-val2; @GetMapping("/toUpperCase")
case "*": public @ResponseBody String toUpperCase(@RequestParam(defaultValue = "") String value) {
return val1*val2; return value.toUpperCase();
case "/":
return val1/val2;
default:
return val1+val2;
}
} }
// http://localhost:8080/split?value=dghghyyh&sep=g
@GetMapping("/split")
public @ResponseBody String[] split(@RequestParam(defaultValue = "") String value,
@RequestParam(defaultValue = " ") String sep) {
return value.split(sep);
}
// http://localhost:8080/toHex?number=765
@GetMapping("/toHex")
public @ResponseBody String toHex(@RequestParam(defaultValue = "0") int number) {
return Integer.toHexString(number);
}
} }