first commit, i i have no idea what i have done
This commit is contained in:
29
server/internal/dto/user.go
Normal file
29
server/internal/dto/user.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package dto
|
||||
|
||||
import "smoop-api/internal/models"
|
||||
|
||||
type UserDto struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Role models.Role `json:"role"`
|
||||
}
|
||||
|
||||
type UserRoleDto struct {
|
||||
Role models.Role `json:"role" binding:"required,oneof=admin user"`
|
||||
}
|
||||
|
||||
// CreateUserDto is used by POST /users/create to create a new user with a role.
|
||||
// Role must be one of: "admin" | "user".
|
||||
type CreateUserDto struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Role string `json:"role" binding:"required,oneof=admin user"`
|
||||
}
|
||||
|
||||
func MapUser(u models.User) UserDto {
|
||||
return UserDto{
|
||||
ID: u.ID,
|
||||
Username: u.Username,
|
||||
Role: u.Role,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user