This commit is contained in:
2026-09-28 13:10:53 +09:00
4 changed files with 61 additions and 28 deletions

View File

@@ -5,6 +5,8 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType; import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import lombok.Getter; import lombok.Getter;
@@ -28,8 +30,9 @@ public class AccountEntity {
@Column(name="login_info_id") @Column(name="login_info_id")
private Integer loginInfoId; private Integer loginInfoId;
@Column(name="employee_id") @ManyToOne
private Integer employeeId; @JoinColumn(name = "employee_id")
private Employee employee;
@Column(name="password_hash") @Column(name="password_hash")
private String passwordHash; private String passwordHash;

View File

@@ -6,6 +6,6 @@ import com.example.demo.entity.AccountEntity;
public interface AccountRepository extends JpaRepository<AccountEntity,Integer>{ public interface AccountRepository extends JpaRepository<AccountEntity,Integer>{
AccountEntity findByEmployeeId (Integer employeeId); AccountEntity findByEmployee_EmployeeId (Integer employeeId);
} }

View File

@@ -16,7 +16,7 @@ public class LoginService {
public AccountEntity login(LoginForm form) { public AccountEntity login(LoginForm form) {
AccountEntity accountEntity = AccountEntity accountEntity =
accountRepository.findByEmployeeId(form.getEmployeeId()); accountRepository.findByEmployee_EmployeeId(form.getEmployeeId());
if(accountEntity == null) { if(accountEntity == null) {
return null; return null;

View File

@@ -8,9 +8,33 @@
</head> </head>
<body> <body>
<div class="header-bar">
<div class="header-left">
ShareBooks
</div>
<div class="header-right">
<span class="user">
<span th:text="${session.loginEmployee.employee.employeeName}"></span>
(<span th:text="${session.loginEmployee.adminFlag == 1 ? '管理者' : '一般'}"></span>)
</span>
<a class="button-link" th:href="@{/logout}">
ログアウト
</a>
</div>
</div>
<div class="container"> <div class="container">
<h1>社内図書一覧</h1> <h1>社内図書一覧</h1>
<div class="float-end"> <div class="float-end">
<a th:href="@{/topmenu}">トップメニューへ</a>
</div> </div>
<form class="input-group" th:action="@{/searchBooks}" th:object="${bookSearchForm}" method="get"> <form class="input-group" th:action="@{/searchBooks}" th:object="${bookSearchForm}" method="get">
@@ -32,9 +56,6 @@
<p>※「タイトル」「出版社」「著者名」で検索</p> <p>※「タイトル」「出版社」「著者名」で検索</p>
<form method="get" action="bookLend">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@@ -47,12 +68,12 @@
<th>カテゴリー名</th> <th>カテゴリー名</th>
<th>サブカテゴリー名</th> <th>サブカテゴリー名</th>
<th>保管場所</th> <th>保管場所</th>
<th>本の状態</th> <th th:if="${session.loginEmployee.adminFlag == 1}">本の状態</th>
<th>登録日時</th> <th th:if="${session.loginEmployee.adminFlag == 1}">登録日時</th>
<th>更新日時</th> <th th:if="${session.loginEmployee.adminFlag == 1}">更新日時</th>
<th>寄贈者</th> <th th:if="${session.loginEmployee.adminFlag == 1}">寄贈者</th>
<th>貸出状態</th> <th>貸出状態</th>
<th>操作</th> <th th:if="${session.loginEmployee.adminFlag == 1}">操作</th>
</tr> </tr>
</thead> </thead>
@@ -68,20 +89,23 @@
<td th:text="*{book.bookSubcategory.bookCategory.bookCategoryName}"></td> <td th:text="*{book.bookSubcategory.bookCategory.bookCategoryName}"></td>
<td th:text="*{book.bookSubcategory.bookSubcategoryName}"></td> <td th:text="*{book.bookSubcategory.bookSubcategoryName}"></td>
<td th:text="*{book.storageLocation.locationName}"></td> <td th:text="*{book.storageLocation.locationName}"></td>
<td th:text="*{book.condition == 0 ? '分からない': <td th:if="${session.loginEmployee.adminFlag == 1}"
th:text="*{book.condition == 0 ? '分からない':
book.condition == 1 ? '新品': book.condition == 1 ? '新品':
book.condition == 2 ? '良好': book.condition == 2 ? '良好':
book.condition == 3 ? '使用感あり': book.condition == 3 ? '使用感あり':
book.condition == 4 ? '痛みあり': book.condition == 4 ? '痛みあり':
'不明'}"> '不明'}">
</td> </td>
<td th:text="*{book.createdAt}"></td> <td th:if="${session.loginEmployee.adminFlag == 1}" th:text="*{book.createdAt}"></td>
<td th:text="*{book.updatedAt}"></td> <td th:if="${session.loginEmployee.adminFlag == 1}" th:text="*{book.updatedAt}"></td>
<td th:text="*{book.employee != null ? book.employee.employeeName : '-'}"></td> <td th:if="${session.loginEmployee.adminFlag == 1}"
<td th:text="*{book.employee != null ? book.employee.employeeName : '-'}"></td>
th:text="*{book.bookLends != null ? (book.bookLends.bookStatus == 0 ? '貸出可': '貸出不可') : '貸出可'}"> <td th:text="*{book.bookLends != null ?
</td> (book.bookLends.bookStatus == 0 ? '貸出可': '貸出不可') : '貸出可'}"></td>
<td>
<td th:if="${session.loginEmployee.adminFlag == 1}">
<form method="post" action="/bookLend"> <form method="post" action="/bookLend">
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}"> <input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
<button type="submit" <button type="submit"
@@ -89,14 +113,21 @@
貸出 貸出
</button> </button>
</form> </form>
<form method="post" action="/updateconfirm"> <form method="post" action="/updateconfirm">
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}"> <input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
<button type="submit">更新</button> <button type="submit">
更新
</button>
</form> </form>
<form method="get" action="/delete"> <form method="get" action="/delete">
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}"> <input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
<button type="submit">削除</button> <button type="submit">
削除
</button>
</form> </form>
</td> </td>
</tr> </tr>
@@ -105,12 +136,11 @@
該当する図書がありません 該当する図書がありません
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
</body> </body>
</html> </html>