浏览代码

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