diff --git a/src/main/java/ru/ulstu/is/cbapp/CbappApplication.java b/src/main/java/ru/ulstu/is/cbapp/CbappApplication.java index ff81a6a..eff8475 100644 --- a/src/main/java/ru/ulstu/is/cbapp/CbappApplication.java +++ b/src/main/java/ru/ulstu/is/cbapp/CbappApplication.java @@ -2,32 +2,39 @@ package ru.ulstu.is.cbapp; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @SpringBootApplication @RestController +@CrossOrigin public class CbappApplication { public static void main(String[] args) { SpringApplication.run(CbappApplication.class, args); } + // http://localhost:8080/calc?v1=15&v2=3 @GetMapping("/calc") - public Integer doSum(@RequestParam(defaultValue = "10") int val1, - @RequestParam(defaultValue = "2") int val2, - @RequestParam(defaultValue = "+") String value) { - switch(value){ - case "-": - return val1-val2; - case "*": - return val1*val2; - case "/": - return val1/val2; - default: - return val1+val2; - } + public Integer doProiz(@RequestParam(defaultValue = "10") int v1, + @RequestParam(defaultValue = "2") int v2) { + return v1*v2; + } + // http://localhost:8080/toUpperCase?value=internetprogramming + @GetMapping("/toUpperCase") + public @ResponseBody String toUpperCase(@RequestParam(defaultValue = "") String value) { + return value.toUpperCase(); } + // 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); + } }