use dto and domain models for tiers + positions#187
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Board “tiers” and “positions” API to use DTO + domain models end-to-end, and renames the position identifier from oid to officer_id across the DB schema, sqlc queries/models, service layer, handlers, and swagger artifacts.
Changes:
- Rename
position.oid→position.officer_id(migration, queries, sqlc models, DTO/domain/store mappers). - Refactor BoardService/BoardHandler tier + position flows to return/accept
domain.*internally anddto.*at the API boundary. - Update routes and swagger docs to reflect tier param rename (
:id→:tier) and DTO-based schemas.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/queries/board.sql | Updates position queries to use officer_id instead of oid. |
| sql/migrations/000003_create_officers.up.sql | Renames the position PK/FK column to officer_id. |
| internal/dto/tier.go | Adjusts tier DTO update payload shape. |
| internal/dto/position.go | Renames Oid → OfficerID, adds delete DTO, aligns tier type to int64. |
| internal/domain/position.go | Renames Oid → OfficerID, adds domain delete model, changes tier type to int64. |
| internal/domain/officer.go | Removes UUID from update model. |
| internal/api/store/dbmodels/models.go | Renames dbmodel Position field to OfficerID. |
| internal/api/store/dbmodels/board.sql.go | sqlc-generated updates for officer_id columns/params. |
| internal/api/store/board_mapper.go | Updates tier/position domain↔db mappings to match renamed fields/types. |
| internal/api/services/board.go | Board service now returns domain models for tiers/positions. |
| internal/api/routes/v1.go | Renames tiers path param :id → :tier. |
| internal/api/handlers/board.go | Handlers updated to bind DTOs and (partially) return DTOs; swagger annotations updated. |
| internal/api/docs/swagger.yaml | Replaces dbmodels schemas with dto schemas and updates tiers path param name. |
| internal/api/docs/swagger.json | Same as swagger.yaml (JSON form). |
| internal/api/docs/docs.go | Same as swagger.yaml (embedded template). |
| fixtures/*.json | Updates fixture payloads to match DTO JSON (strings instead of sql.Null* objects, officer_id rename). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| officer_id = ?; | ||
|
|
||
| -- NOTE: Had to declare above table as :one, may need to change later to :many | ||
|
|
There was a problem hiding this comment.
keeping a note of this comment
5cdf6c2 to
ea309e6
Compare
| c.JSON(http.StatusOK, gin.H{ | ||
| "message": "Tier created successfully", | ||
| "tier": params.Tier, | ||
| "tier": dto.TierDomainToDto(&tier), |
There was a problem hiding this comment.
Did you mean to return the tier here? Instead of the number. If so update the success message in the godoc annotation.
| officer_id = ?; | ||
|
|
||
| -- NOTE: Had to declare above table as :one, may need to change later to :many | ||
|
|
There was a problem hiding this comment.
keeping a note of this comment
mb for big PR, underestimated it
all routes tested at least once
this is an api-only change, will address CLI in next PR
closes #179
progress for #156