refactor wallet domain management
This commit is contained in:
@@ -28,6 +28,7 @@ func RegisterPlatform(serviceKey string, engine *gin.Engine) {
|
||||
registerStaffRoute(protected)
|
||||
registerUserRoute(protected)
|
||||
registerProductRoute(protected)
|
||||
registerWalletRoute(protected)
|
||||
registerCommerceRoute(protected)
|
||||
registerFinanceRoute(protected)
|
||||
registerContentRoute(protected)
|
||||
@@ -87,6 +88,37 @@ func registerProductRoute(group *gin.RouterGroup) {
|
||||
owner.GET("/:identity", ownerGet)
|
||||
}
|
||||
|
||||
func registerWalletRoute(group *gin.RouterGroup) {
|
||||
basic := group.Group("/wallet_basic")
|
||||
basic.GET("", platform.ListWalletBasic)
|
||||
basic.GET("/:identity", platform.GetWalletBasic)
|
||||
basic.PATCH("/:identity/status", platform.UpdateWalletBasicStatus)
|
||||
basic.POST("/:identity/recharge", platform.RechargeWalletBasic)
|
||||
basic.GET("/owner/:owner_type/:owner_identity", platform.GetOrCreateOwnerWallet)
|
||||
|
||||
bank := group.Group("/wallet_bank")
|
||||
bank.GET("", platform.ListWalletBank)
|
||||
bank.GET("/:identity", platform.GetWalletBank)
|
||||
|
||||
payment := group.Group("/wallet_payment")
|
||||
payment.GET("", platform.ListWalletPayment)
|
||||
payment.GET("/:identity", platform.GetWalletPayment)
|
||||
|
||||
record := group.Group("/wallet_record")
|
||||
record.GET("", platform.ListWalletRecord)
|
||||
record.GET("/:identity", platform.GetWalletRecord)
|
||||
|
||||
refund := group.Group("/wallet_refund")
|
||||
refund.GET("", platform.ListWalletRefund)
|
||||
refund.GET("/:identity", platform.GetWalletRefund)
|
||||
|
||||
applyCash := group.Group("/wallet_apply_cash")
|
||||
applyCash.GET("", platform.ListWalletApplyCash)
|
||||
applyCash.GET("/:identity", platform.GetWalletApplyCash)
|
||||
applyCash.POST("/:identity/approve", platform.ApproveWalletApplyCash)
|
||||
applyCash.POST("/:identity/reject", platform.RejectWalletApplyCash)
|
||||
}
|
||||
|
||||
func registerCommerceRoute(group *gin.RouterGroup) {
|
||||
categoryRelations := []platform.ResourceRelation{optionalRelation("parent_identity", "parent_id", &models.EcCategory{})}
|
||||
_, categoryCreate, _, categoryUpdate := platform.ResourceHandlers(&models.EcCategory{}, []string{"name", "sort_no"}, []string{"name", "sort_no"}, categoryRelations...)
|
||||
@@ -140,10 +172,6 @@ func registerFinanceRoute(group *gin.RouterGroup) {
|
||||
registerWritableResource(group, "/finance/fin_settlement", settlementList, settlementCreate, settlementGet, settlementUpdate, &models.FinSettlement{})
|
||||
registerRestrictedWritableResource(group, "/finance/fin_reconciliation", &models.FinReconciliation{}, []string{"channel", "bill_date", "difference_amount"})
|
||||
|
||||
registerReadOnlyResource(group, "/wallet/wallet", &models.Wallet{})
|
||||
registerReadOnlyResource(group, "/wallet/wallet_ledger", &models.WalletLedger{})
|
||||
registerReadOnlyResource(group, "/wallet/wallet_recharge", &models.WalletRecharge{})
|
||||
registerReadOnlyResource(group, "/wallet/wallet_withdrawal", &models.WalletWithdrawal{})
|
||||
}
|
||||
|
||||
func registerContentRoute(group *gin.RouterGroup) {
|
||||
|
||||
@@ -166,7 +166,7 @@ func TestPlatformFinanceContentRoutesFollowTheirContracts(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, resource := range []string{
|
||||
"/wallet/wallet", "/wallet/wallet_ledger", "/wallet/wallet_recharge", "/wallet/wallet_withdrawal",
|
||||
"/wallet_basic", "/wallet_bank", "/wallet_payment", "/wallet_record", "/wallet_refund", "/wallet_apply_cash",
|
||||
} {
|
||||
path := "/heqi/platform/v1" + resource
|
||||
assertRouteMethods(t, routes, path, http.MethodGet)
|
||||
@@ -177,6 +177,19 @@ func TestPlatformFinanceContentRoutesFollowTheirContracts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/wallet_basic/:identity/status", http.MethodPatch)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/wallet_basic/:identity/recharge", http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/wallet_basic/owner/:owner_type/:owner_identity", http.MethodGet)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/wallet_apply_cash/:identity/approve", http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/wallet_apply_cash/:identity/reject", http.MethodPost)
|
||||
for _, oldPath := range []string{
|
||||
"/heqi/platform/v1/wallet/wallet",
|
||||
"/heqi/platform/v1/wallet/wallet_ledger",
|
||||
"/heqi/platform/v1/wallet/wallet_recharge",
|
||||
"/heqi/platform/v1/wallet/wallet_withdrawal",
|
||||
} {
|
||||
assertNoRouteMethods(t, routes, oldPath, http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
|
||||
}
|
||||
|
||||
for _, resource := range []string{
|
||||
"/content/cnt_content", "/notification/ntf_template",
|
||||
|
||||
Reference in New Issue
Block a user