97 lines
3.4 KiB
Go
97 lines
3.4 KiB
Go
|
|
package admin
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/gothinkster/golang-gin-realworld-example-app/middleware"
|
||
|
|
)
|
||
|
|
|
||
|
|
// RegisterRoutes mounts all /api/admin/* routes onto the provided parent group.
|
||
|
|
// Call this BEFORE v1.Use(AuthMiddleware) in main.go so auth is applied here only.
|
||
|
|
func RegisterRoutes(v1 *gin.RouterGroup) {
|
||
|
|
g := v1.Group("/admin")
|
||
|
|
g.Use(middleware.AuthMiddleware(true), middleware.RequireAdmin())
|
||
|
|
{
|
||
|
|
// P0 — Assets
|
||
|
|
g.GET("/assets", ListAssets)
|
||
|
|
g.GET("/assets/:id", GetAsset)
|
||
|
|
g.POST("/assets", CreateAsset)
|
||
|
|
g.PUT("/assets/:id", UpdateAsset)
|
||
|
|
g.DELETE("/assets/:id", DeleteAsset)
|
||
|
|
|
||
|
|
// P0 — Asset Custody
|
||
|
|
g.GET("/asset-custody", ListAssetCustody)
|
||
|
|
g.GET("/asset-custody/:id", GetAssetCustody)
|
||
|
|
g.POST("/asset-custody", CreateAssetCustody)
|
||
|
|
g.PUT("/asset-custody/:id", UpdateAssetCustody)
|
||
|
|
g.DELETE("/asset-custody/:id", DeleteAssetCustody)
|
||
|
|
|
||
|
|
// P0 — Asset Audit Reports
|
||
|
|
g.GET("/asset-audit-reports", ListAssetAuditReports)
|
||
|
|
g.GET("/asset-audit-reports/:id", GetAssetAuditReport)
|
||
|
|
g.POST("/asset-audit-reports", CreateAssetAuditReport)
|
||
|
|
g.PUT("/asset-audit-reports/:id", UpdateAssetAuditReport)
|
||
|
|
g.DELETE("/asset-audit-reports/:id", DeleteAssetAuditReport)
|
||
|
|
|
||
|
|
// P1 — Points Rules
|
||
|
|
g.GET("/points-rules", ListPointsRules)
|
||
|
|
g.GET("/points-rules/:id", GetPointsRule)
|
||
|
|
g.POST("/points-rules", CreatePointsRule)
|
||
|
|
g.PUT("/points-rules/:id", UpdatePointsRule)
|
||
|
|
g.DELETE("/points-rules/:id", DeletePointsRule)
|
||
|
|
|
||
|
|
// P1 — Seasons
|
||
|
|
g.GET("/seasons", ListSeasons)
|
||
|
|
g.GET("/seasons/:id", GetSeason)
|
||
|
|
g.POST("/seasons", CreateSeason)
|
||
|
|
g.PUT("/seasons/:id", UpdateSeason)
|
||
|
|
g.DELETE("/seasons/:id", DeleteSeason)
|
||
|
|
|
||
|
|
// P1 — VIP Tiers
|
||
|
|
g.GET("/vip-tiers", ListVIPTiers)
|
||
|
|
g.GET("/vip-tiers/:id", GetVIPTier)
|
||
|
|
g.POST("/vip-tiers", CreateVIPTier)
|
||
|
|
g.PUT("/vip-tiers/:id", UpdateVIPTier)
|
||
|
|
g.DELETE("/vip-tiers/:id", DeleteVIPTier)
|
||
|
|
|
||
|
|
// P2 — Users (list + edit only)
|
||
|
|
g.GET("/users", ListUsers)
|
||
|
|
g.GET("/users/:wallet", GetUser)
|
||
|
|
g.PUT("/users/:wallet", UpdateUser)
|
||
|
|
|
||
|
|
// P2 — Invite Codes
|
||
|
|
g.GET("/invite-codes", ListInviteCodes)
|
||
|
|
g.PATCH("/invite-codes/:id", UpdateInviteCode)
|
||
|
|
g.PUT("/invite-codes/:id/toggle", ToggleInviteCode)
|
||
|
|
|
||
|
|
// P3 — Product Links (per-asset links on product detail page)
|
||
|
|
g.GET("/product-links", ListProductLinks)
|
||
|
|
g.GET("/product-links/:id", GetProductLink)
|
||
|
|
g.POST("/product-links", CreateProductLink)
|
||
|
|
g.PUT("/product-links/:id", UpdateProductLink)
|
||
|
|
g.DELETE("/product-links/:id", DeleteProductLink)
|
||
|
|
|
||
|
|
// System Contracts (central infrastructure contract registry)
|
||
|
|
g.GET("/system-contracts", ListSystemContracts)
|
||
|
|
g.GET("/system-contracts/:id", GetSystemContract)
|
||
|
|
g.POST("/system-contracts", CreateSystemContract)
|
||
|
|
g.PUT("/system-contracts/:id", UpdateSystemContract)
|
||
|
|
g.DELETE("/system-contracts/:id", DeleteSystemContract)
|
||
|
|
|
||
|
|
// File Upload
|
||
|
|
g.POST("/upload", UploadFile)
|
||
|
|
g.DELETE("/upload", DeleteUploadedFile)
|
||
|
|
|
||
|
|
// Liquidation Bot
|
||
|
|
g.GET("/liquidation/status", GetLiquidationStatus)
|
||
|
|
g.POST("/liquidation/start", StartLiquidationBot)
|
||
|
|
g.POST("/liquidation/stop", StopLiquidationBot)
|
||
|
|
g.GET("/liquidation/records", ListLiquidationRecords)
|
||
|
|
|
||
|
|
// Collateral Buyer Bot
|
||
|
|
g.GET("/buyer/status", GetBuyerBotStatus)
|
||
|
|
g.POST("/buyer/start", StartBuyerBot)
|
||
|
|
g.POST("/buyer/stop", StopBuyerBot)
|
||
|
|
g.GET("/buyer/records", ListBuyRecords)
|
||
|
|
}
|
||
|
|
}
|