This commit is contained in:
zhangwenjian committed 2020-04-13 00:30:58 +08:00
1 parent f25da5f1ee
commit 1df55e75e5
72 files changed
+1401 -1559

No files matched your search

+70 -83
View File
@@ -3,16 +3,17 @@ package router
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
. "go-admin/apis"
log2 "go-admin/apis/log"
"go-admin/apis/system"
"go-admin/apis/system/dict"
. "go-admin/apis/tools"
_ "go-admin/docs"
"go-admin/handler"
"go-admin/handler/sd"
"go-admin/middleware"
_ "go-admin/pkg/jwtauth"
"go-admin/router/middleware"
"log"
)
@@ -27,7 +28,7 @@ func InitRouter() *gin.Engine {
r.Use(middleware.DemoEvn())
r.Static("/static", "./static")
r.GET("/info", Ping)
r.GET("/info", handler.Ping)
// 监控信息
svcd := r.Group("/sd")
@@ -50,12 +51,11 @@ func InitRouter() *gin.Engine {
// Refresh time can be longer than token timeout
r.GET("/refresh_token", authMiddleware.RefreshHandler)
//r.GET("/dashboard", Dashboard)
r.GET("/routes", Dashboard)
apiv1 := r.Group("/api/v1")
{
apiv1.GET("/getCaptcha", GenerateCaptchaHandler)
apiv1.GET("/getCaptcha", system.GenerateCaptchaHandler)
apiv1.GET("/db/tables/page", GetDBTableList)
apiv1.GET("/db/columns/page", GetDBColumnList)
apiv1.GET("/sys/tables/page", GetSysTableList)
@@ -64,112 +64,99 @@ func InitRouter() *gin.Engine {
apiv1.DELETE("/sys/tables/info/:tableId", DeleteSysTables)
apiv1.GET("/sys/tables/info/:tableId", GetSysTables)
apiv1.GET("/gen/preview/:tableId", Preview)
apiv1.GET("/menuTreeselect", GetMenuTreeelect)
apiv1.GET("/rolemenu", GetRoleMenu)
apiv1.POST("/rolemenu", InsertRoleMenu)
apiv1.DELETE("/rolemenu/:id", DeleteRoleMenu)
apiv1.GET("/dict/databytype/:dictType", GetDictDataByDictType)
apiv1.GET("/menuTreeselect", system.GetMenuTreeelect)
apiv1.GET("/dict/databytype/:dictType", dict.GetDictDataByDictType)
}
auth := r.Group("/api/v1")
auth.Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{
auth.GET("/deptList", GetDeptList)
auth.GET("/deptTree", GetDeptTree)
auth.GET("/dept/:deptId", GetDept)
auth.POST("/dept", InsertDept)
auth.PUT("/dept", UpdateDept)
auth.DELETE("/dept/:id", DeleteDept)
auth.GET("/deptList", system.GetDeptList)
auth.GET("/deptTree", system.GetDeptTree)
auth.GET("/dept/:deptId", system.GetDept)
auth.POST("/dept", system.InsertDept)
auth.PUT("/dept", system.UpdateDept)
auth.DELETE("/dept/:id", system.DeleteDept)
auth.GET("/dict/datalist", GetDictDataList)
auth.GET("/dict/data/:dictCode", GetDictData)
auth.POST("/dict/data", InsertDictData)
auth.PUT("/dict/data/", UpdateDictData)
auth.DELETE("/dict/data/:dictCode", DeleteDictData)
auth.GET("/dict/datalist", dict.GetDictDataList)
auth.GET("/dict/data/:dictCode", dict.GetDictData)
auth.POST("/dict/data", dict.InsertDictData)
auth.PUT("/dict/data/", dict.UpdateDictData)
auth.DELETE("/dict/data/:dictCode", dict.DeleteDictData)
auth.GET("/dict/typelist", GetDictTypeList)
auth.GET("/dict/type/:dictId", GetDictType)
auth.POST("/dict/type", InsertDictType)
auth.PUT("/dict/type", UpdateDictType)
auth.DELETE("/dict/type/:dictId", DeleteDictType)
auth.GET("/dict/typelist", dict.GetDictTypeList)
auth.GET("/dict/type/:dictId", dict.GetDictType)
auth.POST("/dict/type", dict.InsertDictType)
auth.PUT("/dict/type", dict.UpdateDictType)
auth.DELETE("/dict/type/:dictId", dict.DeleteDictType)
auth.GET("/dict/typeoptionselect", GetDictTypeOptionSelect)
auth.GET("/dict/typeoptionselect", dict.GetDictTypeOptionSelect)
auth.GET("/sysUserList", GetSysUserList)
auth.GET("/sysUser/:userId", GetSysUser)
auth.GET("/sysUser/", GetSysUserInit)
auth.POST("/sysUser", InsertSysUser)
auth.PUT("/sysUser", UpdateSysUser)
auth.DELETE("/sysUser/:userId", DeleteSysUser)
auth.GET("/sysUserList", system.GetSysUserList)
auth.GET("/sysUser/:userId", system.GetSysUser)
auth.GET("/sysUser/", system.GetSysUserInit)
auth.POST("/sysUser", system.InsertSysUser)
auth.PUT("/sysUser", system.UpdateSysUser)
auth.DELETE("/sysUser/:userId", system.DeleteSysUser)
auth.GET("/rolelist", GetRoleList)
auth.GET("/role/:roleId", GetRole)
auth.POST("/role", InsertRole)
auth.PUT("/role", UpdateRole)
auth.PUT("/roledatascope", UpdateRoleDataScope)
auth.DELETE("/role/:roleId", DeleteRole)
auth.GET("/rolelist", system.GetRoleList)
auth.GET("/role/:roleId", system.GetRole)
auth.POST("/role", system.InsertRole)
auth.PUT("/role", system.UpdateRole)
auth.PUT("/roledatascope", system.UpdateRoleDataScope)
auth.DELETE("/role/:roleId", system.DeleteRole)
auth.GET("/configList", GetConfigList)
auth.GET("/config/:configId", GetConfig)
auth.POST("/config", InsertConfig)
auth.PUT("/config", UpdateConfig)
auth.DELETE("/config/:configId", DeleteConfig)
auth.GET("/configList", system.GetConfigList)
auth.GET("/config/:configId", system.GetConfig)
auth.POST("/config", system.InsertConfig)
auth.PUT("/config", system.UpdateConfig)
auth.DELETE("/config/:configId", system.DeleteConfig)
auth.GET("/roleMenuTreeselect/:roleId", GetMenuTreeRoleselect)
auth.GET("/roleDeptTreeselect/:roleId", GetDeptTreeRoleselect)
auth.GET("/roleMenuTreeselect/:roleId", system.GetMenuTreeRoleselect)
auth.GET("/roleDeptTreeselect/:roleId", system.GetDeptTreeRoleselect)
auth.GET("/getinfo", GetInfo)
auth.GET("/user/profile", GetSysUserProfile)
auth.POST("/user/avatar", InsetSysUserAvatar)
auth.PUT("/user/pwd", SysUserUpdatePwd)
auth.GET("/getinfo", system.GetInfo)
auth.GET("/user/profile", system.GetSysUserProfile)
auth.POST("/user/avatar", system.InsetSysUserAvatar)
auth.PUT("/user/pwd", system.SysUserUpdatePwd)
auth.GET("/postlist", GetPostList)
auth.GET("/post/:postId", GetPost)
auth.POST("/post", InsertPost)
auth.PUT("/post", UpdatePost)
auth.DELETE("/post/:postId", DeletePost)
auth.GET("/postlist", system.GetPostList)
auth.GET("/post/:postId", system.GetPost)
auth.POST("/post", system.InsertPost)
auth.PUT("/post", system.UpdatePost)
auth.DELETE("/post/:postId", system.DeletePost)
auth.GET("/menulist", GetMenuList)
auth.GET("/menu/:id", GetMenu)
auth.POST("/menu", InsertMenu)
auth.PUT("/menu", UpdateMenu)
auth.DELETE("/menu/:id", DeleteMenu)
auth.GET("/menurole", GetMenuRole)
auth.GET("/menulist", system.GetMenuList)
auth.GET("/menu/:id", system.GetMenu)
auth.POST("/menu", system.InsertMenu)
auth.PUT("/menu", system.UpdateMenu)
auth.DELETE("/menu/:id", system.DeleteMenu)
auth.GET("/menurole", system.GetMenuRole)
auth.GET("/menuids", GetMenuIDS)
auth.GET("/menuids", system.GetMenuIDS)
auth.GET("/loginloglist", GetLoginLogList)
auth.GET("/loginlog/:infoId", GetLoginLog)
auth.POST("/loginlog", InsertLoginLog)
auth.PUT("/loginlog", UpdateLoginLog)
auth.DELETE("/loginlog/:infoId", DeleteLoginLog)
auth.GET("/loginloglist", log2.GetLoginLogList)
auth.GET("/loginlog/:infoId", log2.GetLoginLog)
auth.POST("/loginlog", log2.InsertLoginLog)
auth.PUT("/loginlog", log2.UpdateLoginLog)
auth.DELETE("/loginlog/:infoId", log2.DeleteLoginLog)
auth.GET("/operloglist", GetOperLogList)
auth.GET("/operlog/:operId", GetOperLog)
auth.DELETE("/operlog/:operId", DeleteOperLog)
auth.GET("/operloglist", log2.GetOperLogList)
auth.GET("/operlog/:operId", log2.GetOperLog)
auth.DELETE("/operlog/:operId", log2.DeleteOperLog)
auth.GET("/configKey/:configKey", GetConfigByConfigKey)
auth.GET("/configKey/:configKey", system.GetConfigByConfigKey)
auth.POST("/logout", handler.LogOut)
}
//r.NoRoute(authMiddleware.MiddlewareFunc(), NoFound)
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
log.Println("路由加载成功!")
return r
}
func Ping(c *gin.Context) {
log.Println(viper.GetString(`settings.database.type`))
c.JSON(200, gin.H{
"message": "ok",
})
}
func Dashboard(c *gin.Context) {
var user = make(map[string]interface{})