Skip to content

Commit

Permalink
[U] 统计信息go
Browse files Browse the repository at this point in the history
  • Loading branch information
zxysilent committed Apr 22, 2021
1 parent 1019266 commit d653e47
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 38 deletions.
17 changes: 0 additions & 17 deletions control/appctl/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"time"

"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -45,22 +44,6 @@ func Upload(ctx echo.Context) error {
return ctx.JSON(utils.Succ(`文件上传成功`, "/"+filePathName))
}

// Sys 系统信息
func Sys(ctx echo.Context) error {
state := struct {
ARCH string `json:"arch"`
OS string `json:"os"`
Version string `json:"version"`
NumCPU int `json:"num_cpu"`
}{
ARCH: runtime.GOARCH,
OS: runtime.GOOS,
Version: runtime.Version(),
NumCPU: runtime.NumCPU(),
}
return ctx.JSON(utils.Succ(`系统信息`, state))
}

// Collect 统计信息
func Collect(ctx echo.Context) error {
if mod, has := model.Collect(); has {
Expand Down
24 changes: 24 additions & 0 deletions control/sysctl/sysctl.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
package sysctl

import (
"blog/model"
"runtime"

"github.com/labstack/echo/v4"
"github.com/zxysilent/utils"
)

// StatusGoinfo doc
// @Tags status
// @Summary 获取服务器go信息
// @Param token query string true "token"
// @Success 200 {object} model.Reply{data=model.Goinfo} "成功数据"
// @Router /adm/status/goinfo [get]
func StatusGoinfo(ctx echo.Context) error {
mod := model.Goinfo{
ARCH: runtime.GOARCH,
OS: runtime.GOOS,
Version: runtime.Version(),
NumCPU: runtime.NumCPU(),
}
return ctx.JSON(utils.Succ("系统信息", mod))
}

// 上传 下载相关
9 changes: 9 additions & 0 deletions model/sys_app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package model

// Goinfo go information
type Goinfo struct {
ARCH string `json:"arch"`
OS string `json:"os"`
Version string `json:"version"`
NumCPU int `json:"num_cpu"`
}
34 changes: 17 additions & 17 deletions router/router_adm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import (

// admRouter 登录访问
func admRouter(adm *echo.Group) {
adm.GET("/auth/get", sysctl.AuthGet) // 获取当前信息
adm.GET("/auth/api", sysctl.AuthGet) // 获取当前接口
adm.GET("/auth/menu", sysctl.AuthMenu) // 获取当前导航
adm.POST("/auth/edit", sysctl.AuthEdit) // 修改自己信息
adm.POST("/auth/passwd", sysctl.AuthPasswd) // 修改自己密码
adm.GET("/sys", appctl.Sys) // 服务器信息
adm.GET("/collect", appctl.Collect) // 统计信息
adm.POST("/upload", appctl.Upload) // 图片上传
adm.GET("/cate/drop/:id", appctl.CateDrop) // 删除分类
adm.POST("/cate/add", appctl.CateAdd) // 添加分类
adm.POST("/cate/edit", appctl.CateEdit) // 编辑分类
adm.POST("/post/opts", appctl.PostOpts) // 文章/页面-编辑/添加
adm.GET("/post/drop/:id", appctl.PostDrop) // 删除文章/页面
adm.GET("/tag/drop/:id", appctl.TagDrop) // 删除标签
adm.POST("/tag/add", appctl.TagAdd) // 添加标签
adm.POST("/tag/edit", appctl.TagEdit) // 编辑标签
adm.POST("/opts/edit", appctl.OptsEdit) // 编辑配置
adm.GET("/auth/get", sysctl.AuthGet) // 获取当前信息
adm.GET("/auth/api", sysctl.AuthGet) // 获取当前接口
adm.GET("/auth/menu", sysctl.AuthMenu) // 获取当前导航
adm.POST("/auth/edit", sysctl.AuthEdit) // 修改自己信息
adm.POST("/auth/passwd", sysctl.AuthPasswd) // 修改自己密码
adm.GET("/status/goinfo", sysctl.StatusGoinfo) // 服务器信息
adm.GET("/collect", appctl.Collect) // 统计信息
adm.POST("/upload", appctl.Upload) // 图片上传
adm.GET("/cate/drop/:id", appctl.CateDrop) // 删除分类
adm.POST("/cate/add", appctl.CateAdd) // 添加分类
adm.POST("/cate/edit", appctl.CateEdit) // 编辑分类
adm.POST("/post/opts", appctl.PostOpts) // 文章/页面-编辑/添加
adm.GET("/post/drop/:id", appctl.PostDrop) // 删除文章/页面
adm.GET("/tag/drop/:id", appctl.TagDrop) // 删除标签
adm.POST("/tag/add", appctl.TagAdd) // 添加标签
adm.POST("/tag/edit", appctl.TagEdit) // 编辑标签
adm.POST("/opts/edit", appctl.OptsEdit) // 编辑配置

// sysctl
{ // role
Expand Down
4 changes: 2 additions & 2 deletions vue/src/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ export const admCollect = () => {
return fetch.get("/adm/collect");
};
// 服务器信息
export const admSys = () => {
return fetch.get("/adm/sys");
export const admStatusGoinfo = () => {
return fetch.get("/adm/status/goinfo");
};
4 changes: 2 additions & 2 deletions vue/src/views/home/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</div>
</template>
<script>
import { admSys, admCollect } from "@/api/auth";
import { admStatusGoinfo, admCollect } from "@/api/auth";
export default {
data() {
return {
Expand All @@ -115,7 +115,7 @@ export default {
},
methods: {
init() {
admSys().then(resp => {
admStatusGoinfo().then(resp => {
if (resp.code == 200) {
this.sys = resp.data;
} else {
Expand Down

0 comments on commit d653e47

Please sign in to comment.