Merge remote-tracking branch 'origin/feature-backend-tobuy-stock-2' into feature-backend-tobuy-stock

feature-backend-tobuy-stock
Masaharu.Kato 5 months ago
commit 865f1e2337
  1. 4
      backend/src/main/java/com/example/todoapp/model/RecipeStuffs.java
  2. 2
      backend/src/main/java/com/example/todoapp/model/Task.java
  3. 2
      backend/src/main/java/com/example/todoapp/service/StocksService.java
  4. 2
      frontend/src/pages/AddDishes1.tsx
  5. 70
      frontend/src/services/api.ts
  6. 2
      frontend/src/types/types.ts

@ -28,7 +28,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "recipe_stuffs") @Table(name = "recipeStuffs")
public class RecipeStuffs { public class RecipeStuffs {
@ -37,7 +37,7 @@ public class RecipeStuffs {
*/ */
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="recipe_stuffs_id") @Column(name="recipeStuffsId")
private Long recipeStuffsId ; private Long recipeStuffsId ;
/** /**

@ -51,7 +51,7 @@ public class Task {
* 多対一の関係で遅延ロードを使用 * 多対一の関係で遅延ロードを使用
*/ */
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false) @JoinColumn(name = "userId", nullable = false)
private User user; private User user;
/** /**

@ -45,7 +45,7 @@ public class StocksService {
/** /**
* 指定されたユーザのすべての在庫を取得する * 指定されたユーザのすべての在庫を取得する
* @param username ユーザー名 * @param username ユーザー名
* @return ユーザーの在庫リスト(stock_id昇順) * @return ユーザーの在庫リスト(stockId昇順)
*/ */
public List<Stocks> getALLStocksByUser(String username) { public List<Stocks> getALLStocksByUser(String username) {
User user = getUserByUsername(username); User user = getUserByUsername(username);

@ -60,7 +60,7 @@ const AddDishes1: React.FC = () => {
InputLabelProps={{ style: { fontSize: "40px" }}} InputLabelProps={{ style: { fontSize: "40px" }}}
style={{width: "80%" }} style={{width: "80%" }}
InputProps={{ style: { fontSize: "40px"} }} InputProps={{ style: { fontSize: "40px"} }}
name="dish_name" name="dishName"
// autoComplete="username" // autoComplete="username"
autoFocus autoFocus
value={dish} value={dish}

@ -120,8 +120,8 @@ export const toBuyApi = {
throw new Error(TOBUY_ERRORS.CREATE_FAILED); throw new Error(TOBUY_ERRORS.CREATE_FAILED);
} }
// return response.json(); return response.json();
return {result: true} // return {result: true}
// return { // return {
// "result": true, // "result": true,
@ -202,40 +202,42 @@ export const stockApi = {
* @returns * @returns
*/ */
getStocks: async (): Promise<Stock[]> => { getStocks: async (): Promise<Stock[]> => {
// const response = await fetch(`${API_BASE_URL}/api/tobuy/get`, { const response = await fetch(`${API_BASE_URL}/api/tobuy/get`, {
// headers: getHeaders(), // 認証トークンを含むヘッダー headers: getHeaders(), // 認証トークンを含むヘッダー
// }); });
// if (!response.ok) { if (!response.ok) {
// throw new Error(TASK_ERRORS.FETCH_FAILED); throw new Error(TASK_ERRORS.FETCH_FAILED);
// } }
// return response.json(); return response.json();
return [ // return {
{ // "stock_array": [
"stockId": 1, // {
"stuffId": 10, // "stockId": 1,
"stuffName": "豚肉", // "stuffId": 10,
"amount": 100, // "stuffName": "豚肉",
"price": 200, // "amount": 100,
"buyDate": "2025-05-18T09:00:00.000Z", // "price": 200,
"lastUpdate": "2025-05-18T09:00:00.000Z", // "buyDate": "2025-05-18T09:00:00.000Z",
"expDate": "2025-05-19T10:15:00.000Z", // "lastUpdate": "2025-05-18T09:00:00.000Z",
"category": "肉" // "expDate": "2025-05-19T10:15:00.000Z",
}, // "category": "肉"
{ // },
"stockId": 2, // {
"stuffId": 1, // "stockId": 2,
"stuffName": "トマト", // "stuffId": 1,
"amount": 10, // "stuffName": "トマト",
"price": 200, // "amount": 10,
"buyDate": "2025-05-18T09:00:00.000Z", // "price": 200,
"lastUpdate": "2025-05-18T09:00:00.000Z", // "buyDate": "2025-05-18T09:00:00.000Z",
"expDate": "2025-05-19T10:15:00.000Z", // "lastUpdate": "2025-05-18T09:00:00.000Z",
"category": "野菜" // "expDate": "2025-05-19T10:15:00.000Z",
} // "category": "野菜"
] // }
// ]
// }
}, },

@ -4,7 +4,7 @@
*/ */
export interface Task { export interface Task {
id: number; // タスクの一意識別子 id: number; // タスクの一意識別子
stuff_name: string; // タスクのタイトル stuffName: string; // タスクのタイトル
amount: number; //材料の数量 amount: number; //材料の数量
price: number; //材料の値段 price: number; //材料の値段
buyDate:Date; //購入日時 buyDate:Date; //購入日時

Loading…
Cancel
Save