package models

type Role struct {
	Id     uint   `gorm:"size:11 primaryKey" json:"role_id"`
	Name   string `gorm:"size:50 not null default:''" json:"role_name"`
	Method string `gorm:"size:128 not null default:''" json:"method"`
	Path   string `gorm:"size:1024 not null default:''" json:"path"`
}

func FindRoles() []Role {
	var roles []Role
	DB.Order("id desc").Find(&roles)
	return roles
}
func FindRole(id interface{}) Role {
	var role Role
	DB.Where("id = ?", id).First(&role)
	return role
}
func SaveRole(id string, name string, method string, path string) {
	role := &Role{
		Method: method,
		Name:   name,
		Path:   path,
	}
	DB.Model(role).Where("id=?", id).Updates(role)
}
