Ver código fonte

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

yangyi 1 mês atrás
pai
commit
3b941c7883

+ 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);