After reading this article, I change return value of service method entity into DTO.
But I'm little confused in this below situation.
Entity A
<- Repository A
<- Service A
Entity B
<- Repository B
<- Service B
Then , If Service B need to access entity A ,so call method in Service A. Since the result of that method is DTO ,not entity, I'm having a hard time dealing with DTO A in Service B.
Should I call repository A
in Service B
? or should I call Service A
in Service B
and use modelmapper to covert dto to entity in service B?
// Controller code
@RestController
public FooDTO getSomeFoo(){
return new FooDTO(service.getFoo())
}
// Service code
@Service
public Foo getFoo(){
return repository.find(~)
}