feat: implement user profile retrieval with roles and permissions caching

This commit is contained in:
Tran Anh Tuan
2026-05-12 14:36:50 +07:00
parent e81a248a61
commit 902caa222f
17 changed files with 671 additions and 19 deletions

View File

@@ -16,8 +16,8 @@ type AdminConfig struct {
}
type JWTConfig struct {
SecretKey string
ExpirationHours int
SecretKey string `mapstructure:"secretkey"`
ExpirationHours int `mapstructure:"expirehours"`
}
type DatabaseConfig struct {

View File

@@ -0,0 +1,7 @@
package models
// Permission represents a system permission (e.g., "read:warehouse", "write:component")
type Permission struct {
Name string `json:"name"`
Description string `json:"description"`
}

View File

@@ -3,6 +3,25 @@ package responses
type BodyRegisterResponse struct {
ID string `json:"id"`
}
type BodyLoginResponse struct {
Token string `json:"token"`
}
// RoleItem represents a role assigned to the user in the profile response.
type RoleItem struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
}
// BodyProfileResponse is the response body for GET /profile.
type BodyProfileResponse struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
FullName string `json:"fullName"`
IsActive bool `json:"isActive"`
Roles []RoleItem `json:"roles"`
Permissions []string `json:"permissions"`
}