Skip to content

Commit

Permalink
fix: edge get all configs
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Oct 21, 2024
1 parent 0ac4bc7 commit 2576a0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions center/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ func (rt *Router) Config(r *gin.Engine) {
service.GET("/config/:id", rt.configGet)
service.GET("/configs", rt.configsGet)
service.GET("/config", rt.configGetByKey)
service.GET("/all-configs", rt.configGetAll)
service.PUT("/configs", rt.configsPut)
service.POST("/configs", rt.configsPost)
service.DELETE("/configs", rt.configsDel)
Expand Down
5 changes: 5 additions & 0 deletions center/router/router_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func (rt *Router) configGet(c *gin.Context) {
ginx.NewRender(c).Data(configs, err)
}

func (rt *Router) configGetAll(c *gin.Context) {
config, err := models.ConfigsGetAll(rt.Ctx)
ginx.NewRender(c).Data(config, err)
}

func (rt *Router) configGetByKey(c *gin.Context) {
config, err := models.ConfigsGet(rt.Ctx, ginx.QueryStr(c, "key"))
ginx.NewRender(c).Data(config, err)
Expand Down
5 changes: 5 additions & 0 deletions models/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func ConfigsGet(ctx *ctx.Context, ckey string) (string, error) { //select built-
}

func ConfigsGetAll(ctx *ctx.Context) ([]*Configs, error) { // select built-in type configs
if !ctx.IsCenter {
lst, err := poster.GetByUrls[[]*Configs](ctx, "/v1/n9e/all-configs")
return lst, err
}

var lst []*Configs
err := DB(ctx).Model(&Configs{}).Select("ckey, cval").
Where("ckey!='' and external=? ", 0).Find(&lst).Error
Expand Down

0 comments on commit 2576a0f

Please sign in to comment.