[ResourceApp][Backend][Feat] Implement group membership endpoints#74
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Resource application's backend by completing the group membership functionality within the Resource bounded context. It establishes a robust, DDD-style architecture for managing groups and their associated users, ensuring that all interactions are handled with proper validation, error management, and transactional integrity. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'group' feature, including models, repository, service, and API handlers for managing groups and their user memberships. The changes involve adding new database tables (groups and user_groups), integrating them with GORM, and exposing a comprehensive set of REST API endpoints for group CRUD operations and membership management. Review comments suggest improvements such as enhancing security by not exposing raw error messages to clients, ensuring transactional integrity in the RemoveUserFromGroup method to prevent race conditions, adding a unique database constraint for user_groups to enforce data integrity, standardizing error messages for invalid IDs, refactoring anonymous request structs into named types for better maintainability, and correcting code style for struct field alignment.
18ca0a2 to
b2a4f25
Compare
46ff968 to
f164550
Compare
f164550 to
464c6a7
Compare
464c6a7 to
8df9b1f
Compare
…dpoints [ResourceApp][Backend][Feat] Implement group membership endpoints
Overview
This PR completes the Group Membership implementation for the Resource bounded context. It adds full DDD-style flow for /api/groups/:id/users endpoints (GET/POST/DELETE) and enforces atomic DB operations with explicit transactions in repository methods.
GET /api/groups/:id/usersPOST /api/groups/:id/usersDELETE /api/groups/:id/users/:userIdWhat changed
cmd/server/main.go: route registration for group membershipinternal/group/handlers.go: handlers + validation + status mappinginternal/group/services.go: service methodsinternal/group/repository.go: repository methods with transactions (atomic operations)Transactions
POST /groups/:id/users: one transaction → verify group + users + no existing mapping → insert membership rowsDELETE /groups/:id/users/:userId: one transaction delete membership row (in user_groups table) with checkHow to test locally
go test ./...go run ./cmd/server/main.goGET /api/groups/:groupId/usersPOST /api/groups/:groupId/usersDELETE /api/groups/:groupId/users/:userIdrealated to #71
closes #78