feat: Add database object models and repositories for Activity, Company, Customer, Project, TimeEntry, and User with GORM integration

This commit is contained in:
2025-03-10 07:29:34 +00:00
parent 4dda83904a
commit 17cb4505be
28 changed files with 786 additions and 1 deletions
@@ -0,0 +1,18 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type ActivityDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
Name string `gorm:"type:varchar(255);not null"`
BillingRate float64 `gorm:"type:decimal(10,2)"`
}
@@ -0,0 +1,17 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type CompanyDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
Name string `gorm:"type:varchar(255);not null"`
}
@@ -0,0 +1,18 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type CustomerDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
Name string `gorm:"type:varchar(255);not null"`
CompanyID int
}
@@ -0,0 +1,18 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type ProjectDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
Name string `gorm:"type:varchar(255);not null"`
CustomerID int
}
@@ -0,0 +1,23 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type TimeEntryDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
UserID int
ProjectID int
ActivityID int
Start time.Time
End time.Time
Description string
Billable int // Percentage (0-100)
}
@@ -0,0 +1,21 @@
package dbo
import (
"time"
"github.com/oklog/ulid/v2"
"gorm.io/gorm"
)
type UserDBO struct {
gorm.Model
ID ulid.ULID `gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
LastEditorID ulid.ULID
Username string
Password string
Role string
CompanyID int
HourlyRate float64
}