From 648dea05b320d2a4801017acf9a329ba47ff8dbd Mon Sep 17 00:00:00 2001 From: Safgerd Date: Sun, 19 Feb 2023 19:48:24 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ulstu/is/labwork/LabworkApplication.java | 24 +++++++++++++++++++ .../ru/ulstu/is/labwork/WebConfiguration.java | 13 ++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/main/java/ru/ulstu/is/labwork/WebConfiguration.java diff --git a/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java b/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java index 98213be..e99cf97 100644 --- a/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java +++ b/src/main/java/ru/ulstu/is/labwork/LabworkApplication.java @@ -18,4 +18,28 @@ public class LabworkApplication { public String good_morning(@RequestParam(value = "name", defaultValue = "Sir") String name) { return String.format("Good morning, %s!", name); } + @GetMapping("/sum") + public int sum( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 + num2; + } + @GetMapping("/sub") + public int sub( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 - num2; + } + @GetMapping("/mul") + public int mul( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 * num2; + } + @GetMapping("/div") + public int div( @RequestParam(value = "num1", defaultValue = "0") int num1, + @RequestParam(value = "num2", defaultValue = "0") int num2) + { + return num1 / num2; + } } diff --git a/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java b/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java new file mode 100644 index 0000000..2de704e --- /dev/null +++ b/src/main/java/ru/ulstu/is/labwork/WebConfiguration.java @@ -0,0 +1,13 @@ +package ru.ulstu.is.labwork; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfiguration implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("*"); + } +} \ No newline at end of file