Initial commit
This commit is contained in:
commit
c0cb826917
63 changed files with 2069 additions and 0 deletions
20
internal/application/mapper/image_result.go
Normal file
20
internal/application/mapper/image_result.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package mapper
|
||||
|
||||
import (
|
||||
"58team_blog/internal/application/common"
|
||||
"58team_blog/internal/application/queries"
|
||||
"58team_blog/internal/domain/entities"
|
||||
)
|
||||
|
||||
func CreateImageResultFromEntity(entity *entities.Images) *common.ImageResult {
|
||||
return &common.ImageResult{
|
||||
Id: entity.Id,
|
||||
Path: entity.Path,
|
||||
}
|
||||
}
|
||||
|
||||
func CreateImageFindByIdResultFromEntity(entity *entities.Images) *queries.ImageFindByIdResult {
|
||||
return &queries.ImageFindByIdResult{
|
||||
Result: CreateImageResultFromEntity(entity),
|
||||
}
|
||||
}
|
||||
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),
|
||||
}
|
||||
}
|
||||
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),
|
||||
}
|
||||
}
|
||||
43
internal/application/mapper/user_result.go
Normal file
43
internal/application/mapper/user_result.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package mapper
|
||||
|
||||
import (
|
||||
"58team_blog/internal/application/common"
|
||||
"58team_blog/internal/application/queries"
|
||||
"58team_blog/internal/domain/entities"
|
||||
)
|
||||
|
||||
func CreateUserResultFromEntity(entity *entities.User) *common.UserResult {
|
||||
return &common.UserResult{
|
||||
Id: entity.Id,
|
||||
UserName: entity.UserName,
|
||||
Password: entity.Password,
|
||||
}
|
||||
}
|
||||
|
||||
func CreateUserResultListFromEntity(entityList []*entities.User) *common.UserResultList {
|
||||
var result common.UserResultList
|
||||
|
||||
for _, e := range entityList {
|
||||
result.Result = append(result.Result, CreateUserResultFromEntity(e))
|
||||
}
|
||||
|
||||
return &result
|
||||
}
|
||||
|
||||
func CreateUserFindByIdResultFromEntity(entity *entities.User) *queries.UserFindByIdResult {
|
||||
return &queries.UserFindByIdResult{
|
||||
Result: CreateUserResultFromEntity(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreateUserFindByNameResultFromEntity(entity *entities.User) *queries.UserFindByNameResult {
|
||||
return &queries.UserFindByNameResult{
|
||||
Result: CreateUserResultFromEntity(entity),
|
||||
}
|
||||
}
|
||||
|
||||
func CreateUserGetAllResultFromEntity(entity_list []*entities.User) *queries.UserGetAllResult {
|
||||
return &queries.UserGetAllResult{
|
||||
Result: CreateUserResultListFromEntity(entity_list),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue