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.
32 lines
795 B
Go
32 lines
795 B
Go
package app_user
|
|
|
|
import (
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
"github.com/vyes-ai/vigo"
|
|
)
|
|
|
|
type deleteOpts struct {
|
|
AppID string `parse:"path@app_id"`
|
|
UserID string `parse:"path@user_id"`
|
|
}
|
|
|
|
var _ = Router.Delete("/{user_id}", "删除应用用户", deleteAppUser)
|
|
|
|
func deleteAppUser(x *vigo.X, opts *deleteOpts) (any, error) {
|
|
appUser := &models.AppUser{}
|
|
if err := cfg.DB().Where("app_id = ? AND user_id = ?", opts.AppID, opts.UserID).First(appUser).Error; err != nil {
|
|
return nil, vigo.NewError("app_user not found").WithCode(404)
|
|
}
|
|
|
|
if err := cfg.DB().Delete(appUser).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return map[string]interface{}{
|
|
"message": "app_user deleted successfully",
|
|
"app_id": opts.AppID,
|
|
"user_id": opts.UserID,
|
|
}, nil
|
|
}
|