Lab1
This commit is contained in:
parent
815967146e
commit
a6d16481da
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user