Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-02-28 13:50:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5e61c77a66c4de3c088ab32408ef9bad390804c4
5e61c77a
1 parent
1eb8acae
菜品售卖量接口
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
159 additions
and
7 deletions
src/main/java/com/infoloop/tianting/controller/SkuController.java
src/main/java/com/infoloop/tianting/enums/SkuSellQuantityStatus.java
src/main/java/com/infoloop/tianting/model/common/Param.java → src/main/java/com/infoloop/tianting/model/common/IdsParam.java
src/main/java/com/infoloop/tianting/model/dto/SkuSellQuantityDTO.java
src/main/java/com/infoloop/tianting/model/vo/SkuSellQuantityStatisticsVO.java
src/main/java/com/infoloop/tianting/model/vo/SkuSellQuantityVO.java
src/main/java/com/infoloop/tianting/utils/PageUtil.java
src/main/java/com/infoloop/tianting/controller/SkuController.java
View file @
5e61c77
package
com
.
infoloop
.
tianting
.
controller
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.common.IdsParam
;
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
com.infoloop.tianting.utils.PageUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -11,12 +17,16 @@ 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.Collections
;
import
java.util.List
;
@Api
(
tags
=
"sku"
)
...
...
@@ -35,4 +45,36 @@ public class SkuController {
public
List
<
SkuDto
>
getOrderByCustomerId
(
@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
SkuSellQuantityStatisticsVO
.
builder
().
build
();
}
@ApiOperation
(
value
=
"分页查询菜品售卖量"
)
@PostMapping
(
"/stall/{stallId}/skusellquantities/query"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
PageResult
<
SkuSellQuantityVO
>
querySkuSellQuantity
(
@PathVariable
(
"stallId"
)
int
stallId
,
@Valid
@RequestBody
SkuSellQuantityDTO
.
QuerySkuSellQuantityDTO
querySkuSellQuantityDTO
)
{
SkuSellQuantityVO
skuSellQuantityVO
=
SkuSellQuantityVO
.
builder
().
build
();
return
PageUtil
.
buildEmpty
(
skuSellQuantityVO
);
}
@ApiOperation
(
value
=
"批量设置菜品售卖量"
)
@PutMapping
(
"/stall/{stallId}/skusellquantities/batchset"
)
@ResponseStatus
(
HttpStatus
.
CREATED
)
public
void
batchSetSkuSellQuantity
(
@PathVariable
(
"stallId"
)
int
stallId
,
@Valid
@RequestBody
SkuSellQuantityDTO
.
BatchSetSkuSellQuantityDTO
batchSetSkuSellQuantityDTO
)
{
}
@ApiOperation
(
value
=
"根据菜品ids批量查询菜品售卖量"
)
@PostMapping
(
"/stall/{stallId}/skusellquantities/querybyskuids"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
SkuSellQuantityVO
>
querySkuSellQuantityBySkuIds
(
@PathVariable
(
"stallId"
)
int
stallId
,
@Valid
@RequestBody
IdsParam
param
)
{
return
Collections
.
emptyList
();
}
}
...
...
src/main/java/com/infoloop/tianting/enums/SkuSellQuantityStatus.java
0 → 100644
View file @
5e61c77
package
com
.
infoloop
.
tianting
.
enums
;
public
enum
SkuSellQuantityStatus
{
ALL
,
SOLD_OUT
,
ON_SALE
}
src/main/java/com/infoloop/tianting/model/common/Param.java
→
src/main/java/com/infoloop/tianting/model/common/
Ids
Param.java
View file @
5e61c77
...
...
@@ -3,19 +3,16 @@ package com.infoloop.tianting.model.common;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Singular
;
import
javax.validation.constraints.NotEmpty
;
import
java.util.List
;
@Data
@ApiModel
(
description
=
"公共参数"
)
public
class
Param
{
public
class
Ids
Param
{
@ApiModelProperty
(
value
=
"ids"
)
@
Singular
(
"id
"
)
@
NotEmpty
(
message
=
"ids不能为空
"
)
private
List
<
Integer
>
ids
;
@ApiModelProperty
(
value
=
"keyword"
)
private
String
keyword
;
}
...
...
src/main/java/com/infoloop/tianting/model/dto/SkuSellQuantityDTO.java
0 → 100644
View file @
5e61c77
package
com
.
infoloop
.
tianting
.
model
.
dto
;
import
com.infoloop.tianting.enums.SkuSellQuantityStatus
;
import
com.infoloop.tianting.model.common.PageInfo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
@Data
@ApiModel
(
description
=
"SkuSellQuantityDTO"
)
public
class
SkuSellQuantityDTO
{
@Data
@ApiModel
(
description
=
"批量设置菜品售卖量"
)
public
static
class
BatchSetSkuSellQuantityDTO
{
@ApiModelProperty
(
"菜品 Ids"
)
@NotEmpty
private
List
<
Integer
>
skuIds
;
@ApiModelProperty
(
"最大售卖数量"
)
@NotNull
private
Integer
maxSellQuantity
;
}
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@ApiModel
(
description
=
"分页查询菜品售卖量"
)
public
static
class
QuerySkuSellQuantityDTO
extends
PageInfo
{
@ApiModelProperty
(
"菜品售卖状态"
)
@NotNull
private
SkuSellQuantityStatus
status
;
}
}
src/main/java/com/infoloop/tianting/model/vo/SkuSellQuantityStatisticsVO.java
0 → 100644
View file @
5e61c77
package
com
.
infoloop
.
tianting
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
@Data
@ApiModel
@Builder
public
class
SkuSellQuantityStatisticsVO
{
@ApiModelProperty
(
"全部"
)
private
Long
total
;
@ApiModelProperty
(
"售罄"
)
private
Long
soldOut
;
@ApiModelProperty
(
"在售"
)
private
Long
onSale
;
}
src/main/java/com/infoloop/tianting/model/vo/SkuSellQuantityVO.java
0 → 100644
View file @
5e61c77
package
com
.
infoloop
.
tianting
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
@Data
@ApiModel
@Builder
public
class
SkuSellQuantityVO
{
@ApiModelProperty
(
"菜品Id"
)
private
Integer
skuId
;
@ApiModelProperty
(
"菜品名称"
)
private
String
skuName
;
@ApiModelProperty
(
"菜品编号"
)
private
String
skuCode
;
@ApiModelProperty
(
"最大售卖数量"
)
private
int
maxSellQuantity
;
@ApiModelProperty
(
"今日售卖数量"
)
private
int
todaySellQuantity
;
@ApiModelProperty
(
"是否售罄"
)
private
Boolean
soldOut
;
}
src/main/java/com/infoloop/tianting/utils/PageUtil.java
View file @
5e61c77
...
...
@@ -2,13 +2,23 @@ package com.infoloop.tianting.utils;
import
com.infoloop.tianting.model.common.OrderPageResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
PageUtil
{
public
static
<
T
>
PageResult
<
T
>
buildEmpty
(
T
t
)
{
PageResult
<
T
>
pageRet
=
new
PageResult
<>();
pageRet
.
setTotalCount
(
0
);
pageRet
.
setDataList
(
List
.
of
(
t
));
pageRet
.
setPageNo
(
0
);
pageRet
.
setPageSize
(
0
);
pageRet
.
setTotalPage
(
0
);
return
pageRet
;
}
/**
* 自定义分页
*/
...
...
Please
register
or
login
to post a comment