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
package com.ruoyi.promotion.controller.inner;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.promotion.service.IPromotionWishRecommendService;
import com.ruoyi.system.api.domain.PromotionWishRecommend;
import lombok.RequiredArgsConstructor;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 * 心愿求购平台推荐商品 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-10-29
 */
@RestController
@RequestMapping("/inner/promotion-wish-recommend")
@RequiredArgsConstructor
public class PromotionWishRecommendController {
 
    private final IPromotionWishRecommendService promotionWishRecommendService;
 
    /**
     *
     * @param id
     * @return
     */
    @InnerAuth
    @GetMapping("/{id}")
    public R<PromotionWishRecommend> getById(@PathVariable("id") Long id) {
        return R.ok(promotionWishRecommendService.getById(id));
    }
 
    /**
     * 扣减推荐商品库存
     * @param goodsQuantity
     * @param id
     * @return
     */
    @InnerAuth
    @PostMapping("/subAvailableNum")
    R<Integer> subRecommendAvailableNum(@RequestParam("goodsQuantity") Integer goodsQuantity,
            @RequestParam("id") Long id) {
        return R.ok(promotionWishRecommendService.subRecommendAvailableNum(goodsQuantity, id));
    }
 
    /**
     * 恢复荐商品可购数量
     * @param goodsQuantity
     * @param id
     * @return
     */
    @InnerAuth
    @PostMapping("/addAvailableNum")
    R<?> addRecommendAvailableNum(@RequestParam("goodsQuantity") Integer goodsQuantity,
            @RequestParam("id") Long id) {
        promotionWishRecommendService.addRecommendAvailableNum(goodsQuantity, id);
        return R.ok();
    }
}