From fe2d5b14031edbe43238770fb1fc21e8a322b51a Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期四, 13 六月 2024 18:18:08 +0800
Subject: [PATCH] 用户端商品

---
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsSeckillController.java |   38 +++++++++++++++++++++++++++++---------
 1 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsSeckillController.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsSeckillController.java
index 2b97060..c93b370 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsSeckillController.java
+++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsSeckillController.java
@@ -1,19 +1,17 @@
 package com.ruoyi.goods.controller.inner;
 
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.security.annotation.InnerAuth;
 import com.ruoyi.goods.service.IGoodsSeckillService;
 import com.ruoyi.system.api.domain.GoodsSeckill;
+import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * <p>
@@ -31,12 +29,24 @@
 
     private final IGoodsSeckillService goodsSeckillService;
 
+    @InnerAuth
     @PostMapping("/getGoodsSeckillOne")
     @ResponseBody
     public R<GoodsSeckill> getGoodsSeckillOne(@RequestBody Integer goodsSkuId) {
         GoodsSeckill GoodsSeckillOne = goodsSeckillService.getById(goodsSkuId);
         return R.ok(GoodsSeckillOne);
     }
+
+    @InnerAuth
+    @PutMapping("/updGoodsSeckill")
+    R<?> updGoodsSeckill(@RequestBody GoodsStockUpdDTO goodsStockUpdDTOS) {
+        GoodsSeckill GoodsSeckillOne = goodsSeckillService.getById(goodsStockUpdDTOS);
+        GoodsSeckillOne.setSeckillStock(goodsStockUpdDTOS.getAuctionStock());
+        goodsSeckillService.updateById(GoodsSeckillOne);
+        return R.ok();
+    }
+
+
     /**
      * 开始秒杀
      *
@@ -45,7 +55,12 @@
     @InnerAuth
     @GetMapping("/start/{seckillId}")
     R<?> startSeckill(@PathVariable("seckillId") Long seckillId) {
-        goodsSeckillService.startSeckill(seckillId);
+        try {
+            goodsSeckillService.startSeckill(seckillId);
+        } catch (JsonProcessingException e) {
+            log.error("秒杀开始异常", e);
+            return R.fail();
+        }
         return R.ok();
     }
 
@@ -57,7 +72,12 @@
     @InnerAuth
     @GetMapping("/end/{seckillId}")
     R<?> endSeckill(@PathVariable("seckillId") Long seckillId) {
-        goodsSeckillService.endSeckill(seckillId);
+        try {
+            goodsSeckillService.endSeckill(seckillId);
+        } catch (JsonProcessingException e) {
+            log.error("秒杀结束异常", e);
+            return R.fail();
+        }
         return R.ok();
     }
 

--
Gitblit v1.7.1