v0: 能正常实现借书的操作
/**
* 借书
* @param bookDTO
* @return
*/
@Override
@Transactional
public boolean borrow(BookDTO bookDTO) {
Book book = bookMapper.getBookById(bookDTO.getBookId());
if (book.getNumber()-book.getStatus() > 0){
if (book.getNumber()-book.getStatus() >= bookDTO.getNumber()){
bookMapper.addStatus(bookDTO);
BookUser history = bookMapper.getHistory(bookDTO);
if (history != null){
bookDTO.setId(history.getId());
bookMapper.borrowHistory(bookDTO);
}else{
bookMapper.saveHistory(bookDTO);
}
return true;
}else{
return false;
}
}
return false;
}
大约 2 分钟