mirror of https://github.com/veypi/OneAuth.git
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.
33 lines
642 B
Go
33 lines
642 B
Go
//
|
|
// get.go
|
|
// Copyright (C) 2024 veypi <i@veypi.com>
|
|
// Distributed under terms of the MIT license.
|
|
//
|
|
|
|
package access
|
|
|
|
import (
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
"github.com/vyes/vigo"
|
|
)
|
|
|
|
var _ = Router.Get("/:id", getAccess)
|
|
|
|
func getAccess(x *vigo.X) (any, error) {
|
|
// 获取路径参数
|
|
id := x.Params.Get("id")
|
|
if id == "" {
|
|
return nil, vigo.NewError("ID不能为空").WithCode(400)
|
|
}
|
|
|
|
// 查询数据库
|
|
var access models.Access
|
|
err := cfg.DB().Where("id = ?", id).First(&access).Error
|
|
if err != nil {
|
|
return nil, vigo.NewError("未找到资源").WithCode(404)
|
|
}
|
|
|
|
return &access, nil
|
|
}
|