diff --git a/.gitignore b/.gitignore index a1c2a238..1bc94f32 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/.idea/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..a4bdb80c --- /dev/null +++ b/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.1 + + + ru.yandex.practicum + catsgram + 0.0.1-SNAPSHOT + catsgram + Мини-версия популярной соцсети с фотографиями котов. + + 11 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/ru/yandex/practicum/catsgram/CatsgramApplication.java b/src/main/java/ru/yandex/practicum/catsgram/CatsgramApplication.java new file mode 100644 index 00000000..63f822d5 --- /dev/null +++ b/src/main/java/ru/yandex/practicum/catsgram/CatsgramApplication.java @@ -0,0 +1,13 @@ +package ru.yandex.practicum.catsgram; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CatsgramApplication { + + public static void main(String[] args) { + SpringApplication.run(CatsgramApplication.class, args); + } + +} diff --git a/src/main/java/ru/yandex/practicum/catsgram/controller/PostController.java b/src/main/java/ru/yandex/practicum/catsgram/controller/PostController.java new file mode 100644 index 00000000..2b19e51d --- /dev/null +++ b/src/main/java/ru/yandex/practicum/catsgram/controller/PostController.java @@ -0,0 +1,25 @@ +package ru.yandex.practicum.catsgram.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import ru.yandex.practicum.catsgram.model.Post; +import java.util.ArrayList; +import java.util.List; + +@RestController +public class PostController { + + private final List posts = new ArrayList<>(); + + @GetMapping("/posts") + public List findAll() { + return posts; + } + + @PostMapping(value = "/post") + public void create(@RequestBody Post post) { + posts.add(post); + } +} \ No newline at end of file diff --git a/src/main/java/ru/yandex/practicum/catsgram/controller/SimpleController.java b/src/main/java/ru/yandex/practicum/catsgram/controller/SimpleController.java new file mode 100644 index 00000000..be3380f6 --- /dev/null +++ b/src/main/java/ru/yandex/practicum/catsgram/controller/SimpleController.java @@ -0,0 +1,13 @@ +package ru.yandex.practicum.catsgram.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class SimpleController { + + @GetMapping("/home") + public String homePage() { + return "Котограм"; + } +} diff --git a/src/main/java/ru/yandex/practicum/catsgram/model/Post.java b/src/main/java/ru/yandex/practicum/catsgram/model/Post.java new file mode 100644 index 00000000..6a4b8868 --- /dev/null +++ b/src/main/java/ru/yandex/practicum/catsgram/model/Post.java @@ -0,0 +1,41 @@ +package ru.yandex.practicum.catsgram.model; + +import java.time.Instant; + +public class Post { + + private final String author; // автор + private final Instant creationDate = Instant.now(); // дата создания + private String description; // описание + private String photoUrl; // url-адрес фотографии + + public Post(String author, String description, String photoUrl) { + this.author = author; + this.description = description; + this.photoUrl = photoUrl; + } + + public String getAuthor() { + return author; + } + + public Instant getCreationDate() { + return creationDate; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPhotoUrl() { + return photoUrl; + } + + public void setPhotoUrl(String photoUrl) { + this.photoUrl = photoUrl; + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/src/test/java/ru/yandex/practicum/catsgram/CatsgramApplicationTests.java b/src/test/java/ru/yandex/practicum/catsgram/CatsgramApplicationTests.java new file mode 100644 index 00000000..32936573 --- /dev/null +++ b/src/test/java/ru/yandex/practicum/catsgram/CatsgramApplicationTests.java @@ -0,0 +1,13 @@ +package test.java.ru.yandex.practicum.catsgram; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CatsgramApplicationTests { + + @Test + void contextLoads() { + } + +}