feat: Introduce base entity structure and update DTOs for Activity, Company, User, and TimeEntry

This commit is contained in:
2025-03-09 20:28:46 +00:00
parent 9749d5658c
commit 837cd55a33
18 changed files with 255 additions and 54 deletions
@@ -1,13 +1,18 @@
package dto
import (
"time"
"github.com/oklog/ulid/v2"
)
type ActivityDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
BillingRate float64 `json:"billingRate"`
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
Name string `json:"name"`
BillingRate float64 `json:"billingRate"`
}
type ActivityCreateDto struct {
@@ -16,7 +21,10 @@ type ActivityCreateDto struct {
}
type ActivityUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
BillingRate *float64 `json:"billingRate"`
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
Name *string `json:"name"`
BillingRate *float64 `json:"billingRate"`
}
@@ -1,12 +1,17 @@
package dto
import (
"time"
"github.com/oklog/ulid/v2"
)
type CompanyDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
Name string `json:"name"`
}
type CompanyCreateDto struct {
@@ -14,6 +19,9 @@ type CompanyCreateDto struct {
}
type CompanyUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
Name *string `json:"name"`
}
@@ -1,13 +1,18 @@
package dto
import (
"time"
"github.com/oklog/ulid/v2"
)
type CustomerDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
CompanyID int `json:"companyId"`
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
Name string `json:"name"`
CompanyID int `json:"companyId"`
}
type CustomerCreateDto struct {
@@ -16,7 +21,10 @@ type CustomerCreateDto struct {
}
type CustomerUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
CompanyID *int `json:"companyId"`
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
Name *string `json:"name"`
CompanyID *int `json:"companyId"`
}
@@ -1,13 +1,18 @@
package dto
import (
"time"
"github.com/oklog/ulid/v2"
)
type ProjectDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
CustomerID int `json:"customerId"`
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
Name string `json:"name"`
CustomerID int `json:"customerId"`
}
type ProjectCreateDto struct {
@@ -16,7 +21,10 @@ type ProjectCreateDto struct {
}
type ProjectUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
CustomerID *int `json:"customerId"`
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
Name *string `json:"name"`
CustomerID *int `json:"customerId"`
}
@@ -7,14 +7,17 @@ import (
)
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)
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
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)
}
type TimeEntryCreateDto struct {
@@ -28,12 +31,15 @@ type TimeEntryCreateDto struct {
}
type TimeEntryUpdateDto 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)
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
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)
}
@@ -1,16 +1,21 @@
package dto
import (
"time"
"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"`
ID ulid.ULID `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LastEditorID ulid.ULID `json:"lastEditorID"`
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"`
}
type UserCreateDto struct {
@@ -22,10 +27,13 @@ type UserCreateDto struct {
}
type UserUpdateDto 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"`
ID ulid.ULID `json:"id"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
LastEditorID *ulid.ULID `json:"lastEditorID"`
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"`
}