Initial commit
This commit is contained in:
commit
c0cb826917
63 changed files with 2069 additions and 0 deletions
47
internal/application/mapper/post_result.go
Normal file
47
internal/application/mapper/post_result.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package mapper
|
||||
|
||||
import (
|
||||
"58team_blog/internal/application/common"
|
||||
"58team_blog/internal/application/queries"
|
||||
"58team_blog/internal/domain/entities"
|
||||
)
|
||||
|
||||
func CreatePostResultFromEntity(entity *entities.Post) *common.PostResult {
|
||||
return &common.PostResult{
|
||||
Id: entity.Id,
|
||||
UserId: entity.UserId,
|
||||
Title: entity.Title,
|
||||
Description: entity.Description,
|
||||
Content: entity.Content,
|
||||
CreatedAt: entity.CreatedAt,
|
||||
UpdatedAt: entity.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostResultListFromEntity(entity_list []*entities.Post) *common.PostResultList {
|
||||
var result common.PostResultList
|
||||
|
||||
for _, e := range entity_list {
|
||||
result.Result = append(result.Result, CreatePostResultFromEntity(e))
|
||||
}
|
||||
|
||||
return &result
|
||||
}
|
||||
|
||||
func CreatePostFindByIdResultFromEntity(entity entities.Post) *queries.PostFindByIdResult {
|
||||
return &queries.PostFindByIdResult{
|
||||
Result: CreatePostResultFromEntity(&entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostFindAllByUserNameResult(entity []*entities.Post) *queries.PostFindAllByUserNameResult {
|
||||
return &queries.PostFindAllByUserNameResult{
|
||||
Result: CreatePostResultListFromEntity(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostGetAllResult(entity_list []*entities.Post) *queries.PostGetAllResult {
|
||||
return &queries.PostGetAllResult{
|
||||
Result: CreatePostResultListFromEntity(entity_list),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue