mitao
2024-05-31 fc13d832e58e42e241aa827e930651a28ca357e1
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
package com.ruoyi.goods.controller.inner;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.goods.service.IGoodsSkuService;
import com.ruoyi.system.api.domain.GoodsSku;
import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO;
import java.util.Collection;
import java.util.List;
import javax.annotation.Resource;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-05-16
 */
@RestController
@RequestMapping("/goods-sku")
public class GoodsSkuController {
 
    @Resource
    private IGoodsSkuService iGoodsSkuService;
 
    /**
     * 获取当前商品信息
     *
     */
    @InnerAuth
    @PostMapping("/getGoodsSkuOne")
    @ResponseBody
    public R<GoodsSku> getGoodsSkuOne(@RequestBody Integer goodsSkuId) {
        GoodsSku goodsSkuOne=iGoodsSkuService.getById(goodsSkuId);
        return R.ok(goodsSkuOne);
 
    }
 
    @InnerAuth
    @PostMapping("/updateGoodsSkuOne")
    @ResponseBody
    public R<Boolean> updateGoodsSkuOne(@RequestBody GoodsSku goodsSku) {
        return R.ok(iGoodsSkuService.updateById(goodsSku));
 
    }
 
    /**
     * 根据商品名称查询商品SKU列表。
     *
     * @param goodsSkuName 商品名称
     * @return List<GoodsSku>商品SKU列表
     */
    @InnerAuth
    @GetMapping("/name/{goodsSkuName}")
    R<List<GoodsSku>> getGoodsByName(@PathVariable("goodsSkuName") String goodsSkuName) {
        return R.ok(iGoodsSkuService.getGoodsByName(goodsSkuName));
    }
 
 
    /**
     * 批量更新商品库存 auctionStock 负数则为减库存,正数为加库存
     *
     * @param goodsStockUpdDTOS 商品库存修改数据传输对象
     * @param source            请求来源
     */
    @InnerAuth
    @PutMapping("/upd-stock")
    R<?> updGoodsStock(@RequestBody List<GoodsStockUpdDTO> goodsStockUpdDTOS) {
        iGoodsSkuService.updGoodsStock(goodsStockUpdDTOS);
        return R.ok();
    }
 
    /**
     * 根据商品id集合查询商品
     *
     * @param goodsIdList 商品id集合
     * @param source      请求来源
     * @return 商品集合
     */
    @PostMapping("/list")
    R<List<GoodsSku>> getGoodsListByIds(@RequestBody Collection<Long> goodsIdList) {
        return R.ok(iGoodsSkuService.listByIds(goodsIdList));
    }
}