diff --git a/backend/go.mod b/backend/go.mod index 10a3a5b..f559082 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -32,6 +32,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/oklog/ulid/v2 v2.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect diff --git a/backend/go.sum b/backend/go.sum index 41a27b8..0dd9d26 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -63,6 +63,9 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU= +github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ= +github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/backend/internal/domain/entities/activity.go b/backend/internal/domain/entities/activity.go index 7b5182b..56df0d3 100644 --- a/backend/internal/domain/entities/activity.go +++ b/backend/internal/domain/entities/activity.go @@ -1,7 +1,9 @@ package entities +import "github.com/oklog/ulid/v2" + type Activity struct { - ID int + ID ulid.ULID Name string BillingRate float64 } diff --git a/backend/internal/domain/entities/company.go b/backend/internal/domain/entities/company.go index e223f30..d78ed4f 100644 --- a/backend/internal/domain/entities/company.go +++ b/backend/internal/domain/entities/company.go @@ -1,6 +1,8 @@ package entities +import "github.com/oklog/ulid/v2" + type Company struct { - ID int + ID ulid.ULID Name string } diff --git a/backend/internal/domain/entities/customer.go b/backend/internal/domain/entities/customer.go index aa0b403..6badb90 100644 --- a/backend/internal/domain/entities/customer.go +++ b/backend/internal/domain/entities/customer.go @@ -1,7 +1,9 @@ package entities +import "github.com/oklog/ulid/v2" + type Customer struct { - ID int + ID ulid.ULID Name string CompanyID int } diff --git a/backend/internal/domain/entities/project.go b/backend/internal/domain/entities/project.go index 1157585..e71daf0 100644 --- a/backend/internal/domain/entities/project.go +++ b/backend/internal/domain/entities/project.go @@ -1,7 +1,9 @@ package entities +import "github.com/oklog/ulid/v2" + type Project struct { - ID int + ID ulid.ULID Name string CustomerID int } diff --git a/backend/internal/domain/entities/timeentry.go b/backend/internal/domain/entities/timeentry.go index 5488662..19e20d7 100644 --- a/backend/internal/domain/entities/timeentry.go +++ b/backend/internal/domain/entities/timeentry.go @@ -1,9 +1,13 @@ package entities -import "time" +import ( + "time" + + "github.com/oklog/ulid/v2" +) type TimeEntry struct { - ID int + ID ulid.ULID UserID int ProjectID int ActivityID int diff --git a/backend/internal/domain/entities/user.go b/backend/internal/domain/entities/user.go index 94c8605..e33a586 100644 --- a/backend/internal/domain/entities/user.go +++ b/backend/internal/domain/entities/user.go @@ -1,7 +1,9 @@ package entities +import "github.com/oklog/ulid/v2" + type User struct { - ID int + ID ulid.ULID Username string Password string Role string diff --git a/backend/internal/interfaces/http/dto/activity_dto.go b/backend/internal/interfaces/http/dto/activity_dto.go new file mode 100644 index 0000000..4222886 --- /dev/null +++ b/backend/internal/interfaces/http/dto/activity_dto.go @@ -0,0 +1,11 @@ +package dto + +import ( + "github.com/oklog/ulid/v2" +) + +type ActivityDto struct { + ID ulid.ULID `json:"id"` + Name string `json:"name"` + BillingRate float64 `json:"billingRate"` +} diff --git a/backend/internal/interfaces/http/dto/company_dto.go b/backend/internal/interfaces/http/dto/company_dto.go new file mode 100644 index 0000000..53b6588 --- /dev/null +++ b/backend/internal/interfaces/http/dto/company_dto.go @@ -0,0 +1,10 @@ +package dto + +import ( + "github.com/oklog/ulid/v2" +) + +type CompanyDto struct { + ID ulid.ULID `json:"id"` + Name string `json:"name"` +} diff --git a/backend/internal/interfaces/http/dto/customer_dto.go b/backend/internal/interfaces/http/dto/customer_dto.go new file mode 100644 index 0000000..c0e38fe --- /dev/null +++ b/backend/internal/interfaces/http/dto/customer_dto.go @@ -0,0 +1,11 @@ +package dto + +import ( + "github.com/oklog/ulid/v2" +) + +type CustomerDto struct { + ID ulid.ULID `json:"id"` + Name string `json:"name"` + CompanyID int `json:"companyId"` +} diff --git a/backend/internal/interfaces/http/dto/project_dto.go b/backend/internal/interfaces/http/dto/project_dto.go new file mode 100644 index 0000000..d53dcd0 --- /dev/null +++ b/backend/internal/interfaces/http/dto/project_dto.go @@ -0,0 +1,9 @@ +package dto + +import "github.com/oklog/ulid/v2" + +type ProjectDto struct { + ID ulid.ULID `json:"id"` + Name string `json:"name"` + CustomerID int `json:"customerId"` +} diff --git a/backend/internal/interfaces/http/dto/timeentry_dto.go b/backend/internal/interfaces/http/dto/timeentry_dto.go new file mode 100644 index 0000000..7053aa2 --- /dev/null +++ b/backend/internal/interfaces/http/dto/timeentry_dto.go @@ -0,0 +1,18 @@ +package dto + +import ( + "time" + + "github.com/oklog/ulid/v2" +) + +type TimeEntryDto struct { + ID ulid.ULID `json:"id"` + UserID int `json:"userId"` + ProjectID int `json:"projectId"` + ActivityID int `json:"activityId"` + Start time.Time `json:"start"` + End time.Time `json:"end"` + Description string `json:"description"` + Billable int `json:"billable"` // Percentage (0-100) +} diff --git a/backend/internal/interfaces/http/dto/typescript/index.ts b/backend/internal/interfaces/http/dto/typescript/index.ts deleted file mode 100644 index 7139a7f..0000000 --- a/backend/internal/interfaces/http/dto/typescript/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by tygo. DO NOT EDIT. - -////////// -// source: activity.go - -export interface Activity { - ID: number /* int */; - Name: string; - BillingRate: number /* float64 */; -} - -////////// -// source: company.go - -export interface Company { - ID: number /* int */; - Name: string; -} - -////////// -// source: customer.go - -export interface Customer { - ID: number /* int */; - Name: string; - CompanyID: number /* int */; -} - -////////// -// source: project.go - -export interface Project { - ID: number /* int */; - Name: string; - CustomerID: number /* int */; -} - -////////// -// source: timeentry.go - -export interface TimeEntry { - ID: number /* int */; - UserID: number /* int */; - ProjectID: number /* int */; - ActivityID: number /* int */; - Start: string; - End: string; - Description: string; - Billable: number /* int */; // Percentage (0-100) -} - -////////// -// source: user.go - -export interface User { - ID: number /* int */; - Username: string; - Password: string; - Role: string; - CompanyID: number /* int */; - HourlyRate: number /* float64 */; -} diff --git a/backend/internal/interfaces/http/dto/user_dto.go b/backend/internal/interfaces/http/dto/user_dto.go new file mode 100644 index 0000000..197ece1 --- /dev/null +++ b/backend/internal/interfaces/http/dto/user_dto.go @@ -0,0 +1,12 @@ +package dto + +import "github.com/oklog/ulid/v2" + +type UserDto struct { + ID ulid.ULID `json:"id"` + Username string `json:"username"` + Password string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration. + Role string `json:"role"` + CompanyID int `json:"companyId"` + HourlyRate float64 `json:"hourlyRate"` +} diff --git a/backend/tygo.yml b/backend/tygo.yml index 04f926a..55a63e7 100644 --- a/backend/tygo.yml +++ b/backend/tygo.yml @@ -1,5 +1,6 @@ packages: - - path: github.com/timetracker/backend/internal/domain/entities + - path: github.com/timetracker/backend/internal/interfaces/http/dto type_mappings: "time.Time": "string" - output_path: ./internal/interfaces/http/dto/typescript + "ulid.ULID": "string" + output_path: ../frontend/src/types diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 1f3d001..82ce61e 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -1,62 +1,62 @@ // Code generated by tygo. DO NOT EDIT. ////////// -// source: activity.go +// source: activity_dto.go -export interface Activity { - ID: number /* int */; - Name: string; - BillingRate: number /* float64 */; +export interface ActivityDto { + id: string; + name: string; + billingRate: number /* float64 */; } ////////// -// source: company.go +// source: company_dto.go -export interface Company { - ID: number /* int */; - Name: string; +export interface CompanyDto { + id: string; + name: string; } ////////// -// source: customer.go +// source: customer_dto.go -export interface Customer { - ID: number /* int */; - Name: string; - CompanyID: number /* int */; +export interface CustomerDto { + id: string; + name: string; + companyId: number /* int */; } ////////// -// source: project.go +// source: project_dto.go -export interface Project { - ID: number /* int */; - Name: string; - CustomerID: number /* int */; +export interface ProjectDto { + id: string; + name: string; + customerId: number /* int */; } ////////// -// source: timeentry.go +// source: timeentry_dto.go -export interface TimeEntry { - ID: number /* int */; - UserID: number /* int */; - ProjectID: number /* int */; - ActivityID: number /* int */; - Start: string; - End: string; - Description: string; - Billable: number /* int */; // Percentage (0-100) +export interface TimeEntryDto { + id: string; + userId: number /* int */; + projectId: number /* int */; + activityId: number /* int */; + start: string; + end: string; + description: string; + billable: number /* int */; // Percentage (0-100) } ////////// -// source: user.go +// source: user_dto.go -export interface User { - ID: number /* int */; - Username: string; - Password: string; - Role: string; - CompanyID: number /* int */; - HourlyRate: number /* float64 */; +export interface UserDto { + id: string; + username: string; + password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration. + role: string; + companyId: number /* int */; + hourlyRate: number /* float64 */; }