// // get.go // Copyright (C) 2024 veypi // Distributed under terms of the MIT license. // package access import ( "github.com/veypi/OneBD/rest" "github.com/veypi/OneAuth/cfg" "github.com/veypi/OneAuth/models" ) var _ = Router.Get("/:id", getAccess) func getAccess(x *rest.X) (any, error) { // 获取路径参数 id := x.Params.Get("id") if id == "" { return nil, rest.NewError("ID不能为空").WithCode(400) } // 查询数据库 var access models.Access err := cfg.DB().Where("id = ?", id).First(&access).Error if err != nil { return nil, rest.NewError("未找到资源").WithCode(404) } return &access, nil }