feat: 完善平台总后台模块

This commit is contained in:
2026-07-27 00:18:42 +08:00
parent 073eb89762
commit 642980960e
197 changed files with 22356 additions and 1060 deletions

View File

@@ -0,0 +1,82 @@
package routers
import (
"fmt"
"git.apinb.com/bsm-sdk/core/middleware"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform"
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
"github.com/gin-gonic/gin"
)
// RegisterPlatform 注册 /heqi/platform/v1 前缀下的平台总后台路由。
func RegisterPlatform(serviceKey string, engine *gin.Engine) {
basePath := fmt.Sprintf("/%s/platform/v1", serviceKey)
anonymous := engine.Group(basePath)
anonymous.GET("/ping/hello", platform.PingHello)
anonymous.POST("/auth/login", platform.Login)
protected := engine.Group(basePath)
protected.Use(middleware.JwtAuth(true))
protected.GET("/auth/profile", platform.CurrentProfile)
protected.PUT("/auth/password", platform.ChangePassword)
protected.GET("/dashboard/overview", platform.DashboardOverview)
registerGasRoute(protected)
registerDeliveryRoute(protected)
registerStaffRoute(protected)
registerUserRoute(protected)
registerPlatformRoute(protected)
}
func registerGasRoute(group *gin.RouterGroup) {
resource := group.Group("/gas/gas_basic")
resource.GET("", platform.ListGasBasic)
resource.POST("", platform.CreateGasBasic)
resource.GET("/:identity", platform.GetGasBasic)
resource.PUT("/:identity", platform.UpdateGasBasic)
resource.PATCH("/:identity/status", func(ctx *gin.Context) { platform.UpdateRecordStatus(ctx, &models.GasBasic{}) })
resource.DELETE("/:identity", func(ctx *gin.Context) { platform.ArchiveRecord(ctx, &models.GasBasic{}) })
}
func registerDeliveryRoute(group *gin.RouterGroup) {
resource := group.Group("/delivery/delivery_basic")
resource.GET("", platform.ListDeliveryBasic)
resource.POST("", platform.CreateDeliveryBasic)
resource.GET("/:identity", platform.GetDeliveryBasic)
resource.PUT("/:identity", platform.UpdateDeliveryBasic)
resource.PATCH("/:identity/status", func(ctx *gin.Context) { platform.UpdateRecordStatus(ctx, &models.DeliveryBasic{}) })
resource.DELETE("/:identity", func(ctx *gin.Context) { platform.ArchiveRecord(ctx, &models.DeliveryBasic{}) })
}
func registerStaffRoute(group *gin.RouterGroup) {
resource := group.Group("/staff")
resource.GET("/account", platform.ListStaff)
resource.POST("/account", platform.CreateStaff)
resource.GET("/:identity", platform.GetStaff)
resource.PUT("/:identity", platform.UpdateStaff)
resource.PATCH("/:identity/status", func(ctx *gin.Context) { platform.UpdateRecordStatus(ctx, &models.StaffAccount{}) })
resource.DELETE("/:identity", func(ctx *gin.Context) { platform.ArchiveRecord(ctx, &models.StaffAccount{}) })
}
func registerUserRoute(group *gin.RouterGroup) {
resource := group.Group("/user")
resource.GET("/account", platform.ListUser)
resource.POST("/account", platform.CreateUser)
resource.GET("/:identity", platform.GetUser)
resource.PUT("/:identity", platform.UpdateUser)
resource.PATCH("/:identity/status", func(ctx *gin.Context) { platform.UpdateRecordStatus(ctx, &models.UserAccount{}) })
resource.DELETE("/:identity", func(ctx *gin.Context) { platform.ArchiveRecord(ctx, &models.UserAccount{}) })
}
func registerPlatformRoute(group *gin.RouterGroup) {
group.GET("/platform/platfrom_account", platform.ListPlatfromAccount)
role := group.Group("/platform/platform_role")
role.GET("", platform.ListPlatformRole)
role.POST("", platform.CreatePlatformRole)
role.GET("/:identity", platform.GetPlatformRole)
role.PUT("/:identity", platform.UpdatePlatformRole)
role.PATCH("/:identity/status", platform.UpdatePlatformRoleStatus)
role.DELETE("/:identity", platform.ArchivePlatformRole)
group.GET("/platform/platform_menu", platform.ListPlatformMenu)
}

View File

@@ -1,33 +1,10 @@
// Package routers 注册与 sample/server 一致的匿名和 JWT 受保护路由组
// Package routers 提供 API 路由注册入口
package routers
import (
"fmt"
import "github.com/gin-gonic/gin"
"git.apinb.com/bsm-sdk/core/middleware"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform"
"github.com/gin-gonic/gin"
)
// Register 注册路由,请求地址格式: /{serviceKey}/v1/{domain}/{resource}。
func Register(srvKey string, engine *gin.Engine) {
v1Key := fmt.Sprintf("/%s/%s", srvKey, "v1")
anonymous := engine.Group(v1Key)
anonymous.GET("/ping/hello", platform.PingHello)
anonymous.POST("/auth/login", platform.Login)
protected := engine.Group(v1Key)
protected.Use(middleware.JwtAuth(true))
{
protected.GET("/auth/profile", platform.CurrentProfile)
protected.PUT("/auth/password", platform.ChangePassword)
protected.GET("/dashboard/overview", platform.DashboardOverview)
gasStationGroup := protected.Group("/organization/org_gas_station")
gasStationGroup.POST("", platform.CreateOrgGasStation)
gasStationGroup.GET("", platform.ListOrgGasStation)
protected.GET("/organization/org_delivery_point", platform.ListOrgDeliveryPoint)
protected.GET("/organization/org_service_person", platform.ListOrgServicePerson)
protected.GET("/identity/idn_account", platform.ListIdnAccount)
protected.GET("/safety/saf_event", platform.ListSafEvent)
}
// Register 注册路由。
func Register(serviceKey string, engine *gin.Engine) {
RegisterPlatform(serviceKey, engine)
registerUploadRoute(serviceKey, engine)
}

View File

@@ -0,0 +1,11 @@
package routers
import (
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/upload"
"github.com/gin-gonic/gin"
)
// registerUploadRoute 注册已认证的文件上传接口。
func registerUploadRoute(serviceKey string, engine *gin.Engine) {
engine.POST("/upload/file", upload.UploadFile)
}