SkuController.java
3.3 KB
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
package com.infoloop.tianting.controller;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.model.common.PageResult;
import com.infoloop.tianting.model.dto.SkuDbDTO.SkuDto;
import com.infoloop.tianting.model.dto.SkuDbDTO.SkuIdsDto;
import com.infoloop.tianting.model.dto.SkuSellQuantityDTO;
import com.infoloop.tianting.model.vo.SkuSellQuantityStatisticsVO;
import com.infoloop.tianting.model.vo.SkuSellQuantityVO;
import com.infoloop.tianting.service.SkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
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.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
@Api(tags = "sku")
@ApiSupport(order = 2)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SkuController {
private final SkuService skuService;
@ApiOperation(value = "根据sku ids获取")
@PostMapping("/skus")
@ResponseStatus(HttpStatus.OK)
public List<SkuDto> getSkusByIds(@Valid @RequestBody SkuIdsDto skuIdsDto) {
return skuService.getSkusByIds(skuIdsDto.getIds());
}
@ApiOperation(value = "获取菜品售卖量统计")
@GetMapping("/stall/{stallId}/skusellquantities/statistics")
@ResponseStatus(HttpStatus.OK)
public SkuSellQuantityStatisticsVO querySkuSellQuantityStatistics(@PathVariable("stallId") int stallId) {
return skuService.querySkuSellQuantityStatistics(stallId);
}
@ApiOperation(value = "分页查询菜品售卖量")
@PostMapping("/skusellquantities/query")
@ResponseStatus(HttpStatus.OK)
public PageResult<SkuSellQuantityVO> querySkuSellQuantity(@Valid @RequestBody SkuSellQuantityDTO.QuerySkuSellQuantityDTO querySkuSellQuantityDTO) {
return skuService.querySkuSellQuantity(querySkuSellQuantityDTO);
}
@ApiOperation(value = "批量设置菜品售卖量")
@PutMapping("/stall/{stallId}/skusellquantities/batchset")
@ResponseStatus(HttpStatus.CREATED)
public boolean batchSetSkuSellQuantity(@PathVariable("stallId") int stallId,
@Valid @RequestBody SkuSellQuantityDTO.BatchSetSkuSellQuantityDTO batchSetSkuSellQuantityDTO) {
return skuService.batchSetSkuSellQuantity(stallId, batchSetSkuSellQuantityDTO);
}
@ApiOperation(value = "根据菜品ids批量查询菜品售卖量")
@PostMapping("/skusellquantities/querybyskuids")
@ResponseStatus(HttpStatus.OK)
public List<SkuSellQuantityVO> querySkuSellQuantityBySkuIds(@Valid @RequestBody SkuSellQuantityDTO.QuerySkuSellQuantityBySkuIdsDTO querySkuSellQuantityBySkuIdsDTO) {
return skuService.querySkuSellQuantityBySkuIds(querySkuSellQuantityBySkuIdsDTO);
}
}