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.promotion.controller.management;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.promotion.controller.management.dto.MgtPromotionBannerDTO;
import com.ruoyi.promotion.controller.management.dto.MgtPromotionBannerQuery;
import com.ruoyi.promotion.controller.management.dto.MgtPromotionBannerUpdDTO;
import com.ruoyi.promotion.controller.management.vo.MgtPromotionBannerVO;
import com.ruoyi.promotion.service.IPromotionBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
 
/**
 * <p>
 * 轮播图表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-05-16
 */
@RestController
@RequestMapping("/mgt/promotion-banner")
@RequiredArgsConstructor
@Api(value = "管理后台-轮播图管理相关接口", tags = "管理后台-轮播图管理相关接口")
public class MgtPromotionBannerController {
 
    private final IPromotionBannerService promotionBannerService;
 
    /**
     * 获取banner列表分页数据
     *
     * @param query 轮播图列表查询对象
     * @return PageDTO<MgtPromotionBannerVO>
     */
    @ApiOperation("获取轮播图列表分页数据 ")
    @PostMapping("/page")
    public R<PageDTO<MgtPromotionBannerVO>> getBannerPage(
            @Validated @RequestBody MgtPromotionBannerQuery query) {
        return R.ok(promotionBannerService.getBannerPage(query));
    }
 
    /**
     * 添加/编辑轮播图
     *
     * @param dto 轮播图数据传输对象
     */
    @ApiOperation("添加/编辑轮播图")
    @PostMapping("/save")
    public R<?> savePromotionBanner(@Validated @RequestBody MgtPromotionBannerDTO dto) {
        promotionBannerService.savePromotionBanner(dto);
        return R.ok();
    }
 
    /**
     * 删除轮播图
     *
     * @param id 轮播图id
     */
    @ApiOperation("删除轮播图")
    @DeleteMapping("/{id}")
    public R<?> delPromotionBanner(
            @ApiParam(name = "id", value = "轮播图id", required = true) @PathVariable("id") Long id) {
        promotionBannerService.delPromotionBanner(id);
        return R.ok();
    }
 
    /**
     * 查看轮播图详情
     *
     * @param id 轮播图id
     * @return MgtPromotionBannerVO
     */
    @ApiOperation("查看轮播图详情")
    @GetMapping("/detail/{id}")
    public R<MgtPromotionBannerVO> getPromotionBanner(
            @ApiParam(name = "id", value = "轮播图id", required = true) @PathVariable("id") Long id) {
        return R.ok(promotionBannerService.getPromotionBanner(id));
    }
 
    /**
     * 轮播图 上架/下架
     *
     * @param dto 轮播图状态数据传输对象
     */
    @ApiOperation("轮播图 上架/下架")
    @PostMapping("/upd-status")
    public R<?> updStatus(MgtPromotionBannerUpdDTO dto) {
        promotionBannerService.updStatus(dto);
        return R.ok();
    }
}