Skip to content

Commit

Permalink
feat(product): add product statistics for sales ,view count and inven…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
Matrix-X committed Oct 7, 2023
1 parent 73710b4 commit b8a17b9
Show file tree
Hide file tree
Showing 20 changed files with 683 additions and 1 deletion.
142 changes: 142 additions & 0 deletions api/admin/crm/product/productstatistics.api
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"`
}
)


1 change: 1 addition & 0 deletions api/mp/product/productcategory.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info(
)

import "../../admin/crm/product/productcategory.api"
import "../../admin/crm/product/productstatistics.api"

@server(
group: mp/product
Expand Down
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)
}
}
}
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)
}
}
}
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)
}
}
}
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)
}
}
}
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)
}
}
}
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)
}
}
}
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)
}
}
}
Loading

0 comments on commit b8a17b9

Please sign in to comment.