-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(product): add product statistics for sales ,view count and inven…
…tory
- Loading branch information
Showing
20 changed files
with
683 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "产品统计" | ||
desc: "产品统计" | ||
author: "MichaelHu" | ||
email: "[email protected]" | ||
version: "v1" | ||
) | ||
|
||
@server( | ||
group: admin/crm/product/productstatistics | ||
prefix: /api/v1/admin/product | ||
middleware: EmployeeJWTAuth | ||
) | ||
|
||
service PowerX { | ||
@doc "查询产品规格列表" | ||
@handler ListProductStatisticsPage | ||
get /product-statistics/page-list (ListProductStatisticsPageRequest) returns (ListProductStatisticsPageReply) | ||
|
||
@doc "查询产品规格详情" | ||
@handler GetProductStatistics | ||
get /product-statistics/:id (GetProductStatisticsRequest) returns (GetProductStatisticsReply) | ||
|
||
|
||
@doc "创建产品规格" | ||
@handler CreateProductStatistics | ||
post /product-statistics (CreateProductStatisticsRequest) returns (CreateProductStatisticsReply) | ||
|
||
@doc "配置产品规格" | ||
@handler ConfigProductStatistics | ||
post /product-statistics/config (ConfigProductStatisticsRequest) returns (ConfigProductStatisticsReply) | ||
|
||
|
||
@doc "全量产品规格" | ||
@handler PutProductStatistics | ||
put /product-statistics/:id (PutProductStatisticsRequest) returns (PutProductStatisticsReply) | ||
|
||
@doc "增量产品规格" | ||
@handler PatchProductStatistics | ||
patch /product-statistics/:id (PatchProductStatisticsRequest) returns (PatchProductStatisticsReply) | ||
|
||
|
||
@doc "删除产品规格" | ||
@handler DeleteProductStatistics | ||
delete /product-statistics/:id (DeleteProductStatisticsRequest) returns (DeleteProductStatisticsReply) | ||
} | ||
|
||
type ( | ||
ProductStatistics { | ||
Id int64 `json:"id,optional"` | ||
ProductId int64 `json:"productId"` | ||
SoldAmount int64 `json:"SoldAmount,optional"` | ||
InventoryQuantity int64 `json:"InventoryQuantity,optional"` | ||
ViewCount int64 `json:"ViewCount,optional"` | ||
} | ||
) | ||
|
||
type ( | ||
ListProductStatisticsPageRequest struct { | ||
LikeName string `form:"likeName,optional"` | ||
ProductId int64 `form:"productId"` | ||
OrderBy string `form:"orderBy,optional"` | ||
PageIndex int `form:"pageIndex,optional"` | ||
PageSize int `form:"pageSize,optional"` | ||
} | ||
|
||
|
||
ListProductStatisticsPageReply struct { | ||
List []*ProductStatistics `json:"list"` | ||
PageIndex int `json:"pageIndex"` | ||
PageSize int `json:"pageSize"` | ||
Total int64 `json:"total"` | ||
} | ||
) | ||
|
||
type ( | ||
CreateProductStatisticsRequest struct { | ||
ProductStatistics | ||
} | ||
|
||
CreateProductStatisticsReply struct { | ||
ProductStatisticsId int64 `json:"id"` | ||
} | ||
) | ||
|
||
type ( | ||
ConfigProductStatisticsRequest struct { | ||
ProductStatisticss []ProductStatistics `json:"productStatisticss"` | ||
} | ||
|
||
ConfigProductStatisticsReply struct { | ||
Result bool `json:"result"` | ||
} | ||
) | ||
|
||
type ( | ||
GetProductStatisticsRequest struct { | ||
ProductStatisticsId int64 `path:"id"` | ||
} | ||
|
||
GetProductStatisticsReply struct { | ||
*ProductStatistics | ||
} | ||
) | ||
|
||
|
||
type ( | ||
PutProductStatisticsRequest struct { | ||
ProductStatisticsId int64 `path:"id"` | ||
ProductStatistics | ||
} | ||
|
||
PutProductStatisticsReply struct { | ||
*ProductStatistics | ||
} | ||
) | ||
|
||
type ( | ||
PatchProductStatisticsRequest struct { | ||
ProductStatisticsId int64 `path:"id"` | ||
ProductStatistics | ||
} | ||
|
||
PatchProductStatisticsReply struct { | ||
*ProductStatistics | ||
} | ||
) | ||
|
||
|
||
type ( | ||
DeleteProductStatisticsRequest struct { | ||
ProductStatisticsId int64 `path:"id"` | ||
} | ||
|
||
DeleteProductStatisticsReply struct { | ||
ProductStatisticsId int64 `json:"id"` | ||
} | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/configproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ConfigProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ConfigProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewConfigProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.ConfigProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/createproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func CreateProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.CreateProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewCreateProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.CreateProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/deleteproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func DeleteProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.DeleteProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewDeleteProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.DeleteProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/getproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func GetProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.GetProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewGetProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.GetProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/listproductstatisticspagehandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ListProductStatisticsPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ListProductStatisticsPageRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewListProductStatisticsPageLogic(r.Context(), svcCtx) | ||
resp, err := l.ListProductStatisticsPage(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/patchproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func PatchProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.PatchProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewPatchProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.PatchProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/crm/product/productstatistics/putproductstatisticshandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/crm/product/productstatistics" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func PutProductStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.PutProductStatisticsRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productstatistics.NewPutProductStatisticsLogic(r.Context(), svcCtx) | ||
resp, err := l.PutProductStatistics(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Oops, something went wrong.