rentaiming
2024-05-27 43c263df4d8ce0cc830f287780c29db8a2b47f0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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));
    }
}