feat: refactor profile response structure to include UserInfoResponse

This commit is contained in:
Tran Anh Tuan
2026-05-13 15:37:04 +07:00
parent 902caa222f
commit d2bb7aa3aa
2 changed files with 18 additions and 12 deletions

View File

@@ -15,13 +15,17 @@ type RoleItem struct {
Description string `json:"description"`
}
// BodyProfileResponse is the response body for GET /profile.
type BodyProfileResponse struct {
type UserInfoResponse struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
FullName string `json:"fullName"`
IsActive bool `json:"isActive"`
}
// BodyProfileResponse is the response body for GET /profile.
type BodyProfileResponse struct {
Info UserInfoResponse `json:"info"`
Roles []RoleItem `json:"roles"`
Permissions []string `json:"permissions"`
}

View File

@@ -109,11 +109,13 @@ func GetProfile(c *gin.Context) error {
// 5. Return response
response.Ok(c, "Profile fetched", responses.BodyProfileResponse{
Info: responses.UserInfoResponse{
ID: user.ID,
Username: user.Username,
Email: user.Email,
FullName: user.FullName,
IsActive: user.IsActive,
},
Roles: roles,
Permissions: permissions,
})