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.
35 lines
590 B
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
|
|
}
|