diff --git a/backend/src/main/java/com/example/todoapp/controller/ToBuysController.java b/backend/src/main/java/com/example/todoapp/controller/ToBuysController.java index ca72bf5..196f8a8 100644 --- a/backend/src/main/java/com/example/todoapp/controller/ToBuysController.java +++ b/backend/src/main/java/com/example/todoapp/controller/ToBuysController.java @@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.*; /** * 購入リストに関するRESTコントローラー *
- * このコントローラーは、購入リスト (to_buys) へのアイテム追加機能を提供します。 + * このコントローラーは、購入リスト (toBuys) へのアイテム追加機能を提供します。 * リクエストボディには ToBuyDTO 形式のデータが期待されます。 *
*/ @@ -99,7 +99,7 @@ public class ToBuysController { Stuffs stuff = toBuy.getStuff(); resp.setTobuyId(toBuy.getTobuyId()); resp.setStuffId(stuff.getStuffId()); - resp.setStuff_name(stuff.getStuffName()); + resp.setStuffName(stuff.getStuffName()); resp.setAmount(toBuy.getAmount()); resp.setShop(toBuy.getStore()); return resp; diff --git a/backend/src/main/java/com/example/todoapp/dto/ToBuyResponse.java b/backend/src/main/java/com/example/todoapp/dto/ToBuyResponse.java index 8d1a992..e4a677a 100644 --- a/backend/src/main/java/com/example/todoapp/dto/ToBuyResponse.java +++ b/backend/src/main/java/com/example/todoapp/dto/ToBuyResponse.java @@ -6,7 +6,7 @@ import lombok.Data; public class ToBuyResponse { private int tobuyId; private Long stuffId; - private String stuff_name; + private String stuffName; private int amount; private String shop; } \ No newline at end of file diff --git a/backend/src/main/java/com/example/todoapp/dto/ToBuysDTO.java b/backend/src/main/java/com/example/todoapp/dto/ToBuysDTO.java index 1bdee7f..111ccad 100644 --- a/backend/src/main/java/com/example/todoapp/dto/ToBuysDTO.java +++ b/backend/src/main/java/com/example/todoapp/dto/ToBuysDTO.java @@ -19,9 +19,9 @@ public class ToBuysDTO { private int price; private int amount; private String shop; - private String stuff_name; + private String stuffName; private String category; - private LocalDate exp_date; - private LocalDate last_update; - private LocalDate buy_date; + private LocalDate expDate; + private LocalDate lastUpdate; + private LocalDate buyDate; } \ No newline at end of file diff --git a/backend/src/main/java/com/example/todoapp/model/RecipeStuffs.java b/backend/src/main/java/com/example/todoapp/model/RecipeStuffs.java index 0d911ef..efd9017 100644 --- a/backend/src/main/java/com/example/todoapp/model/RecipeStuffs.java +++ b/backend/src/main/java/com/example/todoapp/model/RecipeStuffs.java @@ -46,8 +46,8 @@ public class RecipeStuffs { @NotBlank @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( - name = "recipe_id", - referencedColumnName = "recipe_id", + name = "recipeId", + referencedColumnName = "recipeId", nullable = false ) private Recipes recipes; @@ -59,8 +59,8 @@ public class RecipeStuffs { @NotBlank @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( - name = "stuff_id", - referencedColumnName = "stuff_id", + name = "stuffId", + referencedColumnName = "stuffId", nullable = false ) private Stuffs stuff; diff --git a/backend/src/main/java/com/example/todoapp/model/Recipes.java b/backend/src/main/java/com/example/todoapp/model/Recipes.java index cdaa809..25eaaad 100644 --- a/backend/src/main/java/com/example/todoapp/model/Recipes.java +++ b/backend/src/main/java/com/example/todoapp/model/Recipes.java @@ -35,14 +35,14 @@ public class Recipes { */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name="recipe_id") + @Column(name="recipeId") private int recipeId ; /** * カテゴリ名 */ @NotNull - @Column(name="recipe_name", unique = true, length = 255, nullable = false) + @Column(name="recipeName", unique = true, length = 255, nullable = false) private String recipieName; /** diff --git a/backend/src/main/java/com/example/todoapp/model/Stocks.java b/backend/src/main/java/com/example/todoapp/model/Stocks.java index 398cf2b..8c7eca6 100644 --- a/backend/src/main/java/com/example/todoapp/model/Stocks.java +++ b/backend/src/main/java/com/example/todoapp/model/Stocks.java @@ -39,7 +39,7 @@ public class Stocks { */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name="stock_id") + @Column(name="stockId") private Long stockId ; @@ -49,8 +49,8 @@ public class Stocks { @NotNull @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( - name = "stuff_id", - referencedColumnName = "stuff_id", + name = "stuffId", + referencedColumnName = "stuffId", nullable = false ) private Stuffs stuff; @@ -62,7 +62,7 @@ public class Stocks { @NotNull @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( - name = "user_id", + name = "userId", referencedColumnName = "id", nullable = false ) @@ -84,18 +84,18 @@ public class Stocks { * 購入日 */ @Column(nullable = false) - private LocalDate buy_date; + private LocalDate buyDate; /** * 最後の操作時間 */ @Column(nullable = false) - private LocalDate last_update; + private LocalDate lastUpdate; /** * 賞味期限 */ @Column(nullable = false) - private LocalDate exp_date; + private LocalDate expDate; } \ No newline at end of file diff --git a/backend/src/main/java/com/example/todoapp/model/Stuffs.java b/backend/src/main/java/com/example/todoapp/model/Stuffs.java index 2b164ad..14fb111 100644 --- a/backend/src/main/java/com/example/todoapp/model/Stuffs.java +++ b/backend/src/main/java/com/example/todoapp/model/Stuffs.java @@ -35,14 +35,14 @@ import lombok.NoArgsConstructor; */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "stuff_id") + @Column(name = "stuffId") private Long stuffId; /** * カテゴリ名 */ @NotNull - @Column(name = "stuff_name", unique = true, length = 255, nullable = false) + @Column(name = "stuffName", unique = true, length = 255, nullable = false) private String stuffName; /** diff --git a/backend/src/main/java/com/example/todoapp/model/ToBuys.java b/backend/src/main/java/com/example/todoapp/model/ToBuys.java index d02faa4..e000516 100644 --- a/backend/src/main/java/com/example/todoapp/model/ToBuys.java +++ b/backend/src/main/java/com/example/todoapp/model/ToBuys.java @@ -28,7 +28,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @Entity -@Table(name = "to_buys") +@Table(name = "toBuys") public class ToBuys { /** @@ -36,7 +36,7 @@ public class ToBuys { */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "tobuy_id") + @Column(name = "tobuyId") private int tobuyId ; /** @@ -45,8 +45,8 @@ public class ToBuys { @NotNull @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( - name = "stuff_id", - referencedColumnName = "stuff_id", + name = "stuffId", + referencedColumnName = "stuffId", nullable = false ) private Stuffs stuff; @@ -61,7 +61,7 @@ public class ToBuys { * 多対一の関係で、遅延ロードを使用 */ @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id", nullable = false) + @JoinColumn(name = "userId", nullable = false) private User user; /** diff --git a/backend/src/main/java/com/example/todoapp/repository/StocksRepository.java b/backend/src/main/java/com/example/todoapp/repository/StocksRepository.java index 3fd0855..35b2dd4 100644 --- a/backend/src/main/java/com/example/todoapp/repository/StocksRepository.java +++ b/backend/src/main/java/com/example/todoapp/repository/StocksRepository.java @@ -8,7 +8,13 @@ package com.example.todoapp.repository; import com.example.todoapp.model.Stocks; + +import jakarta.transaction.Transactional; + import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -24,12 +30,12 @@ import java.util.List; @Repository public interface StocksRepository extends JpaRepository- * このクラスは to_buys テーブルに対する基本的なCRUD操作を提供します。 + * このクラスは toBuys テーブルに対する基本的なCRUD操作を提供します。 * Spring Data JPAによって自動的に実装されます。 *
*/ @@ -34,7 +34,7 @@ public interface ToBuysRepository extends JpaRepository- * このクラスは、購入リスト (to_buys) の登録処理を提供します。 + * このクラスは、購入リスト (toBuys) の登録処理を提供します。 * 材料 (stuffs) の存在確認と新規作成、ユーザー情報の取得などを行います。 *
*/ @@ -73,7 +73,7 @@ public class ToBuysService { if (toBuyDTO.getStuffId() == null) { // 新しい材料を作成 stuff = new Stuffs(); - stuff.setStuffName(toBuyDTO.getStuff_name()); + stuff.setStuffName(toBuyDTO.getStuffName()); stuff.setCategory(toBuyDTO.getCategory()); stuff = stuffsRepository.save(stuff); } else { @@ -112,7 +112,7 @@ public class ToBuysService { if (toBuyDTO.getStuffId() == null) { // 新しい材料を作成 stuffs = new Stuffs(); - stuffs.setStuffName(toBuyDTO.getStuff_name()); + stuffs.setStuffName(toBuyDTO.getStuffName()); stuffs.setCategory(toBuyDTO.getCategory()); stuffs = stuffsRepository.save(stuffs); } else { @@ -124,7 +124,7 @@ public class ToBuysService { stuffs = optionalStuffs.get(); //update - // stuffs.setStuff_name(toBuyDTO.getStuff_name()); + // stuffs.setStuffName(toBuyDTO.getStuffName()); // stuffs.setCategory(toBuyDTO.getCategory()); stuffs = stuffsRepository.save(stuffs); } @@ -160,7 +160,7 @@ public class ToBuysService { */ @Transactional public int deleteToBuyByIds(Long userId, int tobuyId) { - return toBuysRepository.deleteByUser_IdAndTobuyId(userId, tobuyId); + return toBuysRepository.deleteByUserIdAndTobuyId(userId, tobuyId); } public Stocks buyToBuys(String username, ToBuysDTO dto) { @@ -174,9 +174,9 @@ public class ToBuysService { stock.setUser(user); stock.setAmount(dto.getAmount()); stock.setPrice(dto.getPrice()); - stock.setLast_update(dto.getLast_update()); - stock.setBuy_date(dto.getBuy_date()); - stock.setExp_date(dto.getExp_date()); + stock.setLastUpdate(dto.getLastUpdate()); + stock.setBuyDate(dto.getBuyDate()); + stock.setExpDate(dto.getExpDate()); deleteToBuyByIds(dto.getUserId(), dto.getTobuyId()); // データベースに保存 return stocksRepository.save(stock);