From f09131edcac2b79763f0686edb2183c6c21d47af Mon Sep 17 00:00:00 2001 From: Milana Ievlewa Date: Wed, 13 Mar 2024 18:37:49 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20's?= =?UTF-8?q?rc/main/java/com/example/demo/ApiController.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/demo/ApiController.java | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/main/java/com/example/demo/ApiController.java diff --git a/src/main/java/com/example/demo/ApiController.java b/src/main/java/com/example/demo/ApiController.java deleted file mode 100644 index df1e67a..0000000 --- a/src/main/java/com/example/demo/ApiController.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.example.demo; - -import java.util.Date; -import java.util.List; -import java.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/usertest") -public class ApiController { - private final Logger log = LoggerFactory.getLogger(ApiController.class); - - List data = new ArrayList<>(List.of( - new UserTest("handle1", "email1", "name1", "password1"), - new UserTest("handle2", "email2", "name2", "password2"))); - - @PostMapping - public UserTest create(@RequestBody UserTest user) { - data.add(user); - return user; - } - - @GetMapping - public List readAll() { - return data; - } - - @GetMapping("/{id}") - public UserTest read(@PathVariable(name = "id") int id) { - return data.get(id); - } - - @PutMapping("/{id}") - public UserTest update(@PathVariable(name = "id") int id, @RequestBody UserTest user) { - UserTest us = data.get(id); - - if (us != null) { - data.remove(id); - } - - data.add(id, user); - return data.get(id); - } - - @DeleteMapping("/{id}") - public UserTest delete(@PathVariable(name = "id") int id) { - UserTest us = data.get(id); - - if (us != null) { - data.remove(id); - } - return null; - } - -}