29 lines
494 B
Go
29 lines
494 B
Go
package models
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type User struct {
|
|
gorm.Model
|
|
Username string `gorm:"unique"`
|
|
Password string
|
|
Roles []Role `gorm:"many2many:user_roles;"`
|
|
}
|
|
|
|
type Role struct {
|
|
gorm.Model
|
|
Name string `gorm:"unique"`
|
|
Permissions []Permission `gorm:"many2many:role_permissions;"`
|
|
}
|
|
|
|
type Permission struct {
|
|
gorm.Model
|
|
Name string `gorm:"unique"`
|
|
}
|
|
|
|
type UserGroup struct {
|
|
gorm.Model
|
|
Name string `gorm:"unique"`
|
|
Users []User `gorm:"many2many:user_group_users;"`
|
|
}
|
|
`
|