mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
add daily checklist module;adjust master data;adjust migration
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
userDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/users/dto"
|
||||
)
|
||||
|
||||
// === DTO Structs ===
|
||||
|
||||
type DailyChecklistRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DailyChecklistListDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CreatedUser *userDTO.UserRelationDTO `json:"created_user"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type DailyChecklistDetailDTO struct {
|
||||
DailyChecklistListDTO
|
||||
}
|
||||
|
||||
// === Mapper Functions ===
|
||||
|
||||
func ToDailyChecklistRelationDTO(e entity.DailyChecklist) DailyChecklistRelationDTO {
|
||||
var name string
|
||||
if e.Name != nil {
|
||||
name = *e.Name
|
||||
}
|
||||
|
||||
return DailyChecklistRelationDTO{
|
||||
Id: e.Id,
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func ToDailyChecklistListDTO(e entity.DailyChecklist) DailyChecklistListDTO {
|
||||
var createdUser *userDTO.UserRelationDTO
|
||||
// if e.CreatedUser.Id != 0 {
|
||||
// mapped := userDTO.ToUserRelationDTO(e.CreatedUser)
|
||||
// createdUser = &mapped
|
||||
// }
|
||||
|
||||
var name string
|
||||
if e.Name != nil {
|
||||
name = *e.Name
|
||||
}
|
||||
|
||||
return DailyChecklistListDTO{
|
||||
Id: e.Id,
|
||||
Name: name,
|
||||
CreatedAt: e.CreatedAt,
|
||||
UpdatedAt: e.UpdatedAt,
|
||||
CreatedUser: createdUser,
|
||||
}
|
||||
}
|
||||
|
||||
func ToDailyChecklistListDTOs(e []entity.DailyChecklist) []DailyChecklistListDTO {
|
||||
result := make([]DailyChecklistListDTO, len(e))
|
||||
for i, r := range e {
|
||||
result[i] = ToDailyChecklistListDTO(r)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ToDailyChecklistDetailDTO(e entity.DailyChecklist) DailyChecklistDetailDTO {
|
||||
return DailyChecklistDetailDTO{
|
||||
DailyChecklistListDTO: ToDailyChecklistListDTO(e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user