// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package route import ( "net/http" "github.com/gin-gonic/gin" "cp-system-management-gateway/controller/v1" _ "cp-system-management-gateway/docs" "cp-system-management-gateway/route/middleware" ) func SetupRoute(engine *gin.Engine) { // 404页面 engine.NoRoute(func(c *gin.Context) { c.String(http.StatusNotFound, "Not Found") }) // 服务健康检查 engine.GET("/ping", func(c *gin.Context) { // TODO 心跳检查 c.String(http.StatusOK, "pong") }) //engine.Use(middleware.Session("smart-site-supplier")) // version 1 apiv1 := engine.Group("/api/v1") { c := v1.NewController() engine.POST("/api/v1/user/login", c.Login) apiv1.PUT("/token_refresh", c.TokenRefresh) apiv1.Use(middleware.Jwt()) user := apiv1.Group("/user") { user.PUT("/password", c.ResetePasswd) } organization := apiv1.Group("/organization") { organization.POST("", c.CreateOrganization) organization.PUT("", c.UpdateOrganization) organization.GET("/list", c.OrganizationList) organization.POST("/user", c.CreateOrganizationUser) organization.PUT("/user", c.OrganizationUserUpdate) //organization.PUT("/user_password", c.OrganizationUserResetPassword) organization.GET("/user_list", c.OrganizationUserList) } operationLog := apiv1.Group("/log") { operationLog.GET("/list", c.SystemLogList) } } }