diff --git a/backend/go.mod b/backend/go.mod index ddb98cb..1a5ea13 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -8,6 +8,7 @@ require ( github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.4 + gorm.io/gorm v1.25.12 ) require ( @@ -25,6 +26,8 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.25.0 // indirect github.com/goccy/go-json v0.10.5 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect diff --git a/backend/go.sum b/backend/go.sum index 0dd9d26..19f1ebf 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -40,6 +40,10 @@ github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PU github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -146,4 +150,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= +gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/activity_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/activity_dbo.go new file mode 100644 index 0000000..9337a0a --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/activity_dbo.go @@ -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)"` +} diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/company_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/company_dbo.go new file mode 100644 index 0000000..792853b --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/company_dbo.go @@ -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"` +} diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/customer_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/customer_dbo.go new file mode 100644 index 0000000..1b68d67 --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/customer_dbo.go @@ -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 +} diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/project_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/project_dbo.go new file mode 100644 index 0000000..e5e6619 --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/project_dbo.go @@ -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 +} diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/timeentry_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/timeentry_dbo.go new file mode 100644 index 0000000..5c1bbd0 --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/timeentry_dbo.go @@ -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) +} diff --git a/backend/internal/infrastructure/persistence/postgres/dbo/user_dbo.go b/backend/internal/infrastructure/persistence/postgres/dbo/user_dbo.go new file mode 100644 index 0000000..b44879d --- /dev/null +++ b/backend/internal/infrastructure/persistence/postgres/dbo/user_dbo.go @@ -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 +}