feat: Add create and update DTOs for Company, Customer, Project, Activity, User, and TimeEntry entities
This commit is contained in:
+1
-1
@@ -4,6 +4,7 @@ go 1.23.6
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/oklog/ulid/v2 v2.1.0
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.16.4
|
||||
@@ -32,7 +33,6 @@ 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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ packages:
|
||||
type_mappings:
|
||||
"time.Time": "string"
|
||||
"ulid.ULID": "string"
|
||||
output_path: ../frontend/src/types
|
||||
output_path: ../frontend/src/types/dto.ts
|
||||
|
||||
Reference in New Issue
Block a user