101 lines
5.3 KiB
Go
101 lines
5.3 KiB
Go
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/products", userlogic.PublicProducts)
|
|
|
|
protected := engine.Group(basePath)
|
|
protected.Use(sdkmiddleware.JwtAuth(true), common.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.POST("/gas/orders/:identity/pay", userlogic.PayGasOrder)
|
|
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.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)
|
|
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.POST("/wallet/recharges", common.CreateRecharge(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.DELETE("/wallet/banks/:identity", common.UnbindBank(client))
|
|
group.GET("/wallet/withdrawals", common.ListWithdrawals(client))
|
|
group.POST("/wallet/withdrawals", common.CreateWithdrawal(client))
|
|
}
|