コントローラー作成、HTML修正等

This commit is contained in:
2026-10-22 11:22:10 +09:00
parent bb9fdcca5e
commit f091771efc
4 changed files with 116 additions and 217 deletions

View File

@@ -6,7 +6,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>4.1.1</version> <version>4.1.1</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> lookup parent from repository
</parent> </parent>
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>team1</artifactId> <artifactId>team1</artifactId>

View File

@@ -1,64 +1,64 @@
package com.example.demo.controller; //package com.example.demo.controller;
//
import java.util.logging.Level; //import java.util.logging.Level;
import java.util.logging.Logger; //import java.util.logging.Logger;
//
import jakarta.servlet.http.HttpSession; //import jakarta.servlet.http.HttpSession;
//
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; //import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; //import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; //import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; //import org.springframework.web.bind.annotation.RequestMethod;
//
import com.example.demo.form.ApprovalForm; //import com.example.demo.form.ApprovalForm;
//
/** ///**
* 書籍貸出承認確認用のコントローラ // * 書籍貸出承認確認用のコントローラ
*/ // */
@Controller //@Controller
public class ApprovalConfirmController { //public class ApprovalConfirmController {
//
// ログ出力用インスタンス // // ログ出力用インスタンス
private final static Logger LOGGER = Logger.getLogger(ApprovalConfirmController.class.getName()); // private final static Logger LOGGER = Logger.getLogger(ApprovalConfirmController.class.getName());
//
// エラーメッセージ用の定数フィールド // // エラーメッセージ用の定数フィールド
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; // private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
//
HttpSession httpSession; // HttpSession httpSession;
ApprovalForm approvalform; // ApprovalForm approvalform;
//
@Autowired // @Autowired
public ApprovalConfirmController( // public ApprovalConfirmController(
HttpSession httpSession, // HttpSession httpSession,
ApprovalForm approvalform) { // ApprovalForm approvalform) {
this.httpSession = httpSession; // this.httpSession = httpSession;
this.approvalform = approvalform; // this.approvalform = approvalform;
} // }
//
@ModelAttribute // @ModelAttribute
public ApprovalForm approvalForm() { // public ApprovalForm approvalForm() {
return new ApprovalForm(); // return new ApprovalForm();
} // }
//
@RequestMapping(value = "/ApprovalConfirm", method = RequestMethod.POST) // @RequestMapping(value = "/ApprovalConfirm", method = RequestMethod.POST)
public String AprrvalForm(ApprovalForm ApprovalForm, Model model) { // public String AprrvalForm(ApprovalForm ApprovalForm, Model model) {
//
try { // try {
//
//
return; // return;
} catch (Exception e) { // } catch (Exception e) {
// ログイン情報の破棄 // // ログイン情報の破棄
httpSession.invalidate(); // httpSession.invalidate();
//
e.printStackTrace(); // e.printStackTrace();
//
// エラーログ出力 // // エラーログ出力
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); // LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// エラー画面遷移 // // エラー画面遷移
return "error"; // return "error";
} // }
} // }
} //}

View File

@@ -1,31 +1,31 @@
package com.example.demo.service.Impl; //package com.example.demo.service.Impl;
//
import java.util.List; //import java.util.List;
//
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; //import org.springframework.transaction.annotation.Transactional;
//
import com.example.demo.repository.Borrow_BooksRepository; //import com.example.demo.repository.Borrow_BooksRepository;
import com.example.demo.service.ApprovalBorrowBooks; //import com.example.demo.service.ApprovalBorrowBooks;
//
@Service //@Service
@Transactional //@Transactional
public class ApprovalBorrowBooksImpl implements ApprovalBorrowBooks { //public class ApprovalBorrowBooksImpl implements ApprovalBorrowBooks {
//
Borrow_BooksRepository borrowbooksRepository; // Borrow_BooksRepository borrowbooksRepository;
//
@Autowired // @Autowired
public ApprovalBorrowBooksImpl(Borrow_BooksRepository borrowbooksRepository) { // public ApprovalBorrowBooksImpl(Borrow_BooksRepository borrowbooksRepository) {
this.borrowbooksRepository = borrowbooksRepository; // this.borrowbooksRepository = borrowbooksRepository;
} // }
//
/* 申請情報から全件取得 // /* 申請情報から全件取得
* @return 取得した情報すべて // * @return 取得した情報すべて
*/ // */
public List<???> selectAll() { // public List<???> selectAll() {
return ???Entity.create???List(???Repository.findAll()); // return ???Entity.create???List(???Repository.findAll());
} // }
//
//
} //}

View File

@@ -12,99 +12,9 @@
</head> </head>
<body> <body>
<h1>
<div class="rightSection"> <div class="rightSection">
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button> <button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div> </div>
</h1>
<form action="selectEmployeeInfo"
method="post"
th:object="${searchConditionEmployeeForm}">
<div class="msgBox error" th:if="${messageError} != null">
<span class="error" th:text="${messageError.message}"></span>
</div>
<table>
<tr>
<th class="header">申請ID</th>
<td>
<label>
<input placeholder="申請ID"
th:field="*{idRequest}"
type="number"/>
</label>
<label>
<input class="readOnly"
name="idRequest"
readonly="readonly"
th:value="*{idRequest}"
type="number"/>
</label>
</td>
</tr>
<tr>
<th class="header">申請者名</th>
<td>
<select th:field="*{nmApplication}">
<option value=""></option>
<option th:each="department : ${departmentFormList}"
th:selected="${searchConditionEmployeeForm.idDepartment != null && department.idDepartment == searchConditionEmployeeForm.idDepartment}"
th:text="${department.nmDepartment}"
th:value="${department.idDepartment}">
</option>
</select>
<input placeholder="申請者名"
th:field="*{nmApplicant}"
type="text"/>
</td>
</tr>
<tr>
<th class="header">書籍名</th>
<td>
<input placeholder="書籍名"
th:field="*{nmBook}"
type="text"/>
</td>
</tr>
<tr>
<th class="header">申請日</th>
<td>
<input placeholder="申請日"
th:field="*{dateRequest}"
type="date"/>
</td>
</tr>
<td>
<th class="header">貸出日</th>
<td>
<input placeholder="貸出日"
th:field="*{dateBorrow}"
type="date"/>
</td>
</tr>
<tr>
<th class="header">返却予定日</th>
<td>
<input placeholder="返却予定日"
th:field="*{dateScheduledReturn}"
type="date"/>
</td>
</tr>
<tr>
<th class="header">操作</th>
<td>
<button class="approvalButton" onclick="approvalSubmit()">承認</button>
</td>
</tr>
</table>
</form>
<div class="header-spacing"></div> <div class="header-spacing"></div>
<a href="showMenu">メニューに戻る</a> <a href="showMenu">メニューに戻る</a>
@@ -112,37 +22,38 @@
<div class="header-spacing"></div> <div class="header-spacing"></div>
<h1><span>検索結果</span></h1> <h1><span>検索結果</span></h1>
<div class="header-spacing"></div>
<th:block th:if="${messageInfo != null}">
<script th:inline="javascript">
alert([[${messageInfo.message}]]);
</script>
</th:block>
<div class="header-spacing"></div> <div class="header-spacing"></div>
<th:block th:if="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}"> <th:block th:if="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}">
<!-- 検索結果が1件以上ある場合 --> <!-- 検索結果が1件以上ある場合 -->
<table class="table-grid table-striped table-hover"> <table class="table-grid table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th style="width: 60px;">申請ID</th> <th style="width: 100px;">申請ID</th>
<th style="width: 100px;">申請者名</th> <th style="width: 100px;">申請者名</th>
<th style="width: 150px;">書籍名</th> <th style="width: 100px;">書籍名</th>
<th style="width: 150px;">申請日</th> <th style="width: 100px;">申請日</th>
<th style="width: 100px;">貸出日</th> <th style="width: 100px;">貸出日</th>
<th style="width: 70px;">返却予定日</th> <th style="width: 100px;">返却予定日</th>
<th style="width: 150px;">操作</th> <th style="width: 100px;">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="employeeInfoForm : ${employeeInfoFormList}"> <tr th:each="employeeInfoForm : ${employeeInfoFormList}">
<td th:text="${employeeInfoForm.idEmployee}"></td> <td th:text="${employeeInfoForm.idRequest}"></td>
<td th:text="${employeeInfoForm.nmEmployee}"></td> <td th:text="${employeeInfoForm.nmApplicant}"></td>
<td th:text="${employeeInfoForm.knEmployee}"></td> <td th:text="${employeeInfoForm.nmBook}"></td>
<td th:text="${employeeInfoForm.mailAddress}"></td> <td th:text="${employeeInfoForm.dateRequest}"></td>
<td th:text="${employeeInfoForm.password}"></td> <td th:text="${employeeInfoForm.dateBorrow}"></td>
<td th:text="${employeeInfoForm.adminAuth}"></td> <td th:text="${employeeInfoForm.dateReturn}"></td>
<td th:text="${employeeInfoForm.nmDepartment}"></td> <td th:text="${employeeInfoForm.dateRequest}"></td>
<td>
<form action="/approve" method="get">
<input name="" th:value="${}" type="hidden">
<input type="submit" value="承認">
</form>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -154,17 +65,5 @@
</th:block> </th:block>
</body> </body>
<script type="text/javascript">
function clearInput() {
document.getElementById('idRequest').value = '';
document.getElementById('idApplicant').value = '';
document.getElementById('nmBook').value = '';
document.getElementById('dateRequest').value = '';
document.getElementById('dateBorrow').value = '';
document.getElementById('dateReturn').value = '';
document.getElementById('dateRequest').selectedIndex = 0;
}
</script>
</html> </html>