add some backend code.
This commit is contained in:
+2
-3
@@ -1,8 +1,7 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@@ -0,0 +1,37 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.aiterp.net/stufflog3/stufflog3-api/internal/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Database interface {
|
||||
Scopes() ScopeRepository
|
||||
Stats(scopeID int) StatRepository
|
||||
}
|
||||
|
||||
type ScopeRepository interface {
|
||||
Find(ctx context.Context, id int) (*models.Scope, error)
|
||||
List(ctx context.Context, userID string) ([]models.ScopeEntry, error)
|
||||
Create(ctx context.Context, scope models.ScopeEntry, owner models.ScopeMember) (*models.Scope, error)
|
||||
Update(ctx context.Context, scope models.ScopeEntry) error
|
||||
Delete(ctx context.Context, scope models.Scope) error
|
||||
UpdateMember(ctx context.Context, scope models.Scope, member models.ScopeMember) (*models.Scope, error)
|
||||
DeleteMember(ctx context.Context, scope models.Scope, userID string) (*models.Scope, error)
|
||||
}
|
||||
|
||||
type StatRepository interface {
|
||||
Find(ctx context.Context, id int) (*models.Stat, error)
|
||||
List(ctx context.Context) ([]models.Stat, error)
|
||||
Create(ctx context.Context, stat models.Stat) (*models.Stat, error)
|
||||
Update(ctx context.Context, stat models.Stat) error
|
||||
Delete(ctx context.Context, stat models.Stat) error
|
||||
}
|
||||
|
||||
type ItemRepository interface {
|
||||
Find(ctx context.Context, id int) (*models.Item, error)
|
||||
List(ctx context.Context) ([]models.Item, error)
|
||||
ListAcquired(ctx context.Context, from, to time.Time) ([]models.Item, error)
|
||||
Create(ctx context.Context, stat models.Stat) (*models.Item, error)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package models
|
||||
@@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Item struct {
|
||||
ID int
|
||||
ProjectRequirementID *int
|
||||
OwnerID string
|
||||
|
||||
Name string
|
||||
Description string
|
||||
OwnerName string
|
||||
CreatedTime time.Time
|
||||
AcquiredTime *time.Time
|
||||
ScheduledDate *time.Time
|
||||
Stats StatProgressEntry[]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package models
|
||||
|
||||
type ProjectEntry struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Status Status `json:"status"`
|
||||
}
|
||||
|
||||
type ProjectRequirement struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Status Status `json:"status"`
|
||||
Stats []StatProgressEntry `json:"stats"`
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
type ScopeEntry struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Abbreviation string `json:"abbreviation"`
|
||||
}
|
||||
|
||||
type ScopeMember struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Owner bool `json:"owner"`
|
||||
}
|
||||
|
||||
type Scope struct {
|
||||
ScopeEntry
|
||||
|
||||
DisplayName string `json:"displayName"`
|
||||
Members []ScopeMember `json:"members"`
|
||||
Projects []ProjectEntry `json:"projects"`
|
||||
Stat []Stat `json:"stat"`
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
type StatEntry struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Weight float64 `json:"weight"`
|
||||
}
|
||||
|
||||
type StatProgressEntry struct {
|
||||
StatEntry
|
||||
|
||||
Acquired int `json:"acquired"`
|
||||
Required int `json:"required"`
|
||||
}
|
||||
|
||||
type Stat struct {
|
||||
StatEntry
|
||||
|
||||
Description string `json:"description"`
|
||||
AllowedAmounts map[string]int `json:"allowedAmounts"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
type Status int
|
||||
|
||||
const (
|
||||
Blocked Status = 0
|
||||
Available Status = 1
|
||||
Background Status = 2
|
||||
Active Status = 3
|
||||
Completed Status = 4
|
||||
Failed Status = 5
|
||||
Dropped Status = 6
|
||||
)
|
||||
|
||||
var StatusLabels = map[Status]string{
|
||||
Blocked: "Blocked",
|
||||
Available: "Available",
|
||||
Background: "Background",
|
||||
Active: "Active",
|
||||
Completed: "Completed",
|
||||
Failed: "Failed",
|
||||
Dropped: "Dropped",
|
||||
}
|
||||
Reference in New Issue
Block a user