mitao
2024-05-24 c7a3b2836d11492549501e23b66ab5d1cabb1d14
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/GoodsSeckillController.java
@@ -1,9 +1,13 @@
package com.ruoyi.goods.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
@@ -13,8 +17,42 @@
 * @author mitao
 * @since 2024-05-16
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/goods-seckill")
public class GoodsSeckillController {
    private final IGoodsSeckillService goodsSeckillService;
    @PostMapping("/getGoodsSeckillOne")
    @ResponseBody
    public R<GoodsSeckill> getGoodsSeckillOne(@RequestBody Integer goodsSkuId) {
        GoodsSeckill GoodsSeckillOne = goodsSeckillService.getById(goodsSkuId);
        return R.ok(GoodsSeckillOne);
    }
    /**
     * 开始秒杀
     *
     * @param seckillId 秒杀id
     */
    @InnerAuth
    @GetMapping("/start/{seckillId}")
    R<?> startSeckill(@PathVariable("seckillId") Long seckillId) {
        goodsSeckillService.startSeckill(seckillId);
        return R.ok();
    }
    /**
     * 结束秒杀
     *
     * @param seckillId 秒杀id
     */
    @InnerAuth
    @GetMapping("/end/{seckillId}")
    R<?> endSeckill(@PathVariable("seckillId") Long seckillId) {
        goodsSeckillService.endSeckill(seckillId);
        return R.ok();
    }
}