nezha/cmd/dashboard/controller/member_page.go

36 lines
730 B
Go
Raw Normal View History

2019-12-08 03:59:58 -05:00
package controller
import (
2019-12-08 10:18:29 -05:00
"net/http"
2019-12-08 03:59:58 -05:00
"github.com/gin-gonic/gin"
2019-12-08 10:18:29 -05:00
"github.com/p14yground/nezha/model"
2019-12-08 03:59:58 -05:00
"github.com/p14yground/nezha/pkg/mygin"
2019-12-08 10:18:29 -05:00
"github.com/p14yground/nezha/service/dao"
2019-12-08 03:59:58 -05:00
)
type memberPage struct {
r *gin.Engine
}
func (mp *memberPage) serve() {
mr := mp.r.Group("")
mr.Use(mygin.Authorize(mygin.AuthorizeOption{
Member: true,
IsPage: true,
Msg: "此页面需要登录",
Btn: "点此登录",
Redirect: "/login",
}))
2019-12-08 10:18:29 -05:00
mr.GET("/server", mp.server)
}
func (mp *memberPage) server(c *gin.Context) {
var servers []model.Server
dao.DB.Find(&servers)
c.HTML(http.StatusOK, "page/server", mygin.CommonEnvironment(c, gin.H{
"Title": "服务器管理",
"Servers": servers,
}))
2019-12-08 03:59:58 -05:00
}