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.system.api.domain.GoodsGroupPurchase;
|
import com.ruoyi.goods.service.IGoodsGroupPurchaseService;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* <p>
|
* 商品团购表 前端控制器
|
* </p>
|
*
|
* @author mitao
|
* @since 2024-05-16
|
*/
|
@Slf4j
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/goods-group-purchase")
|
public class GoodsGroupPurchaseController {
|
|
private final IGoodsGroupPurchaseService goodsGroupPurchaseService;
|
|
@InnerAuth
|
@PostMapping("/getGoodsSeckiGoodsGroupPurchaseOne")
|
@ResponseBody
|
public R<GoodsGroupPurchase> getGoodsSeckiGoodsGroupPurchaseOne(@RequestBody Integer goodsSkuId) {
|
GoodsGroupPurchase GoodsSeckillOne = goodsGroupPurchaseService.getById(goodsSkuId);
|
return R.ok(GoodsSeckillOne);
|
}
|
|
/**
|
* 团购商品开始团购
|
*
|
* @param groupPurchaseId 团购商品id
|
*/
|
@InnerAuth
|
@GetMapping("/start/{groupPurchaseId}")
|
R<?> startGroupPurchase(@PathVariable("groupPurchaseId") Long groupPurchaseId) {
|
try {
|
goodsGroupPurchaseService.startGroupPurchase(groupPurchaseId);
|
} catch (JsonProcessingException e) {
|
log.error("团购商品开始团购失败", e);
|
return R.fail("团购商品开始团购失败");
|
}
|
return R.ok();
|
}
|
|
/**
|
* 团购商品结束团购
|
*
|
* @param groupPurchaseId 团购商品id
|
*/
|
@InnerAuth
|
@GetMapping("/end/{groupPurchaseId}")
|
R<?> endGroupPurchase(@PathVariable("groupPurchaseId") Long groupPurchaseId) {
|
try {
|
goodsGroupPurchaseService.endGroupPurchase(groupPurchaseId);
|
} catch (JsonProcessingException e) {
|
log.error("团购商品开始团购失败", e);
|
return R.fail("团购商品结束团购失败");
|
}
|
return R.ok();
|
}
|
}
|