//
// del.go
// Copyright (C) 2025 veypi <i@veypi.com>
// 2025-05-06 15:24
// Distributed under terms of the MIT license.
//

package role

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

type deleteIDReq struct {
	ID string `src:"path@id" desc:"记录ID"`
}

var _ = Router.Delete("/{id}", "删除用户角色", userRoleDelete)

func userRoleDelete(x *vigo.X, req *deleteIDReq) (*models.UserRole, error) {
	data := &models.UserRole{}
	err := cfg.DB().Where("id = ?", req.ID).Delete(data).Error
	return data, err
}
