You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/api/app/access/get.go

31 lines
645 B
Go

10 months ago
//
// get.go
// Copyright (C) 2024 veypi <i@veypi.com>
// Distributed under terms of the MIT license.
//
package access
import (
10 months ago
"github.com/veypi/OneAuth/cfg"
"github.com/veypi/OneAuth/models"
7 months ago
"github.com/vyes-ai/vigo"
10 months ago
)
type getIDReq struct {
ID string `src:"path@id" desc:"记录ID"`
}
10 months ago
var _ = Router.Get("/{id}", "获取访问权限详情", getAccess)
10 months ago
func getAccess(x *vigo.X, req *getIDReq) (*models.Access, error) {
10 months ago
// 查询数据库
var access models.Access
err := cfg.DB().Where("id = ?", req.ID).First(&access).Error
10 months ago
if err != nil {
return nil, vigo.NewError("未找到资源").WithCode(404)
10 months ago
}
return &access, nil
}