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.
25 lines
543 B
Go
25 lines
543 B
Go
package resource
|
|
|
|
import (
|
|
"github.com/vyes-ai/vigo"
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
)
|
|
|
|
type getIDReq struct {
|
|
ID string `parse:"path@resource_id"`
|
|
}
|
|
|
|
var _ = Router.Get("/{resource_id}", "获取资源详情", getResource)
|
|
|
|
func getResource(x *vigo.X, req *getIDReq) (any, error) {
|
|
// 查询数据库
|
|
resource := &models.Resource{}
|
|
err := cfg.DB().Where("id = ?", req.ID).First(resource).Error
|
|
if err != nil {
|
|
return nil, vigo.NewError("resource not found").WithCode(404)
|
|
}
|
|
|
|
return resource, nil
|
|
}
|