Search in sources :

Example 1 with AuthorData

use of com.tvd12.ezydata.example.jpa.data.AuthorData in project ezyfox-examples by tvd12.

the class AuthorController method addAuthor.

@DoPost("/add")
public AuthorResponse addAuthor(@RequestBody AddAuthorRequest request) {
    authorValidator.validate(request);
    final AddAuthorData addAuthorData = requestToDataConverter.toData(request);
    final AuthorData authorData = authorService.saveAuthor(addAuthorData);
    return dataToResponseConverter.toResponse(authorData);
}
Also used : AuthorData(com.tvd12.ezydata.example.jpa.data.AuthorData) AddAuthorData(com.tvd12.ezydata.example.jpa.data.AddAuthorData) AddAuthorData(com.tvd12.ezydata.example.jpa.data.AddAuthorData)

Example 2 with AuthorData

use of com.tvd12.ezydata.example.jpa.data.AuthorData in project ezyfox-examples by tvd12.

the class AuthorService method saveAuthor.

public AuthorData saveAuthor(AddAuthorData data) {
    final Author entity = dataToEntityConverter.toEntity(data);
    authorRepository.save(entity);
    return entityToDataConverter.toData(entity);
}
Also used : Author(com.tvd12.ezydata.example.jpa.entity.Author)

Aggregations

AddAuthorData (com.tvd12.ezydata.example.jpa.data.AddAuthorData)1 AuthorData (com.tvd12.ezydata.example.jpa.data.AuthorData)1 Author (com.tvd12.ezydata.example.jpa.entity.Author)1