From 9f0238028df57dcbbe249850fbf451ae43608a30 Mon Sep 17 00:00:00 2001 From: FantasyRL <1845983502@qq.com> Date: Wed, 18 Dec 2024 14:33:35 +0800 Subject: [PATCH] fix: api.common and api.version logic error --- api/handler/api/common_service.go | 7 +++--- api/handler/api/version_service.go | 24 +++++++-------------- api/handler/custom/launch_screen_service.go | 3 --- api/handler/custom/url_service.go | 6 ------ 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/api/handler/api/common_service.go b/api/handler/api/common_service.go index 83df466f..8c3082bb 100644 --- a/api/handler/api/common_service.go +++ b/api/handler/api/common_service.go @@ -29,7 +29,6 @@ import ( "github.com/west2-online/fzuhelper-server/api/rpc" "github.com/west2-online/fzuhelper-server/kitex_gen/common" "github.com/west2-online/fzuhelper-server/pkg/errno" - "github.com/west2-online/fzuhelper-server/pkg/logger" ) // GetCSS . @@ -39,7 +38,6 @@ func GetCSS(ctx context.Context, c *app.RequestContext) { var req api.GetCSSRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetCSS: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -47,6 +45,7 @@ func GetCSS(ctx context.Context, c *app.RequestContext) { css, err := rpc.GetCSSRPC(ctx, &common.GetCSSRequest{}) if err != nil { pack.RespError(c, err) + return } c.Data(consts.StatusOK, "text/css", *css) } @@ -58,7 +57,6 @@ func GetHtml(ctx context.Context, c *app.RequestContext) { var req api.GetHtmlRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetHtml: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -66,6 +64,7 @@ func GetHtml(ctx context.Context, c *app.RequestContext) { html, err := rpc.GetHtmlRPC(ctx, &common.GetHtmlRequest{}) if err != nil { pack.RespError(c, err) + return } c.Data(consts.StatusOK, "text/html", *html) } @@ -77,7 +76,6 @@ func GetUserAgreement(ctx context.Context, c *app.RequestContext) { var req api.GetUserAgreementRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetUserAgreement: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -85,6 +83,7 @@ func GetUserAgreement(ctx context.Context, c *app.RequestContext) { userAgreement, err := rpc.GetUserAgreementRPC(ctx, &common.GetUserAgreementRequest{}) if err != nil { pack.RespError(c, err) + return } c.Data(consts.StatusOK, "text/html", *userAgreement) } diff --git a/api/handler/api/version_service.go b/api/handler/api/version_service.go index 6d88f528..e1f51c38 100644 --- a/api/handler/api/version_service.go +++ b/api/handler/api/version_service.go @@ -21,14 +21,12 @@ package api import ( "context" + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" "github.com/west2-online/fzuhelper-server/api/pack" "github.com/west2-online/fzuhelper-server/api/rpc" "github.com/west2-online/fzuhelper-server/kitex_gen/version" "github.com/west2-online/fzuhelper-server/pkg/errno" - "github.com/west2-online/fzuhelper-server/pkg/logger" - - "github.com/cloudwego/hertz/pkg/app" - "github.com/cloudwego/hertz/pkg/protocol/consts" api "github.com/west2-online/fzuhelper-server/api/model/api" ) @@ -40,7 +38,6 @@ func Login(ctx context.Context, c *app.RequestContext) { var req api.LoginRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.Login: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -61,7 +58,6 @@ func UploadVersion(ctx context.Context, c *app.RequestContext) { var req api.UploadRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.UploadVersion: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -91,7 +87,6 @@ func UploadParams(ctx context.Context, c *app.RequestContext) { var req api.UploadParamsRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.UploadParams: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -115,7 +110,6 @@ func DownloadReleaseApk(ctx context.Context, c *app.RequestContext) { var req api.DownloadReleaseApkRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.DownloadReleaseApk: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -123,6 +117,7 @@ func DownloadReleaseApk(ctx context.Context, c *app.RequestContext) { reUrl, err := rpc.DownloadReleaseApkRPC(ctx, &version.DownloadReleaseApkRequest{}) if err != nil { pack.RespError(c, err) + return } c.Redirect(consts.StatusFound, []byte(*reUrl)) @@ -135,7 +130,6 @@ func DownloadBetaApk(ctx context.Context, c *app.RequestContext) { var req api.DownloadBetaApkRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.DownloadBetaApk: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -143,6 +137,7 @@ func DownloadBetaApk(ctx context.Context, c *app.RequestContext) { reUrl, err := rpc.DownloadBetaApkRPC(ctx, &version.DownloadBetaApkRequest{}) if err != nil { pack.RespError(c, err) + return } c.Redirect(consts.StatusFound, []byte(*reUrl)) @@ -155,7 +150,6 @@ func GetReleaseVersion(ctx context.Context, c *app.RequestContext) { var req api.GetReleaseVersionRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetReleaseVersion: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -182,7 +176,6 @@ func GetBetaVersion(ctx context.Context, c *app.RequestContext) { var req api.GetBetaVersionRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetBetaVersion: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -209,7 +202,6 @@ func GetSetting(ctx context.Context, c *app.RequestContext) { var req api.GetSettingRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetSetting: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -225,6 +217,7 @@ func GetSetting(ctx context.Context, c *app.RequestContext) { }) if err != nil { pack.RespError(c, err) + return } resp.CloudSetting = rpcResp.CloudSetting @@ -238,7 +231,6 @@ func GetTest(ctx context.Context, c *app.RequestContext) { var req api.GetTestRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetTest: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -255,6 +247,7 @@ func GetTest(ctx context.Context, c *app.RequestContext) { }) if err != nil { pack.RespError(c, err) + return } resp.CloudSetting = rpcResp.CloudSetting @@ -268,7 +261,6 @@ func GetCloud(ctx context.Context, c *app.RequestContext) { var req api.GetCloudRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetCloud: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -277,6 +269,7 @@ func GetCloud(ctx context.Context, c *app.RequestContext) { rpcResp, err := rpc.GetCloudRPC(ctx, &version.GetCloudRequest{}) if err != nil { pack.RespError(c, err) + return } resp.CloudSetting = rpcResp.CloudSetting @@ -291,7 +284,6 @@ func SetCloud(ctx context.Context, c *app.RequestContext) { var req api.SetCloudRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.SetCloud: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -314,7 +306,6 @@ func GetDump(ctx context.Context, c *app.RequestContext) { var req api.GetDumpRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetDump: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -324,6 +315,7 @@ func GetDump(ctx context.Context, c *app.RequestContext) { rpcResp, err := rpc.GetDumpRPC(ctx, &version.GetDumpRequest{}) if err != nil { pack.RespError(c, err) + return } resp.Data = rpcResp.Data diff --git a/api/handler/custom/launch_screen_service.go b/api/handler/custom/launch_screen_service.go index 483d3d86..55d1ed52 100644 --- a/api/handler/custom/launch_screen_service.go +++ b/api/handler/custom/launch_screen_service.go @@ -26,7 +26,6 @@ import ( "github.com/west2-online/fzuhelper-server/api/rpc" "github.com/west2-online/fzuhelper-server/kitex_gen/launch_screen" "github.com/west2-online/fzuhelper-server/pkg/errno" - "github.com/west2-online/fzuhelper-server/pkg/logger" ) // MobileGetImage . @@ -36,7 +35,6 @@ func MobileGetImage(ctx context.Context, c *app.RequestContext) { var req api.MobileGetImageRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.MobileGetImage: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -65,7 +63,6 @@ func AddImagePointTime(ctx context.Context, c *app.RequestContext) { var req api.AddImagePointTimeRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.AddImagePointTime: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } diff --git a/api/handler/custom/url_service.go b/api/handler/custom/url_service.go index f637c361..c0accb43 100644 --- a/api/handler/custom/url_service.go +++ b/api/handler/custom/url_service.go @@ -32,7 +32,6 @@ import ( "github.com/west2-online/fzuhelper-server/api/rpc" "github.com/west2-online/fzuhelper-server/pkg/base" "github.com/west2-online/fzuhelper-server/pkg/errno" - "github.com/west2-online/fzuhelper-server/pkg/logger" ) var ( @@ -49,7 +48,6 @@ func APILogin(ctx context.Context, c *app.RequestContext) { var req api.LoginRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.APILogin: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -74,7 +72,6 @@ func UploadVersionInfo(ctx context.Context, c *app.RequestContext) { var req api.UploadRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.UploadVersion: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -108,7 +105,6 @@ func GetUploadParams(ctx context.Context, c *app.RequestContext) { var req api.UploadParamsRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.UploadParams: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -135,7 +131,6 @@ func GetReleaseVersionModify(ctx context.Context, c *app.RequestContext) { var req api.GetReleaseVersionRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetReleaseVersionModify: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return } @@ -161,7 +156,6 @@ func GetBetaVersionModify(ctx context.Context, c *app.RequestContext) { var req api.GetBetaVersionRequest err = c.BindAndValidate(&req) if err != nil { - logger.Errorf("api.GetBetaVersionModify: BindAndValidate error %v", err) pack.RespError(c, errno.ParamError.WithError(err)) return }