package com.ruoyi.goods.controller.management;
|
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.utils.page.PageDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsSeckillDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsSeckillQuery;
|
import com.ruoyi.goods.controller.management.dto.GoodsSeckillUpd;
|
import com.ruoyi.goods.controller.management.vo.GoodsSeckillVO;
|
import com.ruoyi.goods.service.IGoodsSeckillService;
|
import com.ruoyi.system.api.domain.dto.ListStatusDTO;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.validation.annotation.Validated;
|
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.PutMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/**
|
* <p>
|
* 商品秒杀表 前端控制器
|
* </p>
|
*
|
* @author mitao
|
* @since 2024-05-16
|
*/
|
@Slf4j
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/mgt/goods-seckill")
|
@Api(value = "管理后台商品秒杀相关接口", tags = {"管理后台接口"})
|
public class MgtGoodsSeckillController {
|
|
private final IGoodsSeckillService goodsSeckillService;
|
|
/**
|
* 获取秒杀商品列表的分页数据
|
*
|
* @param query 秒杀商品查询对象
|
* @return R<PageDTO < GoodsSeckillVO>>
|
*/
|
@ApiOperation(value = "获取秒杀商品列表的分页数据", notes = "获取秒杀商品列表的分页数据")
|
@PostMapping("/page")
|
public R<PageDTO<GoodsSeckillVO>> getGoodsSeckillPage(
|
@Validated @RequestBody GoodsSeckillQuery query) {
|
return R.ok(goodsSeckillService.getGoodsSeckillPage(query));
|
}
|
|
/**
|
* 添加秒杀商品
|
*
|
* @param dto 商品秒杀数据传输对象
|
*/
|
@ApiOperation(value = "添加秒杀商品", notes = "添加秒杀商品")
|
@PostMapping("/add")
|
public R<Void> addGoodsSeckill(@Validated @RequestBody GoodsSeckillDTO dto) {
|
goodsSeckillService.addGoodsSeckill(dto);
|
return R.ok();
|
}
|
|
/**
|
* 修改秒杀商品
|
*
|
* @param upd 商品秒杀数据传输对象
|
*/
|
@ApiOperation(value = "修改秒杀商品", notes = "修改秒杀商品")
|
@PutMapping
|
public R<Void> updGoodsSeckill(@Validated @RequestBody GoodsSeckillUpd upd) {
|
goodsSeckillService.updGoodsSeckill(upd);
|
return R.ok();
|
}
|
|
/**
|
* 上架/下架 秒杀商品
|
*
|
* @param dto 商品上下架状态对象
|
*/
|
@ApiOperation(value = "上架/下架 秒杀商品", notes = "上架/下架 秒杀商品")
|
@PutMapping("/upd-status")
|
public R<Void> updStatus(@Validated @RequestBody ListStatusDTO dto) {
|
goodsSeckillService.updStatus(dto);
|
return R.ok();
|
}
|
|
/**
|
* 查看详情
|
*
|
* @param id 秒杀商品id
|
* @return GoodsSeckillVO 商品秒杀视图对象
|
*/
|
@ApiOperation("查看详情")
|
@GetMapping("/detail/{id}")
|
public R<GoodsSeckillVO> getDetail(@PathVariable("id") Long id) {
|
return R.ok(goodsSeckillService.getDetail(id));
|
}
|
}
|