add paper controller

This commit is contained in:
Anton Romanov 2018-05-04 18:04:09 +04:00
parent 0a2a8c503c
commit 896d23948f
3 changed files with 72 additions and 0 deletions

View File

@ -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<List<Paper>> getPapers() {
return new Response<>(paperService.findAll());
}
}

View File

@ -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;
}
}

View File

@ -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<Paper> findAll() {
return Arrays.asList(new Paper(1, "Название стартьи"));
}
}