package api import ( "fmt" "github.com/gin-gonic/gin" ) // RegRouters 注册路由 func RegRouters(svc *Service) { //登录 spud3dGroup := svc.NewGinRouter("/" + svc.Conf.Name) spud3dGroup.group.Use(Logger()) spud3dGroup.GET("/profile", AssetProfile) spud3dGroup.POST("/import", AssetImport) spud3dGroup.POST("/clean", AssetClean) //数据存储 spud3dGroup.POST("/save/policy", UploadPolicy) // spud3dGroup.GETJWT("/obs/list", ServiceObsList) // spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy) // spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove) // spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder) //minio //spud3dGroup.POSTJWT("/minio/policy", MinioCreateUserPolicy) //资产列表管理 CreateAssetRouter(spud3dGroup) // CreateUserUploadRouter(spud3dGroup) // CreateLibRouter(spud3dGroup) //数据库管理 CreateDatabaseRouter(spud3dGroup) //资产定义路由 CreateDatabaseAssetConfRouter(spud3dGroup) // !20240415更新 获取queenter库material详情,如果本地不存在则创建 // 适配queenter库 spud3dGroup.GETJWT("/queenter/materialGroup/detail", DbMaterialDetail) //资产上传更新管理 CreateDatabaseAssetRouter(spud3dGroup) //分类管理 CreateDatabaseCategoryRouter(spud3dGroup) CreateDatabaseDesignRouter(spud3dGroup) CreateDatabaseDesignProductRouter(spud3dGroup) CreateDatabaseDesignSceneRouter(spud3dGroup) // test TestRouter(spud3dGroup) Move(spud3dGroup) } func Logger() gin.HandlerFunc { return func(c *gin.Context) { // 开始时间 // start := time.Now() // 处理请求 c.Next() // 结束时间 // end := time.Now() //执行时间 // latency := end.Sub(start) path := c.Request.URL.Path clientIP := c.ClientIP() // method := c.Request.Method // statusCode := c.Writer.Status() out := fmt.Sprintf("%15s=> %s", clientIP, path) fmt.Println(out) } }