puzhibing
2026-03-15 935bf1c8fc878d1927d366603d6afdbb53eaad18
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
package com.xiaopeng.operation.controller;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaopeng.api.model.operation.XpCoupon;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.operation.query.XpCouponListQuery;
import com.xiaopeng.operation.service.IXpCouponService;
import com.xiaopeng.operation.vo.XpBannerListVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import org.springframework.stereotype.Controller;
 
import java.util.List;
 
/**
 * <p>
 * 优惠券管理 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2026-02-03
 */
@RestController
@RequestMapping("")
public class XpCouponController {
 
    private final IXpCouponService xpCouponService;
 
    public XpCouponController(IXpCouponService xpCouponService) {
        this.xpCouponService = xpCouponService;
    }
 
 
    @PostMapping("/inner/xp-coupon/getCouponById")
    public R<XpCoupon> getCouponById(@RequestParam Long couponId){
        XpCoupon xpCoupon = xpCouponService.getById(couponId);
        return R.ok(xpCoupon);
    }
 
 
    /**
     * 优惠券列表
     */
    @PostMapping("/v1/api/xp-coupon/list")
    @ApiOperation(value = "优惠券列表",tags = {"管理后台-优惠券"},response = XpCoupon.class)
    public R<Page<XpCoupon>> list(@RequestBody XpCouponListQuery query ){
        return R.ok(xpCouponService.getList(query));
    }
 
 
 
 
    /**
     *    // 添加优惠券
     * @param xpCoupon
     * @return
     */
    @PostMapping("/v1/api/xp-coupon/add")
    @ApiOperation(value = "添加优惠券",tags = {"管理后台-优惠券"},response = XpCoupon.class)
    public R<?> add(@RequestBody XpCoupon xpCoupon){
        xpCouponService.save(xpCoupon);
        return R.ok();
    }
 
    /**
     * 优惠券详情
     */
    @GetMapping("/v1/api/xp-coupon/queryById")
    @ApiOperation(value = "优惠券详情",tags = {"管理后台-优惠券"},response = XpCoupon.class)
    public R<XpCoupon> queryById(@RequestParam Long id){
        XpCoupon xpCoupon = xpCouponService.getById(id);
        return R.ok(xpCoupon);
    }
 
 
    /**
     * 删除优惠券
     */
    @DeleteMapping("/v1/api/xp-coupon/deleteById")
    @ApiOperation(value = "删除优惠券",tags = {"管理后台-优惠券"},response = XpCoupon.class)
    public R<?> deleteById(@RequestParam Long id){
        xpCouponService.removeById(id);
        return R.ok();
    }
 
}