Skip to content

Commit

Permalink
1234
Browse files Browse the repository at this point in the history
  • Loading branch information
zgwit committed Oct 30, 2024
1 parent c11b4f7 commit 7263536
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import "github.com/god-jason/bucket/table"

// 表相关接口只能放这里了,否则会import circle: api->table->api
func init() {

Register("GET", "table/list", table.ApiList)
Register("GET", "table/:table/file/:file", table.ApiManifest)
Register("POST", "table/:table/file/:file", table.ApiManifestUpdate)

Register("POST", "table/:table/count", table.ApiCount)
Register("POST", "table/:table/create", table.ApiCreate)
Register("POST", "table/:table/update/:id", table.ApiUpdate)
Expand All @@ -13,6 +18,4 @@ func init() {
Register("POST", "table/:table/search", table.ApiSearch)
Register("POST", "table/:table/import", table.ApiImport)
Register("POST", "table/:table/export", table.ApiExport)
Register("GET", "table/:table", table.ApiManifest)
Register("POST", "table/:table", table.ApiManifestUpdate)
}
34 changes: 34 additions & 0 deletions table/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,40 @@ import (
"path/filepath"
)

type Info struct {
Name string `json:"name,omitempty"`
Label string `json:"label,omitempty"`
Fields int `json:"fields,omitempty"`
Schema bool `json:"schema,omitempty"`
Scripts int `json:"scripts,omitempty"`
Accumulations int `json:"accumulations,omitempty"`
TimeSeries bool `json:"time_series,omitempty"`
Snapshot bool `json:"snapshot,omitempty"`
}

func ApiList(ctx *gin.Context) {

var infos []*Info

tables.Range(func(name string, tab *Table) bool {
infos = append(infos, &Info{
Name: tab.Name,
Label: tab.Name,
Fields: len(tab.Fields),
Schema: tab.Schema != nil,
Scripts: len(tab.Scripts),
Accumulations: len(tab.Accumulations),
TimeSeries: tab.TimeSeries != nil,
Snapshot: tab.Snapshot != nil,
})
return true
})

//TODO 加入空间统计等

OK(ctx, infos)
}

func ApiManifest(ctx *gin.Context) {
tab := ctx.Param("table")
fn := filepath.Join(viper.GetString("data"), Path, tab+".json")
Expand Down
7 changes: 7 additions & 0 deletions table/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package table

import "github.com/gin-gonic/gin"

func ApiStats(ctx *gin.Context) {
//
}

0 comments on commit 7263536

Please sign in to comment.