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/create.go

35 lines
590 B
Go

package app_user
import (
"github.com/veypi/OneBD/rest"
"oa/models"
"oa/cfg"
)
type createOpts struct {
AppID string `parse:"path"`
UserID string `json:"user_id"`
Status string `json:"status" default:"ok"`
}
var _ = Router.Post("/", createAppUser)
func createAppUser(x *rest.X) (any, error) {
opts := &createOpts{}
if err := x.Parse(opts); err != nil {
return nil, err
}
appUser := &models.AppUser{
AppID: opts.AppID,
UserID: opts.UserID,
Status: opts.Status,
}
if err := cfg.DB().Create(appUser).Error; err != nil {
return nil, err
}
return appUser, nil
}