Skip to content

Commit

Permalink
Update returnBook.java
Browse files Browse the repository at this point in the history
修复归还图书业务同样的问题
  • Loading branch information
cohhi committed Jul 14, 2023
1 parent 0d81da4 commit 39cdf7d
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions jian/src/main/java/com/springboot/jian/controller/returnBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,34 @@ public int returnBook(
@RequestParam String user
) throws IOException {
int result = 0;
boolean bookMessage = false;
boolean userMessage = false;
returnBookMessage returnBookMessage = new returnBookMessage();
selectAllBookMessage selectAllBookMessage = new selectAllBookMessage();
selectAllUserMessage selectAllUserMessage = new selectAllUserMessage();
// 判断图书是否存在
for (int i = 0; i < selectAllBookMessage.selectAllBook().size(); i++) {
if (selectAllBookMessage.selectAllBook().get(i) == book) {
// 判断用户是否存在
for (int j = 0; j < selectAllUserMessage.selectAllUser().size(); j++) {
if (selectAllUserMessage.selectAllUser().get(j) == user) {
result = returnBookMessage.returnBook(book, user);
} else {
result = -2;
}
}
} else {
result = -1;
for (int i = 0; i < com.springboot.jian.service.selectAllBookMessage.selectAllBook().size(); i++) {
if (com.springboot.jian.service.selectAllBookMessage.selectAllBook().get(i).equals(book)) {
bookMessage = true;
break;
}
}
// 判断用户是否存在
for (int j = 0; j < selectAllUserMessage.selectAllUser().size(); j++) {
if (selectAllUserMessage.selectAllUser().get(j).equals(user)) {
result = returnBookMessage.returnBook(book, user);
userMessage = true;
break;
}
}
if (!bookMessage) {
result = -1;
}
if (!userMessage) {
result = -2;
}
if (bookMessage && userMessage) {
result = 1;
}
return result;
}
}

0 comments on commit 39cdf7d

Please sign in to comment.