package role

import (
	"github.com/veypi/vbase/cfg"
	"github.com/veypi/vbase/models"
	"github.com/veypi/vigo"
)

type GetReq struct {
	ID string `src:"path@id" desc:"Role ID"`
}

func get(x *vigo.X, req *GetReq) (*models.Role, error) {
	var role models.Role
	if err := cfg.DB().First(&role, "id = ?", req.ID).Error; err != nil {
		return nil, vigo.ErrNotFound
	}
	return &role, nil
}
