Skip to content

add: ユーザー取得APIを追加して登録時の存在確認を修正#8

Open
ayuayuyu wants to merge 1 commit intomainfrom
feature/add-user-get-endpoint
Open

add: ユーザー取得APIを追加して登録時の存在確認を修正#8
ayuayuyu wants to merge 1 commit intomainfrom
feature/add-user-get-endpoint

Conversation

@ayuayuyu
Copy link
Copy Markdown
Collaborator

@ayuayuyu ayuayuyu commented May 10, 2026

#7

スクリーンショット 2026-05-10 16 30 54

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 登録時の存在確認を getBalancegetUser に切り替え
sysken-pay-front/src/pages/admin/user-update/index.tsx 更新時の存在確認を getBalancegetUser に切り替え
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 UserRepositoryGetUserByID を追加
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants