router.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package api
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // RegRouters 注册路由
  7. func RegRouters(svc *Service) {
  8. //登录
  9. spud3dGroup := svc.NewGinRouter("/" + svc.Conf.Name)
  10. spud3dGroup.group.Use(Logger())
  11. spud3dGroup.GET("/profile", AssetProfile)
  12. spud3dGroup.POST("/import", AssetImport)
  13. spud3dGroup.POST("/clean", AssetClean)
  14. //数据存储
  15. spud3dGroup.POST("/save/policy", UploadPolicy)
  16. // spud3dGroup.GETJWT("/obs/list", ServiceObsList)
  17. // spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy)
  18. // spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove)
  19. // spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder)
  20. //minio
  21. //spud3dGroup.POSTJWT("/minio/policy", MinioCreateUserPolicy)
  22. //资产列表管理
  23. CreateAssetRouter(spud3dGroup)
  24. // CreateUserUploadRouter(spud3dGroup)
  25. // CreateLibRouter(spud3dGroup)
  26. //数据库管理
  27. CreateDatabaseRouter(spud3dGroup)
  28. //资产定义路由
  29. CreateDatabaseAssetConfRouter(spud3dGroup)
  30. // !20240415更新 获取queenter库material详情,如果本地不存在则创建
  31. // 适配queenter库
  32. spud3dGroup.GETJWT("/queenter/materialGroup/detail", DbMaterialDetail)
  33. //资产上传更新管理
  34. CreateDatabaseAssetRouter(spud3dGroup)
  35. //分类管理
  36. CreateDatabaseCategoryRouter(spud3dGroup)
  37. CreateDatabaseDesignRouter(spud3dGroup)
  38. CreateDatabaseDesignProductRouter(spud3dGroup)
  39. CreateDatabaseDesignSceneRouter(spud3dGroup)
  40. // test
  41. TestRouter(spud3dGroup)
  42. Move(spud3dGroup)
  43. }
  44. func Logger() gin.HandlerFunc {
  45. return func(c *gin.Context) {
  46. // 开始时间
  47. // start := time.Now()
  48. // 处理请求
  49. c.Next()
  50. // 结束时间
  51. // end := time.Now()
  52. //执行时间
  53. // latency := end.Sub(start)
  54. path := c.Request.URL.Path
  55. clientIP := c.ClientIP()
  56. // method := c.Request.Method
  57. // statusCode := c.Writer.Status()
  58. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  59. fmt.Println(out)
  60. }
  61. }