Improve model and add roles
This commit is contained in:
parent
488da64ccf
commit
3e984d059c
5 changed files with 32 additions and 38 deletions
|
|
@ -37,11 +37,10 @@ func connectDatabase() (*gorm.DB, error) {
|
||||||
|
|
||||||
err = database.AutoMigrate(
|
err = database.AutoMigrate(
|
||||||
&models.User{},
|
&models.User{},
|
||||||
&models.ParentSection{},
|
|
||||||
&models.Section{},
|
&models.Section{},
|
||||||
|
&models.Role{},
|
||||||
|
&models.UserRoles{},
|
||||||
&models.Person{},
|
&models.Person{},
|
||||||
&models.ManageSection{},
|
|
||||||
&models.ManageParentSection{},
|
|
||||||
&models.List{},
|
&models.List{},
|
||||||
&models.ListItem{},
|
&models.ListItem{},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import "gorm.io/gorm"
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
|
IsMember bool
|
||||||
|
IsContact bool
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
Email string
|
Email string
|
||||||
|
|
|
||||||
15
models/roles.go
Normal file
15
models/roles.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
|
type Role struct {
|
||||||
|
gorm.Model
|
||||||
|
Name string
|
||||||
|
ShowPerson bool
|
||||||
|
CreatePerson bool
|
||||||
|
EditPerson bool
|
||||||
|
ShowArchivedPerson bool
|
||||||
|
ArchivePerson bool
|
||||||
|
RestorePerson bool
|
||||||
|
ExportData bool
|
||||||
|
}
|
||||||
|
|
@ -2,16 +2,12 @@ package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
import "gorm.io/gorm"
|
||||||
|
|
||||||
type ParentSection struct {
|
|
||||||
gorm.Model
|
|
||||||
Name string
|
|
||||||
ShortName string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Section struct {
|
type Section struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Name string
|
Name string
|
||||||
ShortName string
|
ShortName string
|
||||||
ParentSectionID uint
|
ParentSectionID uint
|
||||||
ParentSection ParentSection
|
ParentSection *Section
|
||||||
|
ContainsMembers bool
|
||||||
|
ContainsContacts bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,30 +17,12 @@ type User struct {
|
||||||
SkipWelcome bool
|
SkipWelcome bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ManageSection struct {
|
type UserRoles struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UserID uint
|
UserID uint
|
||||||
User User
|
User User
|
||||||
|
RoleID uint
|
||||||
|
Role Role
|
||||||
SectionID uint
|
SectionID uint
|
||||||
Section Section
|
Section Section
|
||||||
ShowPerson bool
|
|
||||||
CreatePerson bool
|
|
||||||
EditPerson bool
|
|
||||||
ShowArchivedPerson bool
|
|
||||||
ArchivePerson bool
|
|
||||||
UnarchivePerson bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type ManageParentSection struct {
|
|
||||||
gorm.Model
|
|
||||||
UserID uint
|
|
||||||
User User
|
|
||||||
ParentSectionID uint
|
|
||||||
ParentSection ParentSection
|
|
||||||
ShowPerson bool
|
|
||||||
CreatePerson bool
|
|
||||||
EditPerson bool
|
|
||||||
ShowArchivedPerson bool
|
|
||||||
ArchivePerson bool
|
|
||||||
UnarchivePerson bool
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue