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/app_user/get.go

27 lines
577 B
Go

package app_user
import (
"github.com/veypi/OneBD/rest"
"oa/models"
"oa/cfg"
)
var _ = Router.Get("/:user_id", getAppUser)
func getAppUser(x *rest.X) (any, error) {
appID := x.Params.Get("app_id")
userID := x.Params.Get("user_id")
if appID == "" || userID == "" {
return nil, rest.NewError("app_id or user_id is empty").WithCode(400)
}
appUser := &models.AppUser{}
err := cfg.DB().Where("app_id = ? AND user_id = ?", appID, userID).First(appUser).Error
if err != nil {
return nil, rest.NewError("app_user not found").WithCode(404)
}
return appUser, nil
}