Initial commit
This commit is contained in:
commit
c0cb826917
63 changed files with 2069 additions and 0 deletions
48
internal/application/mapper/posts_result.go
Normal file
48
internal/application/mapper/posts_result.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package mapper
|
||||
|
||||
import (
|
||||
"58team_blog/internal/application/common"
|
||||
"58team_blog/internal/application/queries"
|
||||
"58team_blog/internal/domain/entities"
|
||||
)
|
||||
|
||||
func CreatePostsResultFromEntity(entity *entities.Posts) *common.PostsResult {
|
||||
return &common.PostsResult{
|
||||
Id: entity.Id,
|
||||
UserId: entity.UserId,
|
||||
PostId: entity.PostId,
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostsResultListFromEntityList(entity_list []*entities.Posts) *common.PostsResultList {
|
||||
var result common.PostsResultList
|
||||
for _, e := range entity_list {
|
||||
result.Result = append(result.Result, CreatePostsResultFromEntity(e))
|
||||
}
|
||||
|
||||
return &result
|
||||
}
|
||||
|
||||
func CreatePostsFindByUserIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByUserIdResult {
|
||||
return &queries.PostsFindByUserIdResult{
|
||||
Result: CreatePostsResultFromEntity(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostsFindByPostIdResultFromEntity(entity *entities.Posts) *queries.PostsFindByPostIdResult {
|
||||
return &queries.PostsFindByPostIdResult{
|
||||
Result: CreatePostsResultFromEntity(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostsFindAllByUserIdResultFromEntity(entity_list []*entities.Posts) *queries.PostsFindAllByUserIdResult {
|
||||
return &queries.PostsFindAllByUserIdResult{
|
||||
Result: CreatePostsResultListFromEntityList(entity_list),
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePostsGetAllResultFromEntity(entity_list []*entities.Posts) *queries.PostsGetAllResult {
|
||||
return &queries.PostsGetAllResult{
|
||||
Result: CreatePostsResultListFromEntityList(entity_list),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue