diff --git a/src/models/board.go b/src/models/board.go index 397e844b..77fc1fc9 100644 --- a/src/models/board.go +++ b/src/models/board.go @@ -71,6 +71,20 @@ func (b *Board) Del() error { }) } +func BoardGetByID(id int64) (*Board, error) { + var lst []*Board + err := DB().Where("id = ?", id).Find(&lst).Error + if err != nil { + return nil, err + } + + if len(lst) == 0 { + return nil, nil + } + + return lst[0], nil +} + // BoardGet for detail page func BoardGet(where string, args ...interface{}) (*Board, error) { var lst []*Board diff --git a/src/webapi/router/router.go b/src/webapi/router/router.go index 27a00106..32bcfd35 100644 --- a/src/webapi/router/router.go +++ b/src/webapi/router/router.go @@ -177,6 +177,7 @@ func configRoute(r *gin.Engine, version string) { pages.POST("/busi-group/:id/board/:bid/clone", auth(), user(), perm("/dashboards/add"), bgrw(), boardClone) pages.GET("/board/:bid", auth(), user(), boardGet) + pages.GET("/board/:bid/pure", boardPureGet) pages.PUT("/board/:bid", auth(), user(), perm("/dashboards/put"), boardPut) pages.PUT("/board/:bid/configs", auth(), user(), perm("/dashboards/put"), boardPutConfigs) pages.DELETE("/boards", auth(), user(), perm("/dashboards/del"), boardDel) diff --git a/src/webapi/router/router_board.go b/src/webapi/router/router_board.go index 4f799d43..e98ebb7a 100644 --- a/src/webapi/router/router_board.go +++ b/src/webapi/router/router_board.go @@ -51,6 +51,17 @@ func boardGet(c *gin.Context) { ginx.NewRender(c).Data(board, nil) } +func boardPureGet(c *gin.Context) { + board, err := models.BoardGetByID(ginx.UrlParamInt64(c, "bid")) + ginx.Dangerous(err) + + if board == nil { + ginx.Bomb(http.StatusNotFound, "No such dashboard") + } + + ginx.NewRender(c).Data(board, nil) +} + // bgrwCheck func boardDel(c *gin.Context) { var f idsForm