diff --git a/Lab2_1/demo/src/main/java/com/example/demo/ApiController.java b/Lab2_1/demo/src/main/java/com/example/demo/ApiController.java deleted file mode 100644 index 502546d..0000000 --- a/Lab2_1/demo/src/main/java/com/example/demo/ApiController.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.example.demo; - -// import java.util.Date; -import java.util.HashMap; -// import java.util.List; -import java.util.Map; - -// import org.slf4j.Logger; -// import org.slf4j.LoggerFactory; -// import org.springframework.boot.autoconfigure.security.SecurityProperties.User; -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("/user") -public class ApiController { - // private final Logger log = LoggerFactory.getLogger(ApiController.class); - - // @GetMapping - // public String get(@RequestParam(name = "name", defaultValue = "World") String name) { - // return String.format("Hello, %s!", name); - // } - - // @GetMapping("/test") - // public String getTest() { - // return new Date().toString(); - // } - - // @GetMapping("/num") - // public Integer getNum() { - // return 10; - // } - - // @GetMapping("/list") - // public List getList() { - // return List.of(10, 20, 30, 40, 50); - // } - - // @PutMapping("/{name}") - // public String putMethodName(@PathVariable(name = "name") String name, @RequestBody String entity) { - // log.info("The body value is {}", entity); - // return get(name); - // } - - // @PutMapping("user/{idUser}") - // public UserDto postUser(@PathVariable(name = "idUser") String idUser) { - // // Играем с айдишниками - // return new UserDto(); - // } - - - Map users = new HashMap<>(); - - @GetMapping - public Map getUsers() { - return users; - } - - @GetMapping("/{id}") - public UserDto getUser(@PathVariable(name = "id") int id) { - return users.get(id); - } - - @DeleteMapping("/{id}") - public UserDto delete(@PathVariable(name = "id") int id) { - UserDto usr = users.get(id); - users.remove(id); - return usr; - } - - @PostMapping - public UserDto postMap(@RequestBody UserDto userDto) { - users.put(users.size(), userDto); - return userDto; - } - - @PutMapping("/{id}") - public UserDto putMap(@RequestBody UserDto UserDto, @PathVariable(name = "id") int id) { - // users.put(id, UserDto); - users.replace(id, UserDto); - return UserDto; - } -} diff --git a/Lab2_1/demo/src/main/java/com/example/demo/DemoApplication.java b/Lab2_1/demo/src/main/java/com/example/demo/DemoApplication.java deleted file mode 100644 index ac442ae..0000000 --- a/Lab2_1/demo/src/main/java/com/example/demo/DemoApplication.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -@SpringBootApplication -@RestController -@RequestMapping("/api") -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/Lab2_1/demo/src/main/java/com/example/demo/LinesController.java b/Lab2_1/demo/src/main/java/com/example/demo/LinesController.java deleted file mode 100644 index d34097f..0000000 --- a/Lab2_1/demo/src/main/java/com/example/demo/LinesController.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.example.demo; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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.RestController; - - -@RestController -@RequestMapping("/line") -public class LinesController { - List lines = new ArrayList<>(); - - @GetMapping - public List getLines() { - return lines.stream().toList(); - } - - @GetMapping("/{id}") - public LinesDTO getLine(@PathVariable(name = "id") int id) { - return lines.get(id); - } - - @DeleteMapping("/{id}") - public LinesDTO deleteLine(@PathVariable(name = "id") int id) { - LinesDTO lin = lines.get(id); - lines.remove(id); - return lin; - } - - @PostMapping - public LinesDTO postMap(@RequestBody LinesDTO linesDto) { - lines.add(lines.size(), linesDto); - return linesDto; - } - - @PutMapping("/{id}") - public LinesDTO putMap(@RequestBody LinesDTO LinesDto, @PathVariable(name = "id") int id) { - // lines.put(id, LinesDto); - lines.add(id, LinesDto); - return LinesDto; - } -} diff --git a/Lab2_1/demo/src/main/java/com/example/demo/LinesDTO.java b/Lab2_1/demo/src/main/java/com/example/demo/LinesDTO.java deleted file mode 100644 index ad21064..0000000 --- a/Lab2_1/demo/src/main/java/com/example/demo/LinesDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.example.demo; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class LinesDTO { - private String id; - private String title; - private String description; - private String count; - private String price; - - public LinesDTO() { - } - - @JsonCreator - public LinesDTO ( - @JsonProperty(value = "id") String id, - @JsonProperty(value = "title") String title, - @JsonProperty(value = "description") String description, - @JsonProperty(value = "count") String count, - @JsonProperty(value = "price") String price) { - this.id = id; - this.title = title; - this.description = description; - this.count = count; - this.price = price; - } - - public String getId() { - return id; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public String getCount() { - return count; - } - - public String getPrice() { - return price; - } - -} diff --git a/Lab2_1/demo/src/main/java/com/example/demo/UserDto.java b/Lab2_1/demo/src/main/java/com/example/demo/UserDto.java deleted file mode 100644 index c64fcc3..0000000 --- a/Lab2_1/demo/src/main/java/com/example/demo/UserDto.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.demo; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class UserDto { - private String email; - private String name; - private String age; - private String password; - - public UserDto() { - } - - @JsonCreator - public UserDto ( - @JsonProperty(value = "email") String email, - @JsonProperty(value = "name") String name, - @JsonProperty(value = "age") String age, - @JsonProperty(value = "password") String password) { - this.email = email; - this.name = name; - this.age = age; - this.password = password; - } - - - public String getEmail() { - return email; - } - - public String getName() { - return name; - } - - public String getAge() { - return age; - } - - public String getPassword() { - return password; - } -} diff --git a/Lab2_1/demo/src/test/java/com/example/demo/DemoApplicationTests.java b/Lab2_1/demo/src/test/java/com/example/demo/DemoApplicationTests.java deleted file mode 100644 index 2778a6a..0000000 --- a/Lab2_1/demo/src/test/java/com/example/demo/DemoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoApplicationTests { - - @Test - void contextLoads() { - } - -}