Open
Conversation
There was a problem hiding this comment.
Pull request overview
ユーザー登録/更新時の存在確認を GET /v1/user/{user_id} で行えるように、バックエンドにユーザー取得APIを追加し、フロント側の存在確認ロジックを getBalance 依存から切り替えるPRです(Issue #7 対応)。
Changes:
- バックエンド:
GET /v1/user/{user_id}の OpenAPI 追加、UseCase/Handler/Repository 実装追加 - フロント: OpenAPI 型更新、
UserRepositoryImpl.getUser追加、管理画面(登録/更新)の存在確認APIをgetUserに切り替え - テスト: フロント/バックエンドの関連テストを追加・修正
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sysken-pay-front/src/types/api-schema.d.ts | OpenAPI 生成型に GET /v1/user/{user_id} / GetUserResponse を反映 |
| sysken-pay-front/src/adapter/repository/UserRepositoryImpl.ts | getUser を追加してユーザー取得APIを呼び出し |
| sysken-pay-front/src/pages/admin/user-register/index.tsx | 登録時の存在確認を getBalance → getUser に切り替え |
| sysken-pay-front/src/pages/admin/user-update/index.tsx | 更新時の存在確認を getBalance → getUser に切り替え |
| sysken-pay-front/src/test/repository/UserRepositoryImpl.test.ts | getUser のユニットテスト追加 |
| sysken-pay-front/src/test/repository/PurchaseRepositoryImpl.test.ts | cancelPurchase のリクエストボディ期待値を現行スキーマ(items)に合わせて修正 |
| sysken-pay-backend/docs/openapi.yaml | GET /v1/user/{user_id} と GetUserResponse スキーマを追加 |
| sysken-pay-backend/app/usecase/user/get_user.go | ユーザー取得UseCaseを新規追加(IDバリデーション含む) |
| sysken-pay-backend/app/usecase/user/user_test.go | GetUser のテスト追加、既存テストの user_id 値調整 |
| sysken-pay-backend/app/ui/api/user/user.go | User Handler に GetUser を追加、DIを更新 |
| sysken-pay-backend/app/ui/api/user/response.go | GetUserResponse を追加 |
| sysken-pay-backend/app/server/server.go | GET /v1/user/{user_id} をルーティングに追加(Route構成変更) |
| sysken-pay-backend/app/domain/repository/user.go | UserRepository に GetUserByID を追加 |
| sysken-pay-backend/app/infra/repository/user.go | GetUserByID のDB実装を追加 |
| sysken-pay-backend/app/domain/object/user/user.go | user_id のフォーマットバリデーション(学籍番号形式)を追加 |
| sysken-pay-backend/app/domain/object/user/user_test.go | user_id フォーマットバリデーションに合わせてテスト更新 |
| sysken-pay-backend/app/domain/object/user/get_user.go | DB取得用のファクトリ NewUserFromDB を新規追加 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+98
to
+99
| r.Get("/", userHandler.GetUser) | ||
| r.Patch("/", userHandler.UpdateUser) |
Comment on lines
24
to
30
| try { | ||
| await UserRepositoryImpl.getBalance(barcode); | ||
| await UserRepositoryImpl.getUser(barcode); | ||
| setError("このユーザーはすでに登録済みです"); | ||
| } catch { | ||
| setScannedUser({ user_id: barcode }); | ||
| navigate("/admin/user-register/name"); | ||
| } |
Comment on lines
24
to
30
| try { | ||
| await UserRepositoryImpl.getBalance(barcode); | ||
| await UserRepositoryImpl.getUser(barcode); | ||
| setScannedUser({ user_id: barcode }); | ||
| navigate("/admin/user-update/name"); | ||
| } catch { | ||
| setError("このユーザーは登録されていません"); | ||
| } |
Comment on lines
+8
to
+13
| const { data, error } = await apiClient.GET("/v1/user/{user_id}", { | ||
| params: { path: { user_id: userId } }, | ||
| }); | ||
| if (error) throw new Error(error.message); | ||
| if (!data?.user_id) throw new Error("ユーザーが見つかりませんでした"); | ||
| return data; |
Comment on lines
+30
to
+36
| func toGetUserResponse(user *user.User) *GetUserResponse { | ||
| return &GetUserResponse{ | ||
| Status: "success", | ||
| UserID: user.ID(), | ||
| UserName: user.UserName(), | ||
| CreatedAt: user.CreatedAt().Format("2006-01-02T15:04:05.000Z"), | ||
| } |
Comment on lines
+61
to
+67
| get: | ||
| tags: [user] | ||
| summary: ユーザー取得 | ||
| operationId: getUser | ||
| parameters: | ||
| - $ref: "#/components/parameters/UserId" | ||
| responses: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#7