From 896d23948ff32fb33bb4bc765c57da38caf0942b Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 4 May 2018 18:04:09 +0400 Subject: [PATCH] add paper controller --- .../paper/controller/PaperController.java | 30 +++++++++++++++++++ src/main/java/ru/ulstu/paper/model/Paper.java | 27 +++++++++++++++++ .../ru/ulstu/paper/service/PaperService.java | 15 ++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/main/java/ru/ulstu/paper/controller/PaperController.java create mode 100644 src/main/java/ru/ulstu/paper/model/Paper.java create mode 100644 src/main/java/ru/ulstu/paper/service/PaperService.java diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java new file mode 100644 index 0000000..4f5dbc0 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -0,0 +1,30 @@ +package ru.ulstu.paper.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import ru.ulstu.configuration.Constants; +import ru.ulstu.core.model.response.Response; +import ru.ulstu.paper.model.Paper; +import ru.ulstu.paper.service.PaperService; + +import java.util.List; + +import static ru.ulstu.user.controller.UserController.URL; + +@RestController +@RequestMapping(URL) +public class PaperController { + public static final String URL = Constants.API_1_0 + "papers"; + + private final PaperService paperService; + + public PaperController(PaperService paperService) { + this.paperService = paperService; + } + + @GetMapping("/papers") + public Response> getPapers() { + return new Response<>(paperService.findAll()); + } +} diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java new file mode 100644 index 0000000..ea485be --- /dev/null +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -0,0 +1,27 @@ +package ru.ulstu.paper.model; + +public class Paper { + private int id; + private String title; + + public Paper(int id, String title) { + this.id = id; + this.title = title; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java new file mode 100644 index 0000000..86a1211 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -0,0 +1,15 @@ +package ru.ulstu.paper.service; + +import org.springframework.stereotype.Service; +import ru.ulstu.paper.model.Paper; + +import java.util.Arrays; +import java.util.List; + +@Service +public class PaperService { + + public List findAll() { + return Arrays.asList(new Paper(1, "Название стартьи")); + } +}