add org structure
This commit is contained in:
10
model/organization.go
Normal file
10
model/organization.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Organization struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"unique;index"`
|
||||
ParentID uint `json:"parent_id"`
|
||||
Positions []Position `json:"positions,omitempty"`
|
||||
}
|
||||
11
model/position.go
Normal file
11
model/position.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type Position struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"unique;index"`
|
||||
RightMask int `json:"right_mask"`
|
||||
OrganizationID uint `json:"organization_id" gorm:"index;not null"`
|
||||
Users []User `json:"users,omitempty"`
|
||||
}
|
||||
@@ -5,16 +5,19 @@ import "gorm.io/gorm"
|
||||
type (
|
||||
User struct {
|
||||
gorm.Model
|
||||
UserName string `json:"userName" gorm:"unique"`
|
||||
Password string `json:"password,omitempty"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
UserName string `json:"user_name" gorm:"unique;index"`
|
||||
Password string `json:"password,omitempty"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Role string `json:"role" gorm:"default:employee"`
|
||||
PositionID uint `json:"-"`
|
||||
Position Position `gorm:"-:migration"`
|
||||
}
|
||||
)
|
||||
|
||||
type APIUser struct {
|
||||
UserName string `json:"userName" gorm:"unique"`
|
||||
UserName string `json:"user_name" gorm:"unique;index"`
|
||||
Password string `json:"password,omitempty"`
|
||||
FirstName string `json:"firstName"`
|
||||
LastName string `json:"lastName"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user