first
This commit is contained in:
118
http/router/admin.go
Normal file
118
http/router/admin.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
_ "Gwen/docs/admin"
|
||||
"Gwen/http/controller/admin"
|
||||
"Gwen/http/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
)
|
||||
|
||||
func Init(g *gin.Engine) {
|
||||
|
||||
//swagger
|
||||
//g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
g.GET("/admin/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("admin")))
|
||||
|
||||
adg := g.Group("/api/admin")
|
||||
LoginBind(adg)
|
||||
|
||||
adg.Use(middleware.AdminAuth())
|
||||
//FileBind(adg)
|
||||
UserBind(adg)
|
||||
GroupBind(adg)
|
||||
TagBind(adg)
|
||||
AddressBookBind(adg)
|
||||
PeerBind(adg)
|
||||
|
||||
rs := &admin.Rustdesk{}
|
||||
adg.GET("/server-config", rs.ServerConfig)
|
||||
|
||||
//访问静态文件
|
||||
//g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/upload"))
|
||||
}
|
||||
func LoginBind(rg *gin.RouterGroup) {
|
||||
cont := &admin.Login{}
|
||||
rg.POST("/login", cont.Login)
|
||||
rg.POST("/logout", cont.Logout)
|
||||
}
|
||||
|
||||
func UserBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/user")
|
||||
{
|
||||
cont := &admin.User{}
|
||||
aR.GET("/current", cont.Current)
|
||||
aR.POST("/changeCurPwd", cont.ChangeCurPwd)
|
||||
}
|
||||
aRP := rg.Group("/user").Use(middleware.AdminPrivilege())
|
||||
{
|
||||
cont := &admin.User{}
|
||||
aRP.GET("/list", cont.List)
|
||||
aRP.GET("/detail/:id", cont.Detail)
|
||||
aRP.POST("/create", cont.Create)
|
||||
aRP.POST("/update", cont.Update)
|
||||
aRP.POST("/delete", cont.Delete)
|
||||
aRP.POST("/changePwd", cont.UpdatePassword)
|
||||
}
|
||||
}
|
||||
|
||||
func GroupBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/group").Use(middleware.AdminPrivilege())
|
||||
{
|
||||
cont := &admin.Group{}
|
||||
aR.GET("/list", cont.List)
|
||||
aR.GET("/detail/:id", cont.Detail)
|
||||
aR.POST("/create", cont.Create)
|
||||
aR.POST("/update", cont.Update)
|
||||
aR.POST("/delete", cont.Delete)
|
||||
}
|
||||
}
|
||||
|
||||
func TagBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/tag")
|
||||
{
|
||||
cont := &admin.Tag{}
|
||||
aR.GET("/list", cont.List)
|
||||
aR.GET("/detail/:id", cont.Detail)
|
||||
aR.POST("/create", cont.Create)
|
||||
aR.POST("/update", cont.Update)
|
||||
aR.POST("/delete", cont.Delete)
|
||||
}
|
||||
}
|
||||
|
||||
func AddressBookBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/address_book")
|
||||
{
|
||||
cont := &admin.AddressBook{}
|
||||
aR.GET("/list", cont.List)
|
||||
aR.GET("/detail/:id", cont.Detail)
|
||||
aR.POST("/create", cont.Create)
|
||||
aR.POST("/update", cont.Update)
|
||||
aR.POST("/delete", cont.Delete)
|
||||
}
|
||||
}
|
||||
func PeerBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/peer")
|
||||
{
|
||||
cont := &admin.Peer{}
|
||||
aR.GET("/list", cont.List)
|
||||
aR.GET("/detail/:id", cont.Detail)
|
||||
aR.POST("/create", cont.Create)
|
||||
aR.POST("/update", cont.Update)
|
||||
aR.POST("/delete", cont.Delete)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func FileBind(rg *gin.RouterGroup) {
|
||||
aR := rg.Group("/file")
|
||||
{
|
||||
cont := &admin.File{}
|
||||
aR.POST("/notify", cont.Notify)
|
||||
aR.OPTIONS("/oss_token", nil)
|
||||
aR.OPTIONS("/upload", nil)
|
||||
aR.GET("/oss_token", cont.OssToken)
|
||||
aR.POST("/upload", cont.Upload)
|
||||
}
|
||||
}*/
|
||||
73
http/router/api.go
Normal file
73
http/router/api.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
_ "Gwen/docs/api"
|
||||
"Gwen/global"
|
||||
"Gwen/http/controller/api"
|
||||
"Gwen/http/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ApiInit(g *gin.Engine) {
|
||||
|
||||
//g.Use(middleware.Cors())
|
||||
//swagger
|
||||
g.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.InstanceName("api")))
|
||||
|
||||
frg := g.Group("/api")
|
||||
|
||||
frg.Use(middleware.Cors())
|
||||
frg.OPTIONS("/*any", nil)
|
||||
|
||||
i := &api.Index{}
|
||||
frg.GET("/", i.Index)
|
||||
|
||||
frg.POST("/heartbeat", i.Heartbeat)
|
||||
|
||||
{
|
||||
l := &api.Login{}
|
||||
// 如果返回oidc则可以通过oidc登录
|
||||
frg.GET("/login-options", l.LoginOptions)
|
||||
frg.POST("/login", l.Login)
|
||||
|
||||
}
|
||||
{
|
||||
pe := &api.Peer{}
|
||||
//提交系统信息
|
||||
frg.POST("/sysinfo", pe.SysInfo)
|
||||
}
|
||||
frg.Use(middleware.RustAuth())
|
||||
{
|
||||
w := &api.WebClient{}
|
||||
frg.POST("/server-config", w.ServerConfig)
|
||||
}
|
||||
|
||||
{
|
||||
u := &api.User{}
|
||||
frg.GET("/user/info", u.Info)
|
||||
frg.POST("/currentUser", u.Info)
|
||||
}
|
||||
{
|
||||
l := &api.Login{}
|
||||
frg.POST("/logout", l.Logout)
|
||||
}
|
||||
{
|
||||
gr := &api.Group{}
|
||||
frg.GET("/users", gr.Users)
|
||||
frg.GET("/peers", gr.Peers)
|
||||
}
|
||||
|
||||
{
|
||||
ab := &api.Ab{}
|
||||
//获取地址
|
||||
frg.GET("/ab", ab.Ab)
|
||||
//更新地址
|
||||
frg.POST("/ab", ab.UpAb)
|
||||
}
|
||||
|
||||
//访问静态文件
|
||||
g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/public/upload"))
|
||||
}
|
||||
15
http/router/router.go
Normal file
15
http/router/router.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"Gwen/global"
|
||||
"Gwen/http/controller/web"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func WebInit(g *gin.Engine) {
|
||||
i := &web.Index{}
|
||||
g.GET("/webclient-config/index.js", i.ConfigJs)
|
||||
g.StaticFS("/webclient", http.Dir(global.Config.Gin.ResourcesPath+"/web"))
|
||||
g.StaticFS("/_admin", http.Dir(global.Config.Gin.ResourcesPath+"/admin"))
|
||||
}
|
||||
Reference in New Issue
Block a user