ajout app
This commit is contained in:
28
Voltaserve/api/model/file_model.go
Normal file
28
Voltaserve/api/model/file_model.go
Normal file
@ -0,0 +1,28 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
FileTypeFile = "file"
|
||||
FileTypeFolder = "folder"
|
||||
)
|
||||
|
||||
type File interface {
|
||||
GetID() string
|
||||
GetWorkspaceID() string
|
||||
GetName() string
|
||||
GetType() string
|
||||
GetParentID() *string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
GetSnapshots() []Snapshot
|
||||
GetUserPermissions() []CoreUserPermission
|
||||
GetGroupPermissions() []CoreGroupPermission
|
||||
GetText() *string
|
||||
SetID(string)
|
||||
SetParentID(*string)
|
||||
SetWorkspaceID(string)
|
||||
SetType(string)
|
||||
SetName(string)
|
||||
SetText(*string)
|
||||
SetCreateTime(string)
|
||||
SetUpdateTime(*string)
|
||||
}
|
14
Voltaserve/api/model/group_model.go
Normal file
14
Voltaserve/api/model/group_model.go
Normal file
@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
type Group interface {
|
||||
GetID() string
|
||||
GetName() string
|
||||
GetOrganizationID() string
|
||||
GetUserPermissions() []CoreUserPermission
|
||||
GetGroupPermissions() []CoreGroupPermission
|
||||
GetUsers() []string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
SetName(string)
|
||||
SetUpdateTime(*string)
|
||||
}
|
19
Voltaserve/api/model/invitation_model.go
Normal file
19
Voltaserve/api/model/invitation_model.go
Normal file
@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
InvitationStatusPending = "pending"
|
||||
InvitationStatusAccepted = "accepted"
|
||||
InvitationStatusDeclined = "declined"
|
||||
)
|
||||
|
||||
type Invitation interface {
|
||||
GetID() string
|
||||
GetOrganizationID() string
|
||||
GetOwnerID() string
|
||||
GetEmail() string
|
||||
GetStatus() string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
SetStatus(string)
|
||||
SetUpdateTime(*string)
|
||||
}
|
13
Voltaserve/api/model/organization_model.go
Normal file
13
Voltaserve/api/model/organization_model.go
Normal file
@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
type Organization interface {
|
||||
GetID() string
|
||||
GetName() string
|
||||
GetUserPermissions() []CoreUserPermission
|
||||
GetGroupPermissions() []CoreGroupPermission
|
||||
GetUsers() []string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
SetName(string)
|
||||
SetUpdateTime(*string)
|
||||
}
|
58
Voltaserve/api/model/permission_model.go
Normal file
58
Voltaserve/api/model/permission_model.go
Normal file
@ -0,0 +1,58 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
PermissionViewer = "viewer"
|
||||
PermissionEditor = "editor"
|
||||
PermissionOwner = "owner"
|
||||
)
|
||||
|
||||
type CoreUserPermission interface {
|
||||
GetUserID() string
|
||||
GetValue() string
|
||||
}
|
||||
|
||||
type CoreGroupPermission interface {
|
||||
GetGroupID() string
|
||||
GetValue() string
|
||||
}
|
||||
|
||||
func GteViewerPermission(permission string) bool {
|
||||
return permission == PermissionViewer || permission == PermissionEditor || permission == PermissionOwner
|
||||
}
|
||||
|
||||
func GteEditorPermission(permission string) bool {
|
||||
return permission == PermissionEditor || permission == PermissionOwner
|
||||
}
|
||||
|
||||
func GteOwnerPermission(permission string) bool {
|
||||
return permission == PermissionOwner
|
||||
}
|
||||
|
||||
func IsEquivalentPermission(permission string, otherPermission string) bool {
|
||||
if permission == otherPermission {
|
||||
return true
|
||||
}
|
||||
if otherPermission == PermissionViewer && GteViewerPermission(permission) {
|
||||
return true
|
||||
}
|
||||
if otherPermission == PermissionEditor && GteEditorPermission(permission) {
|
||||
return true
|
||||
}
|
||||
if otherPermission == PermissionOwner && GteOwnerPermission(permission) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetPermissionWeight(permission string) int {
|
||||
if permission == PermissionViewer {
|
||||
return 1
|
||||
}
|
||||
if permission == PermissionEditor {
|
||||
return 2
|
||||
}
|
||||
if permission == PermissionOwner {
|
||||
return 3
|
||||
}
|
||||
return 0
|
||||
}
|
49
Voltaserve/api/model/snapshot_model.go
Normal file
49
Voltaserve/api/model/snapshot_model.go
Normal file
@ -0,0 +1,49 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
SnapshotStatusNew = "new"
|
||||
SnapshotStatusProcessing = "processing"
|
||||
SnapshotStatusReady = "ready"
|
||||
SnapshotStatusError = "error"
|
||||
)
|
||||
|
||||
type Snapshot interface {
|
||||
GetID() string
|
||||
GetVersion() int64
|
||||
GetOriginal() *S3Object
|
||||
GetPreview() *S3Object
|
||||
GetText() *S3Object
|
||||
GetThumbnail() *Thumbnail
|
||||
HasOriginal() bool
|
||||
HasPreview() bool
|
||||
HasText() bool
|
||||
HasThumbnail() bool
|
||||
GetStatus() string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
SetID(string)
|
||||
SetVersion(int64)
|
||||
SetOriginal(*S3Object)
|
||||
SetPreview(*S3Object)
|
||||
SetText(*S3Object)
|
||||
SetThumbnail(*Thumbnail)
|
||||
SetStatus(string)
|
||||
}
|
||||
|
||||
type S3Object struct {
|
||||
Bucket string `json:"bucket"`
|
||||
Key string `json:"key"`
|
||||
Size int64 `json:"size"`
|
||||
Image *ImageProps `json:"image,omitempty"`
|
||||
}
|
||||
|
||||
type ImageProps struct {
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
}
|
||||
|
||||
type Thumbnail struct {
|
||||
Base64 string `json:"base64"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
}
|
12
Voltaserve/api/model/user_model.go
Normal file
12
Voltaserve/api/model/user_model.go
Normal file
@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
type User interface {
|
||||
GetID() string
|
||||
GetFullName() string
|
||||
GetUsername() string
|
||||
GetEmail() string
|
||||
GetPicture() *string
|
||||
GetIsEmailConfirmed() bool
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
}
|
16
Voltaserve/api/model/workspace_model.go
Normal file
16
Voltaserve/api/model/workspace_model.go
Normal file
@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
type Workspace interface {
|
||||
GetID() string
|
||||
GetName() string
|
||||
GetStorageCapacity() int64
|
||||
GetRootID() string
|
||||
GetOrganizationID() string
|
||||
GetUserPermissions() []CoreUserPermission
|
||||
GetGroupPermissions() []CoreGroupPermission
|
||||
GetBucket() string
|
||||
GetCreateTime() string
|
||||
GetUpdateTime() *string
|
||||
SetName(string)
|
||||
SetUpdateTime(*string)
|
||||
}
|
Reference in New Issue
Block a user