From 7b70861fd8024bf6f5164495e10345b894200bec Mon Sep 17 00:00:00 2001 From: w-yuki Date: Fri, 25 Sep 2026 16:36:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[add]=E3=83=97=E3=83=AB=E3=83=80=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/BookInsertController.java | 15 +++- .../com/example/demo/entity/BookInsert.java | 4 +- .../repository/StorageLocationRepository.java | 9 ++ src/main/resources/templates/bookInsert.html | 84 +++++++++---------- 4 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 src/main/java/com/example/demo/repository/StorageLocationRepository.java diff --git a/src/main/java/com/example/demo/controller/BookInsertController.java b/src/main/java/com/example/demo/controller/BookInsertController.java index 6ed1d7b..c725330 100644 --- a/src/main/java/com/example/demo/controller/BookInsertController.java +++ b/src/main/java/com/example/demo/controller/BookInsertController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping; import com.example.demo.entity.BookInsert; import com.example.demo.repository.BookCategoryRepository; +import com.example.demo.repository.StorageLocationRepository; import com.example.demo.repository.SubCategoryRepository; import com.example.demo.service.BookInsertService; @@ -21,13 +22,18 @@ private BookInsertService bookInsertService; @Autowired private BookCategoryRepository categoryRepository; + @Autowired private SubCategoryRepository subCategoryRepository; +@Autowired +private StorageLocationRepository storageLocationRepository; + @GetMapping("/bookInsert") public String bookInsert(Model model) { model.addAttribute("categoryList",categoryRepository.findAll()); model.addAttribute("subCategoryList",subCategoryRepository.findAll()); + model.addAttribute("locationList",storageLocationRepository.findAll()); model.addAttribute("bookInsert",new BookInsert()); return "bookInsert"; } @@ -37,6 +43,7 @@ private SubCategoryRepository subCategoryRepository; // 確認画面から戻る: POSTされた入力中の値がformに入ったまま入力画面へ @PostMapping("/bookInsertConfirm") public String bookInsertConfirm(BookInsert bookInsert,Model model) { + System.out.println(bookInsert); bookInsertService.save(bookInsert); model.addAttribute("bookInsert",bookInsert); return "bookInsertConfirm"; @@ -46,6 +53,7 @@ private SubCategoryRepository subCategoryRepository; public String bookInsertBack(BookInsert bookInsert,Model model) { model.addAttribute("categoryList",categoryRepository.findAll()); model.addAttribute("subCategoryList",new ArrayList<>()); + model.addAttribute("locationList",storageLocationRepository.findAll()); model.addAttribute("bookInsert",bookInsert); return "bookInsert"; } @@ -56,16 +64,21 @@ private SubCategoryRepository subCategoryRepository; model.addAttribute("categoryList",categoryRepository.findAll()); model.addAttribute("subCategoryList",subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId())); + model.addAttribute("locationList",storageLocationRepository.findAll()); model.addAttribute("bookInsert", bookInsert); return "bookInsert"; } + } - //画面で選択したカテゴリbookInsert.getBookCategoryId()) + //画面で選択したカテゴリbookInsert.getBookCategoryId()に選択した結果をいれる + //subCategoryRepository.findBookCategory_BookCategoryId(bookInsert.getBookCategoryId(1))); + //「カテゴリIDが1のサブカテゴリを取ってくる」 + //model.addAttribute("subCategoryList",取得結果) diff --git a/src/main/java/com/example/demo/entity/BookInsert.java b/src/main/java/com/example/demo/entity/BookInsert.java index ffe074a..9305b62 100644 --- a/src/main/java/com/example/demo/entity/BookInsert.java +++ b/src/main/java/com/example/demo/entity/BookInsert.java @@ -40,7 +40,7 @@ public class BookInsert { private String publisher; @Column(name = "publication_date") - private String publicationDate; + private LocalDate publicationDate; @Column(name = "location_id") private Integer location; @@ -66,7 +66,7 @@ public class BookInsert { @Column(name = "book_approval") private Integer bookApproval; - @Transient + @Transient //DB保存無効 private Integer bookCategoryId; diff --git a/src/main/java/com/example/demo/repository/StorageLocationRepository.java b/src/main/java/com/example/demo/repository/StorageLocationRepository.java new file mode 100644 index 0000000..861a62a --- /dev/null +++ b/src/main/java/com/example/demo/repository/StorageLocationRepository.java @@ -0,0 +1,9 @@ +package com.example.demo.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.example.demo.entity.StorageLocation; + +public interface StorageLocationRepository extends JpaRepository { + +} \ No newline at end of file diff --git a/src/main/resources/templates/bookInsert.html b/src/main/resources/templates/bookInsert.html index 467e577..059917e 100644 --- a/src/main/resources/templates/bookInsert.html +++ b/src/main/resources/templates/bookInsert.html @@ -8,17 +8,12 @@

新規図書登録入力

- -


- +

新しく図書を登録します。必要事項jを入力し、「登録」ボタンを押してください

+ ※は必須項目です +

-
- -




-
+


-
- +
+

-
+


+
- + +

-
+


- -
- + +
+

-
- -

- -
- -

- -
- +

+ +
+ +

+ +
+ +


@@ -103,7 +97,7 @@ --> - +
From 044210adc30850ce5f47b99a0e38ece91e607564 Mon Sep 17 00:00:00 2001 From: w-yuki Date: Fri, 25 Sep 2026 16:59:14 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[add]=E8=AA=A4=E5=AD=97=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/bookInsert.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/bookInsert.html b/src/main/resources/templates/bookInsert.html index 059917e..04a99d9 100644 --- a/src/main/resources/templates/bookInsert.html +++ b/src/main/resources/templates/bookInsert.html @@ -9,7 +9,7 @@

新規図書登録入力



-

新しく図書を登録します。必要事項jを入力し、「登録」ボタンを押してください

+

新しく図書を登録します。必要事項を入力し、「登録」ボタンを押してください

※は必須項目です

@@ -78,7 +78,7 @@

-
+


From d5583722362b7641f8235fbafe05b75daceca2d6 Mon Sep 17 00:00:00 2001 From: s-tajihi <2026_04_00508@it-college.co.jp> Date: Mon, 28 Sep 2026 09:37:58 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[edit]=20=E7=A4=BE=E5=86=85=E5=9B=B3?= =?UTF-8?q?=E6=9B=B8=E4=B8=80=E8=A6=A7=E7=94=BB=E9=9D=A2=E2=86=92=E3=83=88?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/book.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/book.html b/src/main/resources/templates/book.html index 1a02ff4..569e4e1 100644 --- a/src/main/resources/templates/book.html +++ b/src/main/resources/templates/book.html @@ -10,7 +10,9 @@

社内図書一覧

+ @@ -22,13 +24,13 @@ - +
- +

※「タイトル」「出版社」「著者名」で検索

@@ -99,7 +101,7 @@ - + 該当する図書がありません @@ -110,7 +112,7 @@ - +
\ No newline at end of file From 79fd664f86d44ee818ffcc05ae6e5258d63b31e2 Mon Sep 17 00:00:00 2001 From: s-tajihi <2026_04_00508@it-college.co.jp> Date: Mon, 28 Sep 2026 11:34:02 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[edit]=20HTML=E8=A1=A8=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=88=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E5=88=A4=E5=88=A5=EF=BC=89=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/entity/AccountEntity.java | 7 +++- .../demo/repository/AccountRepository.java | 2 +- .../example/demo/service/LoginService.java | 2 +- src/main/resources/templates/book.html | 41 +++++++++++++++---- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/example/demo/entity/AccountEntity.java b/src/main/java/com/example/demo/entity/AccountEntity.java index fc90022..03bbc9b 100644 --- a/src/main/java/com/example/demo/entity/AccountEntity.java +++ b/src/main/java/com/example/demo/entity/AccountEntity.java @@ -5,6 +5,8 @@ import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.Getter; @@ -28,8 +30,9 @@ public class AccountEntity { @Column(name="login_info_id") private Integer loginInfoId; - @Column(name="employee_id") - private Integer employeeId; + @ManyToOne + @JoinColumn(name = "employee_id") + private Employee employee; @Column(name="password_hash") private String passwordHash; diff --git a/src/main/java/com/example/demo/repository/AccountRepository.java b/src/main/java/com/example/demo/repository/AccountRepository.java index db7d155..0e572b2 100644 --- a/src/main/java/com/example/demo/repository/AccountRepository.java +++ b/src/main/java/com/example/demo/repository/AccountRepository.java @@ -6,6 +6,6 @@ import com.example.demo.entity.AccountEntity; public interface AccountRepository extends JpaRepository{ - AccountEntity findByEmployeeId (Integer employeeId); + AccountEntity findByEmployee_EmployeeId (Integer employeeId); } diff --git a/src/main/java/com/example/demo/service/LoginService.java b/src/main/java/com/example/demo/service/LoginService.java index c87eead..27756fb 100644 --- a/src/main/java/com/example/demo/service/LoginService.java +++ b/src/main/java/com/example/demo/service/LoginService.java @@ -16,7 +16,7 @@ public class LoginService { public AccountEntity login(LoginForm form) { AccountEntity accountEntity = - accountRepository.findByEmployeeId(form.getEmployeeId()); + accountRepository.findByEmployee_EmployeeId(form.getEmployeeId()); if(accountEntity == null) { return null; diff --git a/src/main/resources/templates/book.html b/src/main/resources/templates/book.html index 569e4e1..9598a48 100644 --- a/src/main/resources/templates/book.html +++ b/src/main/resources/templates/book.html @@ -8,6 +8,28 @@ + +
+ +
+ ShareBooks +
+ +
+ + + + () + + + + ログアウト + + +
+ +
+

社内図書一覧

@@ -34,9 +56,6 @@

※「タイトル」「出版社」「著者名」で検索

- -
- @@ -54,7 +73,7 @@ - + @@ -83,7 +102,8 @@ - @@ -107,11 +131,10 @@ 該当する図書がありません +
更新日時 寄贈者 貸出状態操作操作
+ + +
- +
- -