mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
54 lines
976 B
Go
54 lines
976 B
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
|
)
|
|
|
|
// === DTO Structs ===
|
|
|
|
type UserRelationDTO struct {
|
|
Id uint `json:"id"`
|
|
IdUser int64 `json:"id_user"`
|
|
Email string `json:"email"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type UserListDTO struct {
|
|
UserRelationDTO
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type UserDetailDTO struct {
|
|
UserListDTO
|
|
}
|
|
|
|
// === Mapper Functions ===
|
|
|
|
func ToUserRelationDTO(m entity.User) UserRelationDTO {
|
|
return UserRelationDTO{
|
|
Id: m.Id,
|
|
IdUser: m.IdUser,
|
|
Email: m.Email,
|
|
Name: m.Name,
|
|
}
|
|
}
|
|
|
|
func ToUserListDTO(m entity.User) UserListDTO {
|
|
return UserListDTO{
|
|
UserRelationDTO: ToUserRelationDTO(m),
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func ToUserListDTOs(m []entity.User) []UserListDTO {
|
|
result := make([]UserListDTO, len(m))
|
|
for i, r := range m {
|
|
result[i] = ToUserListDTO(r)
|
|
}
|
|
return result
|
|
}
|