소스 검색

feat:库存不足返回中文信息

yangyi 1 개월 전
부모
커밋
3b941c7883
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      server/src/main/java/space/anyi/server/service/impl/TransactionServiceImpl.java

+ 2 - 2
server/src/main/java/space/anyi/server/service/impl/TransactionServiceImpl.java

@@ -30,10 +30,10 @@ public class TransactionServiceImpl extends ServiceImpl<TransactionRecordMapper,
     public TransactionRecord purchase(Integer bookId, Integer buyerId, Integer quantity) {
         Book book = bookService.getById(bookId);
         if (book == null) {
-            throw new RuntimeException("Book not found");
+            throw new RuntimeException("书籍不存在");
         }
         if (book.getStock() < quantity) {
-            throw new RuntimeException("Insufficient stock");
+            throw new RuntimeException("库存不足");
         }
 
         book.setStock(book.getStock() - quantity);