@Test public void updateBook() { BookDO bookDO = new BookDO(); bookDO.setTitle(title); bookDO.setAuthor(author); bookDO.setImage(image); bookDO.setSummary(summary); bookMapper.insert(bookDO); String newTitle = "tttttttt"; CreateOrUpdateBookDTO validator = new CreateOrUpdateBookDTO(); validator.setAuthor(author); validator.setImage(image); validator.setSummary(summary); validator.setTitle(newTitle); BookDO found = bookMapper.selectById(bookDO.getId()); bookService.updateBook(found, validator); BookDO found1 = bookMapper.selectById(bookDO.getId()); assertEquals(found1.getTitle(), newTitle); }
@Override public boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator) { book.setAuthor(validator.getAuthor()); book.setTitle(validator.getTitle()); book.setImage(validator.getImage()); book.setSummary(validator.getSummary()); return bookMapper.updateById(book) > 0; }
BookServiceImpl implements BookService { @Override public boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator) { book.setAuthor(validator.getAuthor()); book.setTitle(validator.getTitle()); book.setImage(validator.getImage()); book.setSummary(validator.getSummary()); return bookMapper.updateById(book) > 0; } }
BookServiceImpl implements BookService { @Override public boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator) { book.setAuthor(validator.getAuthor()); book.setTitle(validator.getTitle()); book.setImage(validator.getImage()); book.setSummary(validator.getSummary()); return bookMapper.updateById(book) > 0; }  }
BookServiceImpl implements BookService { @Override public boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator) { book.setAuthor(validator.getAuthor()); book.setTitle(validator.getTitle()); book.setImage(validator.getImage()); book.setSummary(validator.getSummary()); return bookMapper.updateById(book) > 0; }  @Override boolean createBook(CreateOrUpdateBookDTO validator); @Override List<BookDO> getBookByKeyword(String q); @Override boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator); @Override BookDO getById(Long id); @Override List<BookDO> findAll(); @Override boolean deleteById(Long id); }
BookServiceImpl implements BookService { @Override public boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator) { book.setAuthor(validator.getAuthor()); book.setTitle(validator.getTitle()); book.setImage(validator.getImage()); book.setSummary(validator.getSummary()); return bookMapper.updateById(book) > 0; }  @Override boolean createBook(CreateOrUpdateBookDTO validator); @Override List<BookDO> getBookByKeyword(String q); @Override boolean updateBook(BookDO book, CreateOrUpdateBookDTO validator); @Override BookDO getById(Long id); @Override List<BookDO> findAll(); @Override boolean deleteById(Long id);  }