Search in sources :

Example 1 with AddAuthorData

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

the class DataToEntityConverter method toEntity.

public Author toEntity(AddAuthorData data) {
    final Author entity = new Author();
    entity.setName(data.getAuthorName());
    entity.setCreatedTime(LocalDateTime.now());
    entity.setUpdatedTime(LocalDateTime.now());
    return entity;
}
Also used : Author(com.tvd12.ezydata.example.jpa.entity.Author)

Example 2 with AddAuthorData

use of com.tvd12.ezydata.example.jpa.data.AddAuthorData 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 3 with AddAuthorData

use of com.tvd12.ezydata.example.jpa.data.AddAuthorData 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

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