route.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package route
  4. import (
  5. "net/http"
  6. "github.com/gin-gonic/gin"
  7. "cp-system-management-gateway/controller/v1"
  8. _ "cp-system-management-gateway/docs"
  9. "cp-system-management-gateway/route/middleware"
  10. )
  11. func SetupRoute(engine *gin.Engine) {
  12. // 404页面
  13. engine.NoRoute(func(c *gin.Context) {
  14. c.String(http.StatusNotFound, "Not Found")
  15. })
  16. // 服务健康检查
  17. engine.GET("/ping", func(c *gin.Context) {
  18. // TODO 心跳检查
  19. c.String(http.StatusOK, "pong")
  20. })
  21. //engine.Use(middleware.Session("smart-site-supplier"))
  22. // version 1
  23. apiv1 := engine.Group("/api/v1")
  24. {
  25. c := v1.NewController()
  26. engine.POST("/api/v1/user/login", c.Login)
  27. apiv1.PUT("/token_refresh", c.TokenRefresh)
  28. apiv1.Use(middleware.Jwt())
  29. user := apiv1.Group("/user")
  30. {
  31. user.PUT("/password", c.ResetePasswd)
  32. }
  33. organization := apiv1.Group("/organization")
  34. {
  35. organization.POST("", c.CreateOrganization)
  36. organization.PUT("", c.UpdateOrganization)
  37. organization.GET("/list", c.OrganizationList)
  38. organization.POST("/user", c.CreateOrganizationUser)
  39. organization.PUT("/user", c.OrganizationUserUpdate)
  40. //organization.PUT("/user_password", c.OrganizationUserResetPassword)
  41. organization.GET("/user_list", c.OrganizationUserList)
  42. }
  43. operationLog := apiv1.Group("/log")
  44. {
  45. operationLog.GET("/list", c.SystemLogList)
  46. }
  47. }
  48. }