From c18ecea13bed8571e409d032b729eebffe3d7b11 Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Tue, 23 Apr 2019 22:03:06 +0400 Subject: [PATCH] #115 move method to service --- .../java/ru/ulstu/grant/controller/GrantController.java | 7 +------ src/main/java/ru/ulstu/grant/service/GrantService.java | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/ru/ulstu/grant/controller/GrantController.java b/src/main/java/ru/ulstu/grant/controller/GrantController.java index 5a0c594..92ce826 100644 --- a/src/main/java/ru/ulstu/grant/controller/GrantController.java +++ b/src/main/java/ru/ulstu/grant/controller/GrantController.java @@ -83,12 +83,7 @@ public class GrantController { @PostMapping(value = "/grant", params = "attachPaper") public String attachPaper(GrantDto grantDto) { - if (!grantDto.getPaperIds().isEmpty()) { - grantDto.getPapers().clear(); - grantDto.setPapers(grantService.getGrantPapers(grantDto.getPaperIds())); - } else { - grantDto.getPapers().clear(); - } + grantService.attachPaper(grantDto); return GRANT_PAGE; } diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 2c63acc..ea5a994 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -176,4 +176,12 @@ public class GrantService { return paperService.findAll(); } + public void attachPaper(GrantDto grantDto) { + if (!grantDto.getPaperIds().isEmpty()) { + grantDto.getPapers().clear(); + grantDto.setPapers(getGrantPapers(grantDto.getPaperIds())); + } else { + grantDto.getPapers().clear(); + } + } }