diff --git a/server/product/internal/handler/getrecommandproductlisthandler.go b/server/product/internal/handler/getrecommendproductlisthandler.go similarity index 71% rename from server/product/internal/handler/getrecommandproductlisthandler.go rename to server/product/internal/handler/getrecommendproductlisthandler.go index 332ece32..cb4218c2 100644 --- a/server/product/internal/handler/getrecommandproductlisthandler.go +++ b/server/product/internal/handler/getrecommendproductlisthandler.go @@ -11,22 +11,22 @@ import ( "fusenapi/server/product/internal/types" ) -func GetRecommandProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { +func GetRecommendProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req types.GetRecommandProductListReq + var req types.GetRecommendProductListReq userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } // 创建一个业务逻辑层实例 - l := logic.NewGetRecommandProductListLogic(r.Context(), svcCtx) + l := logic.NewGetRecommendProductListLogic(r.Context(), svcCtx) rl := reflect.ValueOf(l) basic.BeforeLogic(w, r, rl) - resp := l.GetRecommandProductList(&req, userinfo) + resp := l.GetRecommendProductList(&req, userinfo) if !basic.AfterLogic(w, r, rl, resp) { basic.NormalAfterLogic(w, r, resp) diff --git a/server/product/internal/handler/routes.go b/server/product/internal/handler/routes.go index c3ab280e..1a693b8c 100644 --- a/server/product/internal/handler/routes.go +++ b/server/product/internal/handler/routes.go @@ -60,7 +60,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { { Method: http.MethodGet, Path: "/api/product/recommand", - Handler: GetRecommandProductListHandler(serverCtx), + Handler: GetRecommendProductListHandler(serverCtx), }, { Method: http.MethodGet, diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommendproductlistlogic.go similarity index 93% rename from server/product/internal/logic/getrecommandproductlistlogic.go rename to server/product/internal/logic/getrecommendproductlistlogic.go index 319a9d97..41bb291f 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommendproductlistlogic.go @@ -20,21 +20,21 @@ import ( "github.com/zeromicro/go-zero/core/logx" ) -type GetRecommandProductListLogic struct { +type GetRecommendProductListLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } -func NewGetRecommandProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRecommandProductListLogic { - return &GetRecommandProductListLogic{ +func NewGetRecommendProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRecommendProductListLogic { + return &GetRecommendProductListLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } -func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { +func (l *GetRecommendProductListLogic) GetRecommendProductList(req *types.GetRecommendProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { if req.Num > 100 || req.Num < 0 { req.Num = 4 } @@ -60,10 +60,6 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get recommend product list") } - //超过了截取 - if len(recommendProductList) > int(req.Num) { - recommendProductList = recommendProductList[:req.Num] - } } //资源id集合 resourceIds := make([]string, 0, 50) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 5e8cde0b..4a8f453d 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -5,7 +5,7 @@ import ( "fusenapi/utils/basic" ) -type GetRecommandProductListReq struct { +type GetRecommendProductListReq struct { Num int64 `form:"num,optional"` ProductId int64 `form:"product_id"` } diff --git a/server_api/product.api b/server_api/product.api index 37a929fb..bab77042 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -38,8 +38,8 @@ service product { @handler GetRenderSettingByPidHandler get /api/product/get_render_setting_by_pid(GetRenderSettingByPidReq) returns (response); //获取详情页推荐产品列表 - @handler GetRecommandProductListHandler - get /api/product/recommand(GetRecommandProductListReq) returns (response); + @handler GetRecommendProductListHandler + get /api/product/recommand(GetRecommendProductListReq) returns (response); //获取列表页推荐产品列表 @handler HomePageRecommendProductListHandler get /api/product/home_page_recommend(HomePageRecommendProductListReq) returns (response); @@ -49,7 +49,7 @@ service product { } //获取详情页推荐产品列表 -type GetRecommandProductListReq { +type GetRecommendProductListReq { Num int64 `form:"num,optional"` ProductId int64 `form:"product_id"` }