I have a pretty familiar design, where I have a DAO for each model, and then a class of the Model class, which uses DAO and has all the business logic.
I am a little confused as to how to correctly create these classes of service, specifically what my parameters and my answers should be.
Let's say that I have a JSON action, I can read JSON and then load the objects I need and then pass them to the service, or I can just pass the identifier and then load the objects in the service method.
The embarrassment is that I could do some of these things in the operation of my controllers, or I could do this at my service level. Is there a clear answer to these questions?
pseudo code below:
UserDao
save
update
delete
getById
UserService
private userDao
GetUser
Update
I will use my service level in the BOTH web application and API level.
I could have a way like this:
def GetSomething(userId: Int, locationId: Int, ...): Something = { ... }
or I could do this:
def GetSomething(request: GetSomethingRequest): GetSomethingResponse { ... }
Is this one or the other, or should I mix both?
source
share