package ru.ulstu.is.cbapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
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 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);
	}
}
