Feat/wakape/user groups put api#1100
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements a new endpoint for updating user group assignments by year, including a new repository for bulk operations and a domain-level diffing utility. The feedback highlights opportunities to optimize performance by removing a redundant database query in the use case and to improve code robustness by addressing unused variables and tight coupling in the row scanning logic.
Deploying finansu with
|
| Latest commit: |
2df3d6e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4b5e55fa.finansu.pages.dev |
| Branch Preview URL: | https://feat-wakape-user-groups-put.finansu.pages.dev |
Chikuwa0141
reviewed
May 24, 2026
Collaborator
Author
|
@Chikuwa0141 |
Chikuwa0141
approved these changes
May 25, 2026
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.
対応Issue
resolve #0
概要
ユーザーの所属部門を年度ごとに更新するためのAPIを追加。
現在の状態との差分計算をしてから更新する設計にしています。
設計書
【主な実装内容】
openapi.yaml,openapi_gen.go)PUT /users/{user_id}/groups/year/{year}を追加。user_group.go)Diffメソッドを実装。user_group_repository.go)BulkInsertとBulkDeleteを実装。user_usecase.go,user_handler.go)※今回もAIを活用して壁打ちを行いながら、コードの実装しています。
画面スクリーンショット等
今回はバックエンドAPIのみのため割愛。Swagger UIから動作確認可能です。
テスト項目
Swagger UIにて
PUT /users/{user_id}/groups/year/{year}を実行し、以下を確認。groupIdsに今年度の部門ID配列(例:[1, 2])を渡すと、正常にDBが差分更新(登録/削除)されること。groupIdsに空配列[]を渡すと、指定年度の所属だけが全件削除され、過去年度のデータには影響がないこと。groupIdsに存在しないID、または別年度のIDを混ぜてリクエストすると、400エラー (invalid group id) で弾かれること。備考