model

package
v0.0.0-...-26386a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slugify

func Slugify(name string) string

Types

type Dataset

type Dataset struct {
	ID             uint           `json:"id" gorm:"primaryKey"`
	Slug           string         `json:"slug" gorm:"uniqueIndex"`
	Name           string         `json:"name"`
	Contact        string         `json:"contact"`
	Description    string         `json:"description"`
	IsPrivate      bool           `json:"private"`
	OrganizationID uint           `json:"organizationId"`
	ManifestHash   string         `json:"manifestHash"`
	Manifest       *core.Manifest `json:"manifest" gorm:"-"`
	CreatedAt      time.Time      `json:"createdAt"`
	UpdatedAt      time.Time      `json:"updatedAt"`
	DeletedAt      gorm.DeletedAt `json:"-" gorm:"index"`

	Organization   *Organization          `json:"organization"`
	UserPrivileges []UserDatasetPrivilege `json:"userPrivileges"`
}

type GetDataset

type GetDataset struct {
	GetDatasets
	ID uint `json:"id"`
}

type GetDatasets

type GetDatasets struct {
	OrganizationID uint `json:"organizationId"`
}

type GetOrganization

type GetOrganization struct {
	ID   *uint   `json:"id,omitempty"`
	Slug *string `json:"slug,omitempty"`
}

type GetUser

type GetUser struct {
	Email string `json:"email"`
}

type NewDataset

type NewDataset struct {
	Slug           string  `json:"slug"`
	Name           string  `json:"name"`
	OrganizationID uint    `json:"organizationId"`
	Contact        string  `json:"contact"`
	Description    *string `json:"description,omitempty"`
	IsPrivate      bool    `json:"isPrivate"`
}

func (*NewDataset) ID

func (input *NewDataset) ID() string

type NewOrganization

type NewOrganization struct {
	Slug        string  `json:"slug"`
	Name        string  `json:"name"`
	Contact     string  `json:"contact"`
	Description *string `json:"description,omitempty"`
	IsPrivate   bool    `json:"private"`
}

type NewUser

type NewUser struct {
	Email    string  `json:"email"`
	Password string  `json:"password"`
	Name     string  `json:"name"`
	Orcid    *string `json:"orcid,omitempty"`
}

type Organization

type Organization struct {
	ID          uint           `json:"id" gorm:"primaryKey"`
	Slug        string         `json:"slug" gorm:"uniqueIndex"`
	Name        string         `json:"name"`
	Contact     string         `json:"contact" gorm:"index"`
	Description string         `json:"description"`
	IsPrivate   bool           `json:"private"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`

	Datasets       []Dataset                   `json:"datasets"`
	UserPrivileges []UserOrganizationPrivilege `json:"userPrivileges"`
}

type Privilege

type Privilege struct {
	Code        string `json:"code" gorm:"primaryKey"`
	Description string `json:"description"`
}

type Role

type Role struct {
	Code        string `json:"code" gorm:"primaryKey"`
	Description string `json:"description"`
	Users       []User `json:"users"`
}

type User

type User struct {
	ID           uint           `json:"id" gorm:"primaryKey"`
	Email        string         `json:"email" gorm:"uniqueIndex"`
	PasswordHash []byte         `json:"-"`
	Name         string         `json:"name"`
	Orcid        *string        `json:"orcid,omitempty" gorm:"index"`
	RoleCode     string         `json:"roleCode"`
	CreatedAt    time.Time      `json:"createdAt"`
	UpdatedAt    time.Time      `json:"updatedAt"`
	DeletedAt    gorm.DeletedAt `json:"-" gorm:"index"`

	Role                   *Role                       `json:"role"`
	OrganizationPrivileges []UserOrganizationPrivilege `json:"organizationPrivileges"`
	DatasetPrivileges      []UserDatasetPrivilege      `json:"datasetPrivileges"`
}

func (User) CanManageDataset

func (user User) CanManageDataset(dataset Dataset) bool

func (User) CanManageOrganization

func (user User) CanManageOrganization(org Organization) bool

func (User) CanReadDataset

func (user User) CanReadDataset(dataset Dataset) bool

func (User) CanReadOrganization

func (user User) CanReadOrganization(org Organization) bool

func (User) CanWriteDataset

func (user User) CanWriteDataset(dataset Dataset) bool

func (User) CanWriteOrganization

func (user User) CanWriteOrganization(org Organization) bool

func (User) DatasetPrivilege

func (user User) DatasetPrivilege(dataset Dataset) string

func (User) OrganizationPrivilege

func (user User) OrganizationPrivilege(org Organization) string

type UserDatasetPrivilege

type UserDatasetPrivilege struct {
	UserID        uint   `json:"userId" gorm:"primaryKey"`
	DatasetID     uint   `json:"datasetId" gorm:"primaryKey"`
	PrivilegeCode string `json:"privilegeCode"`

	User      *User      `json:"user"`
	Dataset   *Dataset   `json:"dataset"`
	Privilege *Privilege `json:"privilege"`
}

type UserLogin

type UserLogin struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserOrganizationPrivilege

type UserOrganizationPrivilege struct {
	UserID         uint   `json:"userId" gorm:"primaryKey"`
	OrganizationID uint   `json:"organizationID" gorm:"primaryKey"`
	PrivilegeCode  string `json:"privilegeCode"`

	User         *User         `json:"user"`
	Organization *Organization `json:"organization"`
	Privilege    *Privilege    `json:"privilege"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL