diff --git a/team1/src/main/java/com/example/demo/controller/ApprovalConfirmController.java b/team1/src/main/java/com/example/demo/controller/ApprovalConfirmController.java index 99f280c..5c0ac5b 100644 --- a/team1/src/main/java/com/example/demo/controller/ApprovalConfirmController.java +++ b/team1/src/main/java/com/example/demo/controller/ApprovalConfirmController.java @@ -1,56 +1,53 @@ package com.example.demo.controller; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import com.example.demo.form.ReturnForm; +import com.example.demo.service.ReturnService; + /** * 書籍貸出承認確認用のコントローラ */ @Controller public class ApprovalConfirmController { - // ログ出力用インスタンス -// private final static Logger LOGGER = Logger.getLogger(ApprovalConfirmController.class.getName()); + // HttpSession httpSession; + ReturnService returnService; - // エラーメッセージ用の定数フィールド -// private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - -// HttpSession httpSession; -// Request request; -// -// @Autowired -// public ApprovalConfirmController( -// HttpSession httpSession, -// Request request) { -// this.httpSession = httpSession; -// this.request = request; -// } -// -// @ModelAttribute -// public ApprovalForm approvalForm() { -// return new ApprovalForm(); -// } - - @RequestMapping(value = "/approvalConfirm", method = RequestMethod.POST) - public String AprrvalForm() { - - System.out.println("a"); - return "bookList"; -// try { -// -// -// return ; -// } catch (Exception e) { -// // ログイン情報の破棄 -// httpSession.invalidate(); -// -// e.printStackTrace(); -// -// // エラーログ出力 -// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); -// // エラー画面遷移 -// return "error"; -// } + @Autowired + ApprovalConfirmController(ReturnService returnService) { + this.returnService = returnService; } + + @ModelAttribute + ReturnForm returnForm() { + return new ReturnForm(); + } + + @RequestMapping(value = "/approvalConfirm", method = { RequestMethod.POST, RequestMethod.GET }) + public String ApporvalForm(Model model) { + //System.out.println("a"); + try { + //仮の値を入れる 貸出テーブルのID + Integer id = 1; + //申請IDを元に取得 + ReturnForm approvalresultForm = returnService.getReturnForm(id); + approvalresultForm.setIdRequest(id); + + //returnFormに値をセット + // 画面に返す為の情報をセット + model.addAttribute("returnForm", approvalresultForm); + return "approvalConfirm"; + + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + } diff --git a/team1/src/main/java/com/example/demo/controller/ApprovalConfirmResultController.java b/team1/src/main/java/com/example/demo/controller/ApprovalConfirmResultController.java index 01741be..f933786 100644 --- a/team1/src/main/java/com/example/demo/controller/ApprovalConfirmResultController.java +++ b/team1/src/main/java/com/example/demo/controller/ApprovalConfirmResultController.java @@ -1,11 +1,73 @@ package com.example.demo.controller; +import jakarta.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.example.demo.form.ReturnForm; +import com.example.demo.service.ReturnService; /** - * 書籍貸出完了・却下処理用のコントローラ + * 書籍貸出承認完了・却下処理用のコントローラ */ @Controller public class ApprovalConfirmResultController { + + HttpSession httpSession; + ReturnService returnService; + @Autowired + public ApprovalConfirmResultController(HttpSession httpSession, ReturnService returnService) { + this.httpSession = httpSession; + this.returnService = returnService; + } + + @ModelAttribute + ReturnForm returnForm() { + return new ReturnForm(); + } + + //承認完了画面表示処理 + @RequestMapping(value = "/approvalComplete", method = RequestMethod.POST) + public String approvalComplete(ReturnForm returnForm) { + + try { + //セッションからIDを拾いたい + httpSession.getAttribute(""); + //いったん1ということで + int id = 1; + + returnService.setReturnComplete(returnForm.getIdRequest(), id); + + return "approvalComplete"; + + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + //却下完了画面表示処理 + @RequestMapping(value = "/approvalRejected", method = RequestMethod.POST) + public String approvalRejected(ReturnForm returnForm) { + + try { + //セッションからIDを拾いたい + httpSession.getAttribute(""); + //いったん1ということで + int id = 1; + + returnService.setReturnRejected(returnForm.getIdRequest(), id); + + return "approvalRejected"; + + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } } diff --git a/team1/src/main/resources/templates/approvalComplete.html b/team1/src/main/resources/templates/approvalComplete.html index bc7189b..0cd8456 100644 --- a/team1/src/main/resources/templates/approvalComplete.html +++ b/team1/src/main/resources/templates/approvalComplete.html @@ -2,14 +2,8 @@ - - - - - - - - 書籍貸出承認完了画面 + + 書籍貸出承認画面 diff --git a/team1/src/main/resources/templates/approvalConfirm.html b/team1/src/main/resources/templates/approvalConfirm.html index 966e313..c5f0b58 100644 --- a/team1/src/main/resources/templates/approvalConfirm.html +++ b/team1/src/main/resources/templates/approvalConfirm.html @@ -1,39 +1,28 @@ - - - - - - - 書籍貸出承認確認 + + 書籍貸出承認確認 -

登録内容確認    -
- ログイン者名: - -
-

- - -
+
+ +
+ + -
- -
@@ -44,7 +33,7 @@ @@ -54,9 +43,9 @@ @@ -68,7 +57,7 @@ @@ -80,7 +69,7 @@ @@ -90,9 +79,9 @@ @@ -102,9 +91,9 @@ @@ -116,7 +105,7 @@ @@ -128,7 +117,7 @@ @@ -147,6 +136,5 @@
承認待ち一覧に戻る - - + \ No newline at end of file diff --git a/team1/src/main/resources/templates/approvalRejected.html b/team1/src/main/resources/templates/approvalRejected.html index 79a8dbf..988cd09 100644 --- a/team1/src/main/resources/templates/approvalRejected.html +++ b/team1/src/main/resources/templates/approvalRejected.html @@ -2,14 +2,8 @@ - - - - - - - - 書籍貸出却下画面 + + 書籍貸出却下画面
申請ID