diff --git a/server/canteen/internal/handler/getcanteendetailhandler.go b/server/canteen/internal/handler/getcanteendetailhandler.go index 932f64f2..f5c8d44f 100644 --- a/server/canteen/internal/handler/getcanteendetailhandler.go +++ b/server/canteen/internal/handler/getcanteendetailhandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/canteen/internal/logic" "fusenapi/server/canteen/internal/svc" @@ -20,7 +21,7 @@ func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.GetCanteenDetailReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/canteen/internal/handler/savecanteentypeproducthandler.go b/server/canteen/internal/handler/savecanteentypeproducthandler.go index 8a81fb62..7e5ee156 100644 --- a/server/canteen/internal/handler/savecanteentypeproducthandler.go +++ b/server/canteen/internal/handler/savecanteentypeproducthandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/canteen/internal/logic" "fusenapi/server/canteen/internal/svc" @@ -20,7 +21,7 @@ func SaveCanteenTypeProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func SaveCanteenTypeProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func SaveCanteenTypeProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc var req types.SaveCanteenTypeProductReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func SaveCanteenTypeProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/canteen/internal/logic/getcanteendetaillogic.go b/server/canteen/internal/logic/getcanteendetaillogic.go index 9a751854..d24ffbef 100644 --- a/server/canteen/internal/logic/getcanteendetaillogic.go +++ b/server/canteen/internal/logic/getcanteendetaillogic.go @@ -27,7 +27,7 @@ func NewGetCanteenDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } // 获取餐厅详情 -func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq, loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *GetCanteenDetailLogic) GetCanteenDetail(req *types.GetCanteenDetailReq, loginInfo *auth.UserInfo) (resp *basic.Response) { //获取餐厅类型数据 canteenTypeModel := gmodel.NewFsCanteenTypeModel(l.svcCtx.MysqlConn) canteenTypeInfo, err := canteenTypeModel.FindOne(l.ctx, req.Id) diff --git a/server/canteen/internal/logic/savecanteentypeproductlogic.go b/server/canteen/internal/logic/savecanteentypeproductlogic.go index 6b4d9cf4..b7382b96 100644 --- a/server/canteen/internal/logic/savecanteentypeproductlogic.go +++ b/server/canteen/internal/logic/savecanteentypeproductlogic.go @@ -30,7 +30,7 @@ func NewSaveCanteenTypeProductLogic(ctx context.Context, svcCtx *svc.ServiceCont } // 保存餐厅类型的关联产品 -func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCanteenTypeProductReq, loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCanteenTypeProductReq, loginInfo *auth.UserInfo) (resp *basic.Response) { if len(req.ProductList) == 0 { return resp.SetStatusWithMessage(basic.CodeServiceErr, "product list can`t be empty") } diff --git a/server/canteen/internal/types/types.go b/server/canteen/internal/types/types.go index e2774873..34a65a59 100644 --- a/server/canteen/internal/types/types.go +++ b/server/canteen/internal/types/types.go @@ -35,6 +35,9 @@ type SaveCanteenProduct struct { SId string `json:"s_id"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` diff --git a/server/data-transfer/internal/handler/getqrcodesetlisthandler.go b/server/data-transfer/internal/handler/getqrcodesetlisthandler.go index a366d2c0..190b2864 100644 --- a/server/data-transfer/internal/handler/getqrcodesetlisthandler.go +++ b/server/data-transfer/internal/handler/getqrcodesetlisthandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/data-transfer/internal/logic" "fusenapi/server/data-transfer/internal/svc" @@ -19,7 +20,7 @@ func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -31,7 +32,7 @@ func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -40,7 +41,7 @@ func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } l := logic.NewGetQrCodeSetListLogic(r.Context(), svcCtx) - resp := l.GetQrCodeSetList() + resp := l.GetQrCodeSetList(userinfo) // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; // 否则,发送500内部服务器错误的JSON响应并记录错误消息logx.Error。 if resp != nil { @@ -50,6 +51,5 @@ func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/data-transfer/internal/handler/getstandardlogolisthandler.go b/server/data-transfer/internal/handler/getstandardlogolisthandler.go index 1eff3761..4c9d27f9 100644 --- a/server/data-transfer/internal/handler/getstandardlogolisthandler.go +++ b/server/data-transfer/internal/handler/getstandardlogolisthandler.go @@ -2,13 +2,13 @@ package handler import ( "errors" - "fusenapi/server/data-transfer/internal/types" "net/http" "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/data-transfer/internal/logic" "fusenapi/server/data-transfer/internal/svc" @@ -20,7 +20,7 @@ func GetStandardLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +32,7 @@ func GetStandardLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -51,6 +51,5 @@ func GetStandardLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/data-transfer/internal/handler/uploadlogohandler.go b/server/data-transfer/internal/handler/uploadlogohandler.go index 26d18626..8481ae57 100644 --- a/server/data-transfer/internal/handler/uploadlogohandler.go +++ b/server/data-transfer/internal/handler/uploadlogohandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/data-transfer/internal/logic" "fusenapi/server/data-transfer/internal/svc" @@ -20,7 +21,7 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.UploadLogoReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/data-transfer/internal/handler/uploadqrcodehandler.go b/server/data-transfer/internal/handler/uploadqrcodehandler.go index b3170434..2b6afa80 100644 --- a/server/data-transfer/internal/handler/uploadqrcodehandler.go +++ b/server/data-transfer/internal/handler/uploadqrcodehandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/data-transfer/internal/logic" "fusenapi/server/data-transfer/internal/svc" @@ -20,7 +21,7 @@ func UploadQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func UploadQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func UploadQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.UploadQrcodeReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func UploadQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/data-transfer/internal/logic/getqrcodesetlistlogic.go b/server/data-transfer/internal/logic/getqrcodesetlistlogic.go index 5359912a..b17db08f 100644 --- a/server/data-transfer/internal/logic/getqrcodesetlistlogic.go +++ b/server/data-transfer/internal/logic/getqrcodesetlistlogic.go @@ -27,7 +27,7 @@ func NewGetQrCodeSetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } // 获取二维码配置列表 -func (l *GetQrCodeSetListLogic) GetQrCodeSetList(loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *GetQrCodeSetListLogic) GetQrCodeSetList(loginInfo *auth.UserInfo) (resp *basic.Response) { qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn) qrCodeList, err := qrCodeModel.GetAll(l.ctx) if err != nil { diff --git a/server/data-transfer/internal/logic/getstandardlogolistlogic.go b/server/data-transfer/internal/logic/getstandardlogolistlogic.go index a007a83b..61785c8f 100644 --- a/server/data-transfer/internal/logic/getstandardlogolistlogic.go +++ b/server/data-transfer/internal/logic/getstandardlogolistlogic.go @@ -26,7 +26,7 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContex } // 获取标准logo列表 -func (l *GetStandardLogoListLogic) GetStandardLogoList(loginInfo *auth.UserInfo) (resp *types2.Response) { +func (l *GetStandardLogoListLogic) GetStandardLogoList(loginInfo *auth.UserInfo) (resp *basic.Response) { standardLogoModel := gmodel.NewFsStandardLogoModel(l.svcCtx.MysqlConn) logoList, err := standardLogoModel.GetAll(l.ctx) if err != nil { diff --git a/server/data-transfer/internal/logic/uploadlogologic.go b/server/data-transfer/internal/logic/uploadlogologic.go index 2f52d9a2..7e266dd2 100644 --- a/server/data-transfer/internal/logic/uploadlogologic.go +++ b/server/data-transfer/internal/logic/uploadlogologic.go @@ -25,7 +25,7 @@ func NewUploadLogoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upload } } -func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, loginInfo *auth.UserInfo) (resp *basic.Response) { // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) return resp.SetStatus(basic.CodeOK) diff --git a/server/data-transfer/internal/logic/uploadqrcodelogic.go b/server/data-transfer/internal/logic/uploadqrcodelogic.go index 64cef43c..8e7b6f0a 100644 --- a/server/data-transfer/internal/logic/uploadqrcodelogic.go +++ b/server/data-transfer/internal/logic/uploadqrcodelogic.go @@ -27,7 +27,7 @@ func NewUploadQrcodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Uplo } // 生成base64二维码 -func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq, loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq, loginInfo *auth.UserInfo) (resp *basic.Response) { if req.Url == "" { resp.SetStatus(basic.CodeApiErr, "param url is empty") } diff --git a/server/data-transfer/internal/types/types.go b/server/data-transfer/internal/types/types.go index 7dcaf75f..d50c9a7c 100644 --- a/server/data-transfer/internal/types/types.go +++ b/server/data-transfer/internal/types/types.go @@ -39,6 +39,9 @@ type UploadLogoRsp struct { ImgColor []string `json:"img_color"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` diff --git a/server/home-user-auth/internal/handler/routes.go b/server/home-user-auth/internal/handler/routes.go deleted file mode 100644 index 5738d5a4..00000000 --- a/server/home-user-auth/internal/handler/routes.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -package handler - -import ( - "net/http" - - "fusenapi/server/home-user-auth/internal/svc" - - "github.com/zeromicro/go-zero/rest" -) - -func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/user/login", - Handler: UserLoginHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/user/fonts", - Handler: UserFontsHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/user/get-type", - Handler: UserGetTypeHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/user/basic-info", - Handler: UserSaveBasicInfoHandler(serverCtx), - }, - { - Method: http.MethodPost, - Path: "/user/status-config", - Handler: UserStatusConfigHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/user/basic-info", - Handler: UserBasicInfoHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/user/address-list", - Handler: UserAddressListHandler(serverCtx), - }, - }, - ) -} diff --git a/server/product/internal/handler/getproductlisthandler.go b/server/product/internal/handler/getproductlisthandler.go index 08a24ead..35a1d3d6 100644 --- a/server/product/internal/handler/getproductlisthandler.go +++ b/server/product/internal/handler/getproductlisthandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/product/internal/logic" "fusenapi/server/product/internal/svc" @@ -20,7 +21,7 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.GetProductListReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/product/internal/handler/getsizebyproducthandler.go b/server/product/internal/handler/getsizebyproducthandler.go index 4504376c..13bcf0bb 100644 --- a/server/product/internal/handler/getsizebyproducthandler.go +++ b/server/product/internal/handler/getsizebyproducthandler.go @@ -2,13 +2,13 @@ package handler import ( "errors" - "fusenapi/server/product/internal/types" "net/http" "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/product/internal/logic" "fusenapi/server/product/internal/svc" @@ -20,7 +20,7 @@ func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +32,7 @@ func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -51,6 +51,5 @@ func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/product/internal/handler/getsuccessrecommandhandler.go b/server/product/internal/handler/getsuccessrecommandhandler.go index 4e78cbae..a3196ad5 100644 --- a/server/product/internal/handler/getsuccessrecommandhandler.go +++ b/server/product/internal/handler/getsuccessrecommandhandler.go @@ -8,6 +8,7 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" "fusenapi/utils/auth" + "fusenapi/utils/basic" "fusenapi/server/product/internal/logic" "fusenapi/server/product/internal/svc" @@ -20,7 +21,7 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -32,7 +33,7 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { userinfo, err := auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 401, Message: "unauthorized", }) @@ -43,7 +44,7 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.GetSuccessRecommandReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { - httpx.OkJsonCtx(r.Context(), w, &types.Response{ + httpx.OkJsonCtx(r.Context(), w, &basic.Response{ Code: 510, Message: "parameter error", }) @@ -62,6 +63,5 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { httpx.ErrorCtx(r.Context(), w, err) logx.Error(err) } - return } } diff --git a/server/product/internal/logic/getproductlistlogic.go b/server/product/internal/logic/getproductlistlogic.go index 45bc8625..277f8522 100644 --- a/server/product/internal/logic/getproductlistlogic.go +++ b/server/product/internal/logic/getproductlistlogic.go @@ -33,8 +33,7 @@ func NewGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge } // 获取产品列表 -func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo *auth.UserInfo) (resp *types.Response) { - resp = &types.Response{} +func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo *auth.UserInfo) (resp *basic.Response) { //如果是demo if req.IsDemo == 1 { var demo types.GetProductListRsp diff --git a/server/product/internal/logic/getsizebyproductlogic.go b/server/product/internal/logic/getsizebyproductlogic.go index a16449c5..e01c4a10 100644 --- a/server/product/internal/logic/getsizebyproductlogic.go +++ b/server/product/internal/logic/getsizebyproductlogic.go @@ -32,7 +32,7 @@ func NewGetSizeByProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } // 获取分类下的产品以及尺寸 -func (l *GetSizeByProductLogic) GetSizeByProduct(loginInfo *auth.UserInfo) (resp *types.Response) { +func (l *GetSizeByProductLogic) GetSizeByProduct(loginInfo *auth.UserInfo) (resp *basic.Response) { //获取所有网站目录 tagsModel := gmodel.NewFsTagsModel(l.svcCtx.MysqlConn) tagsList, err := tagsModel.GetAllByLevel(l.ctx, constants.TYPE_WEBSITE) diff --git a/server/product/internal/logic/getsuccessrecommandlogic.go b/server/product/internal/logic/getsuccessrecommandlogic.go index 24360b2f..4564156e 100644 --- a/server/product/internal/logic/getsuccessrecommandlogic.go +++ b/server/product/internal/logic/getsuccessrecommandlogic.go @@ -26,8 +26,7 @@ func NewGetSuccessRecommandLogic(ctx context.Context, svcCtx *svc.ServiceContext } // 获取推荐的产品列表 -func (l *GetSuccessRecommandLogic) GetSuccessRecommand(req *types.GetSuccessRecommandReq, loginInfo *auth.UserInfo) (resp *types.Response) { - resp = &types.Response{} +func (l *GetSuccessRecommandLogic) GetSuccessRecommand(req *types.GetSuccessRecommandReq, loginInfo *auth.UserInfo) (resp *basic.Response) { //获取用户信息 userModel := gmodel.NewFsUserModel(l.svcCtx.MysqlConn) userInfo, err := userModel.FindOne(l.ctx, loginInfo.UserId) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 1b74bab6..ff2759e8 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -96,6 +96,9 @@ type PriceObj struct { Price float64 `json:"price"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` diff --git a/server_api/basic.api b/server_api/basic.api index d979d3be..d3eba6ea 100644 --- a/server_api/basic.api +++ b/server_api/basic.api @@ -6,7 +6,9 @@ info ( author: "" email: "" ) +type request { +} // response 统一返回码 type response { Code int `json:"code"`