add postgres and refactor code
This commit is contained in:
@@ -8,3 +8,8 @@ type Organization struct {
|
||||
ParentID uint `json:"parent_id"`
|
||||
Positions []Position `json:"positions,omitempty"`
|
||||
}
|
||||
|
||||
type OrganizationApi struct {
|
||||
Name string `json:"name" gorm:"unique;index"`
|
||||
ParentID uint `json:"parent_id"`
|
||||
}
|
||||
|
||||
@@ -9,3 +9,9 @@ type Position struct {
|
||||
OrganizationID uint `json:"organization_id" gorm:"index;not null"`
|
||||
Users []User `json:"users,omitempty"`
|
||||
}
|
||||
|
||||
type PositionApi struct {
|
||||
Name string `json:"name" gorm:"unique;index"`
|
||||
RightMask int `json:"right_mask"`
|
||||
OrganizationID uint `json:"organization_id" gorm:"index;not null"`
|
||||
}
|
||||
|
||||
@@ -5,19 +5,16 @@ import "gorm.io/gorm"
|
||||
type (
|
||||
User struct {
|
||||
gorm.Model
|
||||
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"`
|
||||
APIUser
|
||||
Position Position `gorm:"-:migration"`
|
||||
}
|
||||
)
|
||||
|
||||
type APIUser struct {
|
||||
UserName string `json:"user_name" gorm:"unique;index"`
|
||||
Password string `json:"password,omitempty"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
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_id,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user