package routers import ( "fmt" sdkmiddleware "git.apinb.com/bsm-sdk/core/middleware" stafflogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/staff" userlogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/user" common "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common" "github.com/gin-gonic/gin" ) // RegisterClient 注册用户 App 和工作人员 App 的隔离 API。 func RegisterClient(serviceKey string, engine *gin.Engine) { registerUserClient(serviceKey, engine) registerStaffClient(serviceKey, engine) } func registerUserClient(serviceKey string, engine *gin.Engine) { basePath := fmt.Sprintf("/%s/client/v1/user", serviceKey) anonymous := engine.Group(basePath) anonymous.POST("/auth/verification-code", common.SendVerificationCode("user_app")) anonymous.POST("/auth/register", userlogic.Register) anonymous.POST("/auth/login", userlogic.Login) anonymous.POST("/auth/reset-password", userlogic.ResetPassword) anonymous.GET("/public/gas-stations", userlogic.PublicGasStations) anonymous.GET("/public/delivery-points", userlogic.PublicDeliveryPoints) anonymous.GET("/public/contents", userlogic.PublicContents) anonymous.GET("/public/contents/:identity", userlogic.PublicSafetyContent) anonymous.GET("/public/products", userlogic.PublicProducts) anonymous.GET("/public/products/:identity", userlogic.PublicProduct) protected := engine.Group(basePath) protected.Use(sdkmiddleware.JwtAuth(true), common.RequireClient("user_app")) protected.GET("/auth/profile", userlogic.Profile) protected.GET("/owned-products", userlogic.ListOwnedProducts) protected.GET("/devices", userlogic.ListDevices) protected.PUT("/devices/:identity/group", userlogic.AssignDeviceGroup) protected.GET("/device-groups", userlogic.ListDeviceGroups) protected.GET("/usage-statistics", userlogic.GetUsageStatistics) protected.GET("/messages", userlogic.ListMessages) protected.PUT("/messages/read", userlogic.MarkMessagesRead) protected.POST("/device-groups", userlogic.SaveDeviceGroup) protected.PUT("/device-groups/:identity", userlogic.SaveDeviceGroup) protected.DELETE("/device-groups/:identity", userlogic.DeleteDeviceGroup) protected.GET("/emergency-contacts", userlogic.ListEmergencyContacts) protected.POST("/emergency-contacts", userlogic.SaveEmergencyContact) protected.PUT("/emergency-contacts/:identity", userlogic.SaveEmergencyContact) protected.DELETE("/emergency-contacts/:identity", userlogic.DeleteEmergencyContact) protected.GET("/family", userlogic.FamilyDashboard) protected.POST("/family-members", userlogic.InviteFamilyMember) protected.PUT("/family-members/:identity/device-permissions", userlogic.UpdateFamilyPermissions) protected.DELETE("/family-members/:identity", userlogic.RevokeFamilyMember) protected.GET("/family-invitations", userlogic.ListFamilyInvitations) protected.POST("/family-invitations/:identity/respond", userlogic.RespondFamilyInvitation) protected.POST("/ticket-photos", userlogic.UploadTicketPhoto) protected.GET("/ticket-photos/:name", userlogic.UploadedTicketPhoto) protected.GET("/tickets/:identity/photos/:photoIdentity", userlogic.TicketPhoto) protected.GET("/auth/avatar", userlogic.Avatar) protected.PUT("/auth/profile", userlogic.UpdateProfile) protected.PUT("/auth/password", userlogic.ChangePassword) protected.GET("/addresses", userlogic.ListAddresses) protected.POST("/addresses", userlogic.SaveAddress) protected.PUT("/addresses/:identity", userlogic.UpdateAddress) protected.DELETE("/addresses/:identity", userlogic.DeleteAddress) protected.POST("/addresses/:identity/default", userlogic.SetDefaultAddress) protected.POST("/contents/read-confirmations", userlogic.ConfirmContentRead) protected.GET("/service-relation", userlogic.ServiceRelation) protected.GET("/gas/contracts", userlogic.ListGasContracts) protected.GET("/gas/orders", userlogic.ListGasOrders) protected.GET("/gas/order-options", userlogic.GetGasOrderOptions) protected.POST("/gas/orders", userlogic.CreateGasOrder) protected.GET("/gas/orders/:identity", userlogic.GetGasOrder) protected.POST("/gas/orders/:identity/confirm-receipt", userlogic.ConfirmGasReceipt) protected.GET("/gas/contracts/:identity", userlogic.GetGasContract) protected.GET("/gas/contracts/:identity/attachment", userlogic.DownloadGasContractAttachment) protected.GET("/gas/contracts/:identity/history", userlogic.GetGasContractHistory) protected.GET("/gas/contracts/:identity/requests", userlogic.ListGasContractRequests) protected.POST("/gas/contracts/:identity/requests", userlogic.CreateGasContractRequest) protected.POST("/gas/orders/:identity/cancel", userlogic.CancelGasOrder) protected.POST("/gas/orders/:identity/pay", userlogic.PayGasOrder) protected.GET("/gas/orders/:identity/delivery", userlogic.GetGasOrderDelivery) protected.GET("/gas/orders/:identity/delivery/track", userlogic.GetGasOrderDeliveryTrack) protected.POST("/gas/orders/:identity/refunds", userlogic.CreateRefund("gasorder")) protected.GET("/tickets", userlogic.ListTickets) protected.POST("/tickets", userlogic.CreateTicket) protected.POST("/tickets/:identity/confirm", userlogic.ConfirmTicket) protected.POST("/tickets/:identity/cancel", userlogic.CancelTicket) protected.GET("/shop/orders", userlogic.ListShopOrders) protected.GET("/shop/orders/:identity", userlogic.GetShopOrder) protected.GET("/shop/cart", userlogic.ListCart) protected.GET("/shop/favorites", userlogic.ListFavorites) protected.GET("/shop/recommendations", userlogic.Recommendations) protected.GET("/shop/favorites/items/:identity", userlogic.FavoriteState) protected.PUT("/shop/favorites/items/:identity", userlogic.SetFavorite) protected.GET("/shop/cart/items/:identity", userlogic.GetCartItem) protected.PUT("/shop/cart/items/:identity", userlogic.SetCartItem) protected.POST("/shop/orders", userlogic.CreateShopOrder) protected.POST("/shop/orders/:identity/cancel", userlogic.CancelShopOrder) protected.POST("/shop/orders/:identity/pay", userlogic.PayShopOrder) protected.POST("/shop/orders/:identity/refunds", userlogic.CreateRefund("ec_order")) protected.POST("/shop/orders/:identity/confirm-receipt", userlogic.ConfirmShopReceipt) protected.GET("/refunds", userlogic.ListRefunds) protected.GET("/deposits", userlogic.ListDeposits) protected.POST("/deposit-returns", userlogic.CreateDepositReturn) protected.GET("/deposit-returns/:identity", userlogic.GetDepositReturn) protected.POST("/deposit-returns/:identity/cancel", userlogic.CancelDepositReturn) registerClientWalletRoutes(protected, "user_app") } func registerStaffClient(serviceKey string, engine *gin.Engine) { basePath := fmt.Sprintf("/%s/client/v1/staff", serviceKey) anonymous := engine.Group(basePath) anonymous.POST("/auth/verification-code", common.SendVerificationCode("service_app")) anonymous.POST("/auth/login", stafflogic.Login) anonymous.POST("/auth/reset-password", stafflogic.ResetPassword) protected := engine.Group(basePath) protected.Use(sdkmiddleware.JwtAuth(true), common.RequireClient("service_app")) protected.GET("/auth/profile", stafflogic.Profile) protected.GET("/preflight", stafflogic.Preflight) protected.PUT("/auth/password", stafflogic.ChangePassword) protected.POST("/attendance", stafflogic.Attendance) protected.GET("/tickets", stafflogic.ListTickets) protected.GET("/tickets/:identity", stafflogic.GetTicket) protected.POST("/tickets/:identity/start", stafflogic.StartTicket) protected.POST("/tickets/:identity/exception", stafflogic.ExceptionTicket) protected.POST("/tickets/:identity/recover", stafflogic.RecoverTicket) protected.POST("/tickets/:identity/submit-result", stafflogic.SubmitTicketResult) protected.GET("/delivery/orders", stafflogic.ListDeliveryOrders) protected.GET("/delivery/orders/:identity", stafflogic.GetDeliveryOrder) protected.POST("/delivery/orders/:identity/start", stafflogic.StartDeliveryOrder) protected.POST("/delivery/orders/:identity/tracks", stafflogic.AppendDeliveryTracks) protected.POST("/delivery/orders/:identity/arrive", stafflogic.ArriveDeliveryOrder) protected.POST("/delivery/orders/:identity/exception", stafflogic.ExceptionDeliveryOrder) protected.POST("/delivery/orders/:identity/recover", stafflogic.RecoverDeliveryOrder) protected.POST("/delivery/orders/:identity/submit-receipt", stafflogic.SubmitDeliveryReceipt) registerClientWalletRoutes(protected, "service_app") } func registerClientWalletRoutes(group *gin.RouterGroup, client string) { group.GET("/wallet", common.GetWallet(client)) group.PUT("/wallet/payment-password", common.SetPaymentPassword(client)) group.GET("/wallet/records", common.ListWalletRecords(client)) group.GET("/wallet/bills", common.ListWalletBills(client)) group.POST("/wallet/recharges", common.CreateRecharge(client)) group.GET("/wallet/recharge-options", common.GetRechargeOptions(client)) group.GET("/wallet/recharges", common.ListRecharges(client)) group.GET("/wallet/recharges/:identity", common.GetRecharge(client)) group.GET("/wallet/recharge-requests/:request", common.GetRecharge(client)) group.POST("/wallet/recharges/:identity/mock-confirm", common.ConfirmMockRecharge(client)) group.GET("/wallet/banks", common.ListBanks(client)) group.POST("/wallet/banks", common.BindBank(client)) group.POST("/wallet/banks/:identity/default", common.SetDefaultBank(client)) group.DELETE("/wallet/banks/:identity", common.UnbindBank(client)) group.GET("/wallet/withdrawals", common.ListWithdrawals(client)) group.POST("/wallet/withdrawals", common.CreateWithdrawal(client)) }