-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加了静态的库存量,销量,浏览量
- Loading branch information
Showing
8 changed files
with
166 additions
and
105 deletions.
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
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/mp/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/mp/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/mp/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/mp/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) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
internal/logic/mp/crm/product/productstatistics/getproductstatisticslogic.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,52 @@ | ||
package productstatistics | ||
|
||
import ( | ||
product2 "PowerX/internal/model/crm/product" | ||
"PowerX/internal/types/errorx" | ||
"context" | ||
|
||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type GetProductStatisticsLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewGetProductStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductStatisticsLogic { | ||
return &GetProductStatisticsLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *GetProductStatisticsLogic) GetProductStatistics(req *types.GetProductStatisticsRequest) (resp *types.GetProductStatisticsReply, err error) { | ||
|
||
statistics, err := l.svcCtx.PowerX.ProductStatistics.GetProductStatisticsByProductId(l.ctx, req.ProductId) | ||
if err != nil { | ||
return nil, errorx.WithCause(err, err.Error()) | ||
} | ||
|
||
return &types.GetProductStatisticsReply{ | ||
ProductStatistics: TransformProductStatisticsToReplyForMP(statistics), | ||
}, nil | ||
} | ||
|
||
func TransformProductStatisticsToReplyForMP(specific *product2.ProductStatistics) (specificReply *types.ProductStatistics) { | ||
if specific == nil { | ||
return nil | ||
} | ||
|
||
return &types.ProductStatistics{ | ||
Id: specific.Id, | ||
ProductId: specific.ProductId, | ||
SoldAmount: specific.BaseSoldAmount + specific.SoldAmount, | ||
InventoryQuantity: specific.BaseInventoryQuantity + specific.InventoryQuantity, | ||
ViewCount: specific.BaseViewCount + specific.ViewCount, | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
internal/logic/mp/crm/product/productstatistics/listproductstatisticspagelogic.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,30 @@ | ||
package productstatistics | ||
|
||
import ( | ||
"context" | ||
|
||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
|
||
"github.com/zeromicro/go-zero/core/logx" | ||
) | ||
|
||
type ListProductStatisticsPageLogic struct { | ||
logx.Logger | ||
ctx context.Context | ||
svcCtx *svc.ServiceContext | ||
} | ||
|
||
func NewListProductStatisticsPageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListProductStatisticsPageLogic { | ||
return &ListProductStatisticsPageLogic{ | ||
Logger: logx.WithContext(ctx), | ||
ctx: ctx, | ||
svcCtx: svcCtx, | ||
} | ||
} | ||
|
||
func (l *ListProductStatisticsPageLogic) ListProductStatisticsPage(req *types.ListProductStatisticsPageRequest) (resp *types.ListProductStatisticsPageReply, err error) { | ||
// todo: add your logic here and delete this line | ||
|
||
return | ||
} |
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