feature-backend-tobuy-stock-2
Amagasu 5 months ago
parent b048eb01d5
commit 292bb6e43b
  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
@NoArgsConstructor
@Entity
@Table(name = "recipe_stuffs")
@Table(name = "recipeStuffs")
public class RecipeStuffs {
@ -37,7 +37,7 @@ public class RecipeStuffs {
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="recipe_stuffs_id")
@Column(name="recipeStuffsId")
private Long recipeStuffsId ;
/**

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

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

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

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

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

Loading…
Cancel
Save