mitao
2024-11-01 a53a1f481278f981bab8030853b353a823a9cd81
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.ruoyi.promotion.controller.forepart;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.promotion.controller.forepart.dto.ForepartPromotionWishDTO;
import com.ruoyi.promotion.controller.forepart.vo.ForepartPopupVO;
import com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishBulletVO;
import com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishVO;
import com.ruoyi.promotion.service.IPromotionWishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
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-10-29
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/forepart/promotion-wish")
@Api(value = "用户端-心愿求购相关接口", tags = "【09.25】用户端-心愿求购相关接口")
public class ForepartPromotionWishController {
 
    private final IPromotionWishService promotionWishService;
 
    /**
     * 个人中心-获取推荐商品可购买数
     * @return
     */
    @GetMapping("/getRecommendNum")
    @ApiOperation(value = "个人中心-获取推荐商品可购买数")
    public R<Integer> getRecommendNum() {
        return R.ok(promotionWishService.getRecommendNum());
    }
 
    /**
     * 获取首页弹幕数据
     * @return
     */
    @GetMapping("/bulletList")
    @ApiOperation(value = "获取首页弹幕数据", notes = "达成心愿数为数组长度")
    public R<List<ForepartPromotionWishBulletVO>> getBulletList() {
        return R.ok(promotionWishService.getBulletList());
    }
 
    /**
     * 求购历史-达成心愿数
     * @return
     */
    @GetMapping("/getCompletedWishCount")
    @ApiOperation(value = "求购历史-达成心愿数")
    public R<Long> getCompletedWishCount() {
        return R.ok(promotionWishService.getCompletedWishCount());
    }
 
    /**
     * 获取弹窗信息
     * @return
     */
    @GetMapping("/popup")
    @ApiOperation(value = "获取弹窗信息", notes = "获取弹窗信息")
    public R<ForepartPopupVO> getPopup() {
        return R.ok(promotionWishService.getPopup());
    }
 
    /**
     * 求购历史
     * @param page
     * @return
     */
    @PostMapping("/wishHistory")
    @ApiOperation(value = "求购历史")
    public R<PageDTO<ForepartPromotionWishVO>> getWishHistory(@Valid @RequestBody BasePage page) {
        return R.ok(promotionWishService.getWishHistory(page));
    }
 
    /**
     * 发布求购
     * @param dto
     * @return
     */
    @PostMapping("/publish")
    @ApiOperation(value = "发布求购")
    public R<Long> publish(@Valid @RequestBody ForepartPromotionWishDTO dto) {
        return R.ok(promotionWishService.publish(dto));
    }
 
    /**
     * 心愿求购详情
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "心愿求购详情")
    public R<ForepartPromotionWishVO> getDetails(
            @ApiParam(name = "id", value = "心愿求购id", required = true) @NotNull(message = "心愿求购id不能为空") @PathVariable("id") Long id) {
        return R.ok(promotionWishService.getPromotionWishDetails(id));
    }
 
    /**
     * 撤回求购
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    @ApiOperation(value = "撤回心愿求购")
    public R<?> delete(
            @ApiParam(name = "id", value = "心愿求购id", required = true) @NotNull(message = "心愿求购id不能为空") @PathVariable("id") Long id) {
        promotionWishService.deleteById(id);
        return R.ok();
    }
}