diff --git a/server/product/internal/handler/homepagerecommandproductlisthandler.go b/server/product/internal/handler/homepagerecommendproductlisthandler.go similarity index 90% rename from server/product/internal/handler/homepagerecommandproductlisthandler.go rename to server/product/internal/handler/homepagerecommendproductlisthandler.go index 448711d0..6187d025 100644 --- a/server/product/internal/handler/homepagerecommandproductlisthandler.go +++ b/server/product/internal/handler/homepagerecommendproductlisthandler.go @@ -13,7 +13,7 @@ import ( "fusenapi/server/product/internal/svc" ) -func HomePageRecommandProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { +func HomePageRecommendProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var ( @@ -51,7 +51,7 @@ func HomePageRecommandProductListHandler(svcCtx *svc.ServiceContext) http.Handle userinfo = &auth.UserInfo{UserId: 0, GuestId: 0} } - var req types.HomePageRecommandProductListReq + var req types.HomePageRecommendProductListReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { httpx.OkJsonCtx(r.Context(), w, &basic.Response{ @@ -62,8 +62,8 @@ func HomePageRecommandProductListHandler(svcCtx *svc.ServiceContext) http.Handle return } // 创建一个业务逻辑层实例 - l := logic.NewHomePageRecommandProductListLogic(r.Context(), svcCtx) - resp := l.HomePageRecommandProductList(&req, userinfo) + l := logic.NewHomePageRecommendProductListLogic(r.Context(), svcCtx) + resp := l.HomePageRecommendProductList(&req, userinfo) // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; if resp != nil { httpx.OkJsonCtx(r.Context(), w, resp) diff --git a/server/product/internal/handler/routes.go b/server/product/internal/handler/routes.go index fc5640a7..0a73ed56 100644 --- a/server/product/internal/handler/routes.go +++ b/server/product/internal/handler/routes.go @@ -109,8 +109,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { }, { Method: http.MethodGet, - Path: "/api/product/home_page_recommand", - Handler: HomePageRecommandProductListHandler(serverCtx), + Path: "/api/product/home_page_recommend", + Handler: HomePageRecommendProductListHandler(serverCtx), }, }, ) diff --git a/server/product/internal/logic/homepagerecommandproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go similarity index 92% rename from server/product/internal/logic/homepagerecommandproductlistlogic.go rename to server/product/internal/logic/homepagerecommendproductlistlogic.go index c90c4aff..fdbd0240 100644 --- a/server/product/internal/logic/homepagerecommandproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -20,21 +20,21 @@ import ( "github.com/zeromicro/go-zero/core/logx" ) -type HomePageRecommandProductListLogic struct { +type HomePageRecommendProductListLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } -func NewHomePageRecommandProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomePageRecommandProductListLogic { - return &HomePageRecommandProductListLogic{ +func NewHomePageRecommendProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomePageRecommendProductListLogic { + return &HomePageRecommendProductListLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } -func (l *HomePageRecommandProductListLogic) HomePageRecommandProductList(req *types.HomePageRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { +func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *types.HomePageRecommendProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { //查询用户信息(不用判断存在) user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { @@ -126,7 +126,7 @@ func (l *HomePageRecommandProductListLogic) HomePageRecommandProductList(req *ty mapProductSizeCount[v.ProductId] = v.Num } //组装返回 - listRsp := make([]types.HomePageRecommandProductListRsp, 0, len(recommendProductList)) + listRsp := make([]types.HomePageRecommendProductListRsp, 0, len(recommendProductList)) for _, productInfo := range recommendProductList { minPrice, ok := mapProductMinPrice[productInfo.Id] _, tmpOk := mapProductTemplate[productInfo.Id] @@ -143,7 +143,7 @@ func (l *HomePageRecommandProductListLogic) HomePageRecommandProductList(req *ty if _, ok = mapProductHaveOptionFitting[productInfo.Id]; ok { haveOptionalFitting = true } - item := types.HomePageRecommandProductListRsp{ + item := types.HomePageRecommendProductListRsp{ ProductId: productInfo.Id, Sn: *productInfo.Sn, Title: *productInfo.Title, diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 75f07e6c..fa3386d6 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -378,11 +378,11 @@ type GetLastProductDesignRsp struct { Info interface{} `json:"info"` } -type HomePageRecommandProductListReq struct { +type HomePageRecommendProductListReq struct { Size uint32 `form:"size"` } -type HomePageRecommandProductListRsp struct { +type HomePageRecommendProductListRsp struct { ProductId int64 `json:"product_id"` Sn string `json:"sn"` Title string `json:"title"` diff --git a/server_api/product.api b/server_api/product.api index dc6beb8a..23929596 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -69,8 +69,8 @@ service product { @handler GetRecommandProductListHandler get /api/product/recommand (GetRecommandProductListReq) returns (response); //获取列表页推荐产品列表 - @handler HomePageRecommandProductListHandler - get /api/product/home_page_recommand (HomePageRecommandProductListReq) returns (response); + @handler HomePageRecommendProductListHandler + get /api/product/home_page_recommend (HomePageRecommendProductListReq) returns (response); //*********************产品详情分解接口结束*********************** //*********************推荐产品接口开始×××××××××××××××××××××××××× @@ -422,10 +422,10 @@ type GetLastProductDesignRsp { Info interface{} `json:"info"` } //获取列表页推荐产品(返回是这个维度数组) -type HomePageRecommandProductListReq { +type HomePageRecommendProductListReq { Size uint32 `form:"size"` } -type HomePageRecommandProductListRsp { +type HomePageRecommendProductListRsp { ProductId int64 `json:"product_id"` Sn string `json:"sn"` Title string `json:"title"`