Files
platforms/backend/api/internal/routers/client.go
2026-07-30 18:04:34 +08:00

87 lines
4.4 KiB
Go

package routers
import (
"fmt"
sdkmiddleware "git.apinb.com/bsm-sdk/core/middleware"
clientcommon "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/common"
stafflogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/staff"
userlogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/user"
"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", clientcommon.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/products", userlogic.PublicProducts)
protected := engine.Group(basePath)
protected.Use(sdkmiddleware.JwtAuth(true), clientcommon.RequireClient("user_app"))
protected.GET("/auth/profile", userlogic.Profile)
protected.PUT("/auth/profile", userlogic.UpdateProfile)
protected.PUT("/auth/password", userlogic.ChangePassword)
protected.GET("/addresses", userlogic.ListAddresses)
protected.POST("/addresses", userlogic.SaveAddress)
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.POST("/gas/orders/:identity/cancel", userlogic.CancelGasOrder)
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.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/confirm-receipt", userlogic.ConfirmShopReceipt)
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", clientcommon.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), clientcommon.RequireClient("service_app"))
protected.GET("/auth/profile", stafflogic.Profile)
protected.PUT("/auth/password", stafflogic.ChangePassword)
protected.POST("/attendance", stafflogic.Attendance)
protected.GET("/tickets", stafflogic.ListTickets)
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)
registerClientWalletRoutes(protected, "service_app")
}
func registerClientWalletRoutes(group *gin.RouterGroup, client string) {
group.GET("/wallet", clientcommon.GetWallet(client))
group.PUT("/wallet/payment-password", clientcommon.SetPaymentPassword(client))
group.GET("/wallet/records", clientcommon.ListWalletRecords(client))
group.POST("/wallet/recharges", clientcommon.CreateRecharge(client))
group.POST("/wallet/recharges/:identity/mock-confirm", clientcommon.ConfirmMockRecharge(client))
group.GET("/wallet/banks", clientcommon.ListBanks(client))
group.POST("/wallet/banks", clientcommon.BindBank(client))
group.DELETE("/wallet/banks/:identity", clientcommon.UnbindBank(client))
group.GET("/wallet/withdrawals", clientcommon.ListWithdrawals(client))
group.POST("/wallet/withdrawals", clientcommon.CreateWithdrawal(client))
}