// Code generated by protoc-gen-go-aeus. DO NOT EDIT. // source: organize.proto // date: 2025-06-13 11:10:07 package pb import ( "git.nobla.cn/golang/aeus/transport/http" "context" "git.nobla.cn/golang/aeus/pkg/errors" ) type MenuServiceHttpServer interface { GetMenus(context.Context, *GetMenuRequest) (*GetMenuResponse, error) } type ProfileServiceHttpServer interface { GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) } type AuthServiceHttpServer interface { Login(context.Context, *LoginRequest) (*LoginResponse, error) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) } func handleMenuServiceGetMenus(s MenuServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &GetMenuRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.GetMenus(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func handleProfileServiceGetProfile(s ProfileServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &GetProfileRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.GetProfile(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func handleProfileServiceUpdateProfile(s ProfileServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &UpdateProfileRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.UpdateProfile(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func handleProfileServiceResetPassword(s ProfileServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &ResetPasswordRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.ResetPassword(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func handleAuthServiceLogin(s AuthServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &LoginRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.Login(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func handleAuthServiceLogout(s AuthServiceHttpServer) http.HandleFunc { return func(ctx *http.Context) (err error) { req := &LogoutRequest{} if err := ctx.Bind(req); err != nil { return ctx.Error(errors.Invalid, err.Error()) } if res, err := s.Logout(ctx.Context(), req); err != nil { if er, ok := err.(*errors.Error); ok { return ctx.Error(er.Code, er.Message) } else { return ctx.Error(errors.Unavailable, err.Error()) } } else { return ctx.Success(res) } } } func RegisterMenuServiceRouter(hs *http.Server, s MenuServiceHttpServer) { // Register handle GetMenus route hs.GET("/api/menu", handleMenuServiceGetMenus(s)) } func RegisterProfileServiceRouter(hs *http.Server, s ProfileServiceHttpServer) { // Register handle GetProfile route hs.GET("/user/profile", handleProfileServiceGetProfile(s)) // Register handle UpdateProfile route hs.PUT("/user/profile", handleProfileServiceUpdateProfile(s)) // Register handle ResetPassword route hs.POST("/user/reset-password", handleProfileServiceResetPassword(s)) } func RegisterAuthServiceRouter(hs *http.Server, s AuthServiceHttpServer) { // Register handle Login route hs.POST("/passport/login", handleAuthServiceLogin(s)) // Register handle Logout route hs.POST("/passport/logout", handleAuthServiceLogout(s)) }