feat: Introduce base entity structure and update DTOs for Activity, Company, User, and TimeEntry
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type Activity struct {
|
||||
ID ulid.ULID
|
||||
EntityBase
|
||||
Name string
|
||||
BillingRate float64
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/oklog/ulid/v2"
|
||||
)
|
||||
|
||||
type EntityBase struct {
|
||||
ID ulid.ULID
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
LastEditorID ulid.ULID
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package entities
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type Company struct {
|
||||
ID ulid.ULID
|
||||
EntityBase
|
||||
Name string
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type TimeEntry struct {
|
||||
ID ulid.ULID
|
||||
EntityBase
|
||||
UserID int
|
||||
ProjectID int
|
||||
ActivityID int
|
||||
|
||||
@@ -3,7 +3,7 @@ package entities
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type User struct {
|
||||
ID ulid.ULID
|
||||
EntityBase
|
||||
Username string
|
||||
Password string
|
||||
Role string
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user