changes...
This commit is contained in:
parent
41944884b4
commit
ab4b53fd40
26 changed files with 600 additions and 51 deletions
|
|
@ -3,6 +3,7 @@ package services
|
|||
import (
|
||||
"58team_blog/internal/application/commands"
|
||||
"58team_blog/internal/application/common"
|
||||
ie "58team_blog/internal/application/errors"
|
||||
"58team_blog/internal/application/mapper"
|
||||
"58team_blog/internal/application/queries"
|
||||
"58team_blog/internal/domain/entities"
|
||||
|
|
@ -44,6 +45,10 @@ func (s *PostService) FindById(query queries.PostFindByIdQuery) (*queries.PostFi
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if post == nil {
|
||||
return nil, ie.NewNotFoundError("Post")
|
||||
}
|
||||
|
||||
if err := post.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type UserService struct {
|
|||
repo repository.UsersRepository
|
||||
}
|
||||
|
||||
func NewUserService(repo repository.UsersRepository) UserService {
|
||||
func CreateUserService(repo repository.UsersRepository) UserService {
|
||||
return UserService{
|
||||
repo: repo,
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ func (s *UserService) Create(cmd commands.CreateUserCommand) (*common.UserResult
|
|||
{
|
||||
user, err := s.repo.FindByName(cmd.Username)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("User.create findByName error: %s", err)
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue