refactor platform account and access models

This commit is contained in:
david
2026-07-28 13:35:59 +08:00
parent f808f1c51f
commit bc39021c0d
20 changed files with 234 additions and 181 deletions

View File

@@ -179,7 +179,13 @@ func registerUserRoute(group *gin.RouterGroup) {
}
func registerPlatformRoute(group *gin.RouterGroup) {
registerWritableResource(group, "/platfrom_account", platform.ListPlatfromAccount, platform.CreatePlatfromAccount, platform.GetPlatfromAccount, platform.UpdatePlatfromAccount, &models.PlatfromAccount{})
account := group.Group("/platform_account")
account.GET("", platform.ListPlatformAccount)
account.POST("", platform.CreatePlatformAccount)
account.GET("/:identity", platform.GetPlatformAccount)
account.PUT("/:identity", platform.UpdatePlatformAccount)
account.PATCH("/:identity/status", platform.UpdatePlatformAccountStatus)
account.DELETE("/:identity", platform.ArchivePlatformAccount)
role := group.Group("/platform_role")
role.GET("", platform.ListPlatformRole)
role.POST("", platform.CreatePlatformRole)
@@ -189,7 +195,6 @@ func registerPlatformRoute(group *gin.RouterGroup) {
role.DELETE("/:identity", platform.ArchivePlatformRole)
role.GET("/:identity/menu", platform.ListPlatformRoleMenuIdentities)
role.PUT("/:identity/menu", platform.ReplacePlatformRoleMenus)
role.PUT("/:identity/menus", platform.ReplacePlatformRoleMenus)
menu := group.Group("/platform_menu")
menu.GET("", platform.ListPlatformMenu)
menu.POST("", platform.CreatePlatformMenu)

View File

@@ -85,7 +85,7 @@ func TestPlatformOrganizationAndAccountRoutesExposeResourceCRUD(t *testing.T) {
"/user_account",
"/user_address",
"/user_service_relation",
"/platfrom_account",
"/platform_account",
"/platform_role",
"/platform_menu",
} {
@@ -95,7 +95,8 @@ func TestPlatformOrganizationAndAccountRoutesExposeResourceCRUD(t *testing.T) {
}
assertRouteMethods(t, routes, "/heqi/platform/v1/platform_role/:identity/menu", http.MethodGet, http.MethodPut)
assertRouteMethods(t, routes, "/heqi/platform/v1/platform_role/:identity/menus", http.MethodPut)
assertNoRouteMethods(t, routes, "/heqi/platform/v1/platform_role/:identity/menus", http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
assertNoRouteMethods(t, routes, "/heqi/platform/v1/platfrom_account", http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
}
func TestPlatformProductCommerceAndDeliveryRoutesFollowTheirContracts(t *testing.T) {