Skip to content

Conversation

@victortwin
Copy link
Owner

No description provided.


@Override
public boolean save(SchoolBook book) {
if (book != null) {
Copy link

@IliaIsakhin IliaIsakhin Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (book == null) {
    return false;
}

import com.epam.izh.rd.online.entity.SchoolBook;
import com.epam.izh.rd.online.repository.BookRepository;

public class SimpleSchoolBookService implements BookService {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implements BookService<SchoolBook>, сейчас у тебя репозиторий работает с абстрактными книгами

public boolean save(Book book) {
SchoolBook schoolBook = (SchoolBook) book;

if (authorService.findByFullName(schoolBook.getAuthorName(), schoolBook.getAuthorLastName()) != null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такое authorService.findByFullName(schoolBook.getAuthorName(), schoolBook.getAuthorLastName()) лучше в переменную выносить для читаемости

private BookRepository<SchoolBook> schoolBookBookRepository;
private AuthorService authorService;

public SimpleSchoolBookService() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А какой смысл в этом конструкторе?

import com.epam.izh.rd.online.entity.Author;
import com.epam.izh.rd.online.repository.AuthorRepository;

public class SimpleAuthorService implements AuthorService {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы прикрутил какую-нибудь валидацию, например на save Author != null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants