zhuyifan

菜品售卖量接口

1 package com.infoloop.tianting.controller; 1 package com.infoloop.tianting.controller;
2 2
3 import com.github.xiaoymin.knife4j.annotations.ApiSupport; 3 import com.github.xiaoymin.knife4j.annotations.ApiSupport;
4 +import com.infoloop.tianting.model.common.IdsParam;
5 +import com.infoloop.tianting.model.common.PageResult;
4 import com.infoloop.tianting.model.dto.SkuDbDTO.SkuDto; 6 import com.infoloop.tianting.model.dto.SkuDbDTO.SkuDto;
5 import com.infoloop.tianting.model.dto.SkuDbDTO.SkuIdsDto; 7 import com.infoloop.tianting.model.dto.SkuDbDTO.SkuIdsDto;
8 +import com.infoloop.tianting.model.dto.SkuSellQuantityDTO;
9 +import com.infoloop.tianting.model.vo.SkuSellQuantityStatisticsVO;
10 +import com.infoloop.tianting.model.vo.SkuSellQuantityVO;
6 import com.infoloop.tianting.service.SkuService; 11 import com.infoloop.tianting.service.SkuService;
12 +import com.infoloop.tianting.utils.PageUtil;
7 import io.swagger.annotations.Api; 13 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiOperation; 14 import io.swagger.annotations.ApiOperation;
9 import lombok.RequiredArgsConstructor; 15 import lombok.RequiredArgsConstructor;
...@@ -11,12 +17,16 @@ import lombok.extern.slf4j.Slf4j; ...@@ -11,12 +17,16 @@ import lombok.extern.slf4j.Slf4j;
11 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.http.HttpStatus; 18 import org.springframework.http.HttpStatus;
13 import org.springframework.validation.annotation.Validated; 19 import org.springframework.validation.annotation.Validated;
20 +import org.springframework.web.bind.annotation.GetMapping;
21 +import org.springframework.web.bind.annotation.PathVariable;
14 import org.springframework.web.bind.annotation.PostMapping; 22 import org.springframework.web.bind.annotation.PostMapping;
23 +import org.springframework.web.bind.annotation.PutMapping;
15 import org.springframework.web.bind.annotation.RequestBody; 24 import org.springframework.web.bind.annotation.RequestBody;
16 import org.springframework.web.bind.annotation.ResponseStatus; 25 import org.springframework.web.bind.annotation.ResponseStatus;
17 import org.springframework.web.bind.annotation.RestController; 26 import org.springframework.web.bind.annotation.RestController;
18 27
19 import javax.validation.Valid; 28 import javax.validation.Valid;
29 +import java.util.Collections;
20 import java.util.List; 30 import java.util.List;
21 31
22 @Api(tags = "sku") 32 @Api(tags = "sku")
...@@ -35,4 +45,36 @@ public class SkuController { ...@@ -35,4 +45,36 @@ public class SkuController {
35 public List<SkuDto> getOrderByCustomerId(@Valid @RequestBody SkuIdsDto skuIdsDto) { 45 public List<SkuDto> getOrderByCustomerId(@Valid @RequestBody SkuIdsDto skuIdsDto) {
36 return skuService.getSkusByIds(skuIdsDto.getIds()); 46 return skuService.getSkusByIds(skuIdsDto.getIds());
37 } 47 }
48 +
49 + @ApiOperation(value = "获取菜品售卖量统计")
50 + @GetMapping("/stall/{stallId}/skusellquantities/statistics")
51 + @ResponseStatus(HttpStatus.OK)
52 + public SkuSellQuantityStatisticsVO querySkuSellQuantityStatistics(@PathVariable("stallId") int stallId) {
53 + return SkuSellQuantityStatisticsVO.builder().build();
54 + }
55 +
56 + @ApiOperation(value = "分页查询菜品售卖量")
57 + @PostMapping("/stall/{stallId}/skusellquantities/query")
58 + @ResponseStatus(HttpStatus.OK)
59 + public PageResult<SkuSellQuantityVO> querySkuSellQuantity(@PathVariable("stallId") int stallId,
60 + @Valid @RequestBody SkuSellQuantityDTO.QuerySkuSellQuantityDTO querySkuSellQuantityDTO) {
61 + SkuSellQuantityVO skuSellQuantityVO = SkuSellQuantityVO.builder().build();
62 + return PageUtil.buildEmpty(skuSellQuantityVO);
63 + }
64 +
65 + @ApiOperation(value = "批量设置菜品售卖量")
66 + @PutMapping("/stall/{stallId}/skusellquantities/batchset")
67 + @ResponseStatus(HttpStatus.CREATED)
68 + public void batchSetSkuSellQuantity(@PathVariable("stallId") int stallId,
69 + @Valid @RequestBody SkuSellQuantityDTO.BatchSetSkuSellQuantityDTO batchSetSkuSellQuantityDTO) {
70 +
71 + }
72 +
73 + @ApiOperation(value = "根据菜品ids批量查询菜品售卖量")
74 + @PostMapping("/stall/{stallId}/skusellquantities/querybyskuids")
75 + @ResponseStatus(HttpStatus.OK)
76 + public List<SkuSellQuantityVO> querySkuSellQuantityBySkuIds(@PathVariable("stallId") int stallId,
77 + @Valid @RequestBody IdsParam param) {
78 + return Collections.emptyList();
79 + }
38 } 80 }
......
1 +package com.infoloop.tianting.enums;
2 +
3 +public enum SkuSellQuantityStatus {
4 +
5 + ALL,
6 + SOLD_OUT,
7 + ON_SALE
8 +}
...@@ -3,19 +3,16 @@ package com.infoloop.tianting.model.common; ...@@ -3,19 +3,16 @@ package com.infoloop.tianting.model.common;
3 import io.swagger.annotations.ApiModel; 3 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty; 4 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 5 import lombok.Data;
6 -import lombok.Singular;
7 6
7 +import javax.validation.constraints.NotEmpty;
8 import java.util.List; 8 import java.util.List;
9 9
10 @Data 10 @Data
11 @ApiModel(description = "公共参数") 11 @ApiModel(description = "公共参数")
12 -public class Param { 12 +public class IdsParam {
13 13
14 @ApiModelProperty(value = "ids") 14 @ApiModelProperty(value = "ids")
15 - @Singular("id") 15 + @NotEmpty(message = "ids不能为空")
16 private List<Integer> ids; 16 private List<Integer> ids;
17 17
18 - @ApiModelProperty(value = "keyword")
19 - private String keyword;
20 -
21 } 18 }
......
1 +package com.infoloop.tianting.model.dto;
2 +
3 +import com.infoloop.tianting.enums.SkuSellQuantityStatus;
4 +import com.infoloop.tianting.model.common.PageInfo;
5 +import io.swagger.annotations.ApiModel;
6 +import io.swagger.annotations.ApiModelProperty;
7 +import lombok.Data;
8 +import lombok.EqualsAndHashCode;
9 +
10 +import javax.validation.constraints.NotEmpty;
11 +import javax.validation.constraints.NotNull;
12 +import java.util.List;
13 +
14 +@Data
15 +@ApiModel(description = "SkuSellQuantityDTO")
16 +public class SkuSellQuantityDTO {
17 +
18 + @Data
19 + @ApiModel(description = "批量设置菜品售卖量")
20 + public static class BatchSetSkuSellQuantityDTO {
21 +
22 + @ApiModelProperty("菜品 Ids")
23 + @NotEmpty
24 + private List<Integer> skuIds;
25 +
26 + @ApiModelProperty("最大售卖数量")
27 + @NotNull
28 + private Integer maxSellQuantity;
29 + }
30 +
31 +
32 + @EqualsAndHashCode(callSuper = true)
33 + @Data
34 + @ApiModel(description = "分页查询菜品售卖量")
35 + public static class QuerySkuSellQuantityDTO extends PageInfo {
36 +
37 + @ApiModelProperty("菜品售卖状态")
38 + @NotNull
39 + private SkuSellQuantityStatus status;
40 + }
41 +
42 +}
1 +package com.infoloop.tianting.model.vo;
2 +
3 +import io.swagger.annotations.ApiModel;
4 +import io.swagger.annotations.ApiModelProperty;
5 +import lombok.Builder;
6 +import lombok.Data;
7 +
8 +@Data
9 +@ApiModel
10 +@Builder
11 +public class SkuSellQuantityStatisticsVO {
12 +
13 + @ApiModelProperty("全部")
14 + private Long total;
15 +
16 + @ApiModelProperty("售罄")
17 + private Long soldOut;
18 +
19 + @ApiModelProperty("在售")
20 + private Long onSale;
21 +}
1 +package com.infoloop.tianting.model.vo;
2 +
3 +import io.swagger.annotations.ApiModel;
4 +import io.swagger.annotations.ApiModelProperty;
5 +import lombok.Builder;
6 +import lombok.Data;
7 +
8 +
9 +@Data
10 +@ApiModel
11 +@Builder
12 +public class SkuSellQuantityVO {
13 +
14 + @ApiModelProperty("菜品Id")
15 + private Integer skuId;
16 +
17 + @ApiModelProperty("菜品名称")
18 + private String skuName;
19 +
20 + @ApiModelProperty("菜品编号")
21 + private String skuCode;
22 +
23 + @ApiModelProperty("最大售卖数量")
24 + private int maxSellQuantity;
25 +
26 + @ApiModelProperty("今日售卖数量")
27 + private int todaySellQuantity;
28 +
29 + @ApiModelProperty("是否售罄")
30 + private Boolean soldOut;
31 +
32 +}
...@@ -2,13 +2,23 @@ package com.infoloop.tianting.utils; ...@@ -2,13 +2,23 @@ package com.infoloop.tianting.utils;
2 2
3 import com.infoloop.tianting.model.common.OrderPageResult; 3 import com.infoloop.tianting.model.common.OrderPageResult;
4 import com.infoloop.tianting.model.common.PageResult; 4 import com.infoloop.tianting.model.common.PageResult;
5 -
6 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; 5 import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto;
6 +
7 import java.util.LinkedList; 7 import java.util.LinkedList;
8 import java.util.List; 8 import java.util.List;
9 9
10 public class PageUtil { 10 public class PageUtil {
11 11
12 + public static <T> PageResult<T> buildEmpty(T t) {
13 + PageResult<T> pageRet = new PageResult<>();
14 + pageRet.setTotalCount(0);
15 + pageRet.setDataList(List.of(t));
16 + pageRet.setPageNo(0);
17 + pageRet.setPageSize(0);
18 + pageRet.setTotalPage(0);
19 + return pageRet;
20 + }
21 +
12 /** 22 /**
13 * 自定义分页 23 * 自定义分页
14 */ 24 */
......