Otfe/models/group.go

51 lines
783 B
Go

package models
import (
"github.com/jinzhu/gorm"
)
//Group type
type Group struct {
gorm.Model
Name string
Permissions map[string]bool
Admin bool
Users []string
}
func NewGroup(Name string) Group {
var group Group
group.Permissions = make(map[string]bool)
return group
}
//Create group
func (g *Group) Create() error {
return create(&g)
}
//Read group
func (g *Group) Read() error {
return read(&g)
}
//ReadAll groups
func (g *Group) ReadAll() ([]Group, error) {
var groups []Group
var err error
err = readAll(&groups)
return groups, err
}
//Update group
func (g *Group) Update() error {
return update(&g)
}
//Delete group
func (g *Group) Delete() error {
err := delete(&g)
return err
}