// 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" "xingjia-management-gateway/controller/v1" "xingjia-management-gateway/route/middleware" _ "xingjia-management-gateway/docs" ) 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) engine.GET("/api/v1/file", c.DownLoad) engine.PUT("/api/v1/token_refresh", c.TokenRefresh) apiv1.Use(middleware.Jwt()) apiv1.POST("/file", c.Upload) //apiv1.GET("/file", c.DownLoad) //apiv1.PUT("/token_refresh", c.TokenRefresh) muser := apiv1.Group("/management_user") { muser.POST("", c.ManagementUserAdd) muser.PUT("/password", c.ManagementUserResetPassword) muser.GET("", c.ManagementUserList) muser.PUT("", c.ManagementUserUpdate) muser.DELETE("", c.ManagementUserDel) } olog := apiv1.Group("/operation_log") { olog.GET("", c.OperationLogList) olog.DELETE("", c.OperationLogDel) } jt := apiv1.Group("/jt") { jt.POST("/desc", c.JtDescAdd) jt.GET("/desc", c.JtDescInfo) jt.PUT("/desc", c.JtDescUpdate) jt.DELETE("/desc", c.JtDescDel) jt.PUT("/desc/publish", c.JtDescPublish) jt.POST("/vision", c.JtVisionAdd) jt.GET("/vision", c.JtVisionInfo) jt.PUT("/vision", c.JtVisionUpdate) jt.DELETE("/vision", c.JtVisionDel) jt.PUT("/vision/publish", c.JtVisionPublish) jt.POST("/news", c.JtNewsAdd) jt.GET("/news", c.JtNewsList) jt.PUT("/news", c.JtNewsUpdate) jt.DELETE("/news", c.JtNewsDel) jt.PUT("/news/publish", c.JtNewsPublish) jt.POST("/announcement", c.JtAnnouncementAdd) jt.GET("/announcement", c.JtAnnouncementList) jt.PUT("/announcement", c.JtAnnouncementUpdate) jt.DELETE("/announcement", c.JtAnnouncementDel) jt.PUT("/announcement/publish", c.JtAnnouncementPublish) jt.POST("/program", c.JtProgramAdd) jt.GET("/program", c.JtProgramList) jt.PUT("/program", c.JtProgramUpdate) jt.DELETE("/program", c.JtProgramDel) jt.PUT("/program/publish", c.JtProgramPublish) jt.POST("/lx", c.JtLxAdd) jt.GET("/lx", c.JtLxList) jt.PUT("/lx", c.JtLxUpdate) jt.DELETE("/lx", c.JtLxDel) jt.PUT("/lx/publish", c.JtLxPublish) jt.POST("/hw", c.JtHwAdd) jt.GET("/hw", c.JtHwList) jt.PUT("/hw", c.JtHwUpdate) jt.DELETE("/hw", c.JtHwDel) jt.PUT("/hw/publish", c.JtHwPublish) jt.POST("/df", c.JtDfAdd) jt.GET("/df", c.JtDfList) jt.PUT("/df", c.JtDfUpdate) jt.DELETE("/df", c.JtDfDel) jt.PUT("/df/publish", c.JtDfPublish) jt.POST("/contact", c.JtContactAdd) jt.GET("/contact", c.JtContactInfo) jt.PUT("/contact", c.JtContactUpdate) jt.DELETE("/contact", c.JtContactDel) jt.POST("/page_pic", c.PagePicAdd) jt.GET("/page_pic", c.PagePicList) jt.PUT("/page_pic", c.PagePicUpdate) jt.DELETE("/page_pic", c.PagePicDel) } } }