feat: Add create and update DTOs for Company, Customer, Project, Activity, User, and TimeEntry entities

This commit is contained in:
2025-03-09 19:55:23 +00:00
parent 0402b8ac65
commit 9749d5658c
22 changed files with 430 additions and 67 deletions
+14 -1
View File
@@ -1,9 +1,22 @@
package entities
import "github.com/oklog/ulid/v2"
import (
"github.com/oklog/ulid/v2"
)
type Activity struct {
ID ulid.ULID
Name string
BillingRate float64
}
type ActivityUpdate struct {
ID ulid.ULID
Name *string
BillingRate *float64
}
type ActivityCreate struct {
Name string
BillingRate float64
}
@@ -6,3 +6,12 @@ type Company struct {
ID ulid.ULID
Name string
}
type CompanyCreate struct {
Name string
}
type CompanyUpdate struct {
ID ulid.ULID
Name *string
}
@@ -7,3 +7,14 @@ type Customer struct {
Name string
CompanyID int
}
type CustomerCreate struct {
Name string
CompanyID int
}
type CustomerUpdate struct {
ID ulid.ULID
Name *string
CompanyID *int
}
@@ -7,3 +7,14 @@ type Project struct {
Name string
CustomerID int
}
type ProjectCreate struct {
Name string
CustomerID int
}
type ProjectUpdate struct {
ID ulid.ULID
Name *string
CustomerID *int
}
@@ -16,3 +16,24 @@ type TimeEntry struct {
Description string
Billable int // Percentage (0-100)
}
type TimeEntryCreate struct {
UserID int
ProjectID int
ActivityID int
Start time.Time
End time.Time
Description string
Billable int // Percentage (0-100)
}
type TimeEntryUpdate struct {
ID ulid.ULID
UserID *int
ProjectID *int
ActivityID *int
Start *time.Time
End *time.Time
Description *string
Billable *int // Percentage (0-100)
}
+17
View File
@@ -10,3 +10,20 @@ type User struct {
CompanyID int
HourlyRate float64
}
type UserCreate struct {
Username string
Password string
Role string
CompanyID int
HourlyRate float64
}
type UserUpdate struct {
ID ulid.ULID
Username *string
Password *string
Role *string
CompanyID *int
HourlyRate *float64
}
@@ -9,3 +9,14 @@ type ActivityDto struct {
Name string `json:"name"`
BillingRate float64 `json:"billingRate"`
}
type ActivityCreateDto struct {
Name string `json:"name"`
BillingRate float64 `json:"billingRate"`
}
type ActivityUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
BillingRate *float64 `json:"billingRate"`
}
@@ -8,3 +8,12 @@ type CompanyDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
}
type CompanyCreateDto struct {
Name string `json:"name"`
}
type CompanyUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
}
@@ -9,3 +9,14 @@ type CustomerDto struct {
Name string `json:"name"`
CompanyID int `json:"companyId"`
}
type CustomerCreateDto struct {
Name string `json:"name"`
CompanyID int `json:"companyId"`
}
type CustomerUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
CompanyID *int `json:"companyId"`
}
@@ -1,9 +1,22 @@
package dto
import "github.com/oklog/ulid/v2"
import (
"github.com/oklog/ulid/v2"
)
type ProjectDto struct {
ID ulid.ULID `json:"id"`
Name string `json:"name"`
CustomerID int `json:"customerId"`
}
type ProjectCreateDto struct {
Name string `json:"name"`
CustomerID int `json:"customerId"`
}
type ProjectUpdateDto struct {
ID ulid.ULID `json:"id"`
Name *string `json:"name"`
CustomerID *int `json:"customerId"`
}
@@ -16,3 +16,24 @@ type TimeEntryDto struct {
Description string `json:"description"`
Billable int `json:"billable"` // Percentage (0-100)
}
type TimeEntryCreateDto struct {
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 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)
}
@@ -1,6 +1,8 @@
package dto
import "github.com/oklog/ulid/v2"
import (
"github.com/oklog/ulid/v2"
)
type UserDto struct {
ID ulid.ULID `json:"id"`
@@ -10,3 +12,20 @@ type UserDto struct {
CompanyID int `json:"companyId"`
HourlyRate float64 `json:"hourlyRate"`
}
type UserCreateDto struct {
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 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"`
}