feat: Replace int IDs with ulid.ULID in domain entities and update TypeScript DTOs
This commit is contained in:
parent
56a6f3cfc4
commit
0402b8ac65
@ -32,6 +32,7 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // 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/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
|
@ -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/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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
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 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
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=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
BillingRate float64
|
BillingRate float64
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Customer struct {
|
type Customer struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
CompanyID int
|
CompanyID int
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
CustomerID int
|
CustomerID int
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/oklog/ulid/v2"
|
||||||
|
)
|
||||||
|
|
||||||
type TimeEntry struct {
|
type TimeEntry struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
UserID int
|
UserID int
|
||||||
ProjectID int
|
ProjectID int
|
||||||
ActivityID int
|
ActivityID int
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int
|
ID ulid.ULID
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Role string
|
Role string
|
||||||
|
11
backend/internal/interfaces/http/dto/activity_dto.go
Normal file
11
backend/internal/interfaces/http/dto/activity_dto.go
Normal file
@ -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"`
|
||||||
|
}
|
10
backend/internal/interfaces/http/dto/company_dto.go
Normal file
10
backend/internal/interfaces/http/dto/company_dto.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/oklog/ulid/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CompanyDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
11
backend/internal/interfaces/http/dto/customer_dto.go
Normal file
11
backend/internal/interfaces/http/dto/customer_dto.go
Normal file
@ -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"`
|
||||||
|
}
|
9
backend/internal/interfaces/http/dto/project_dto.go
Normal file
9
backend/internal/interfaces/http/dto/project_dto.go
Normal file
@ -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"`
|
||||||
|
}
|
18
backend/internal/interfaces/http/dto/timeentry_dto.go
Normal file
18
backend/internal/interfaces/http/dto/timeentry_dto.go
Normal file
@ -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)
|
||||||
|
}
|
@ -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 */;
|
|
||||||
}
|
|
12
backend/internal/interfaces/http/dto/user_dto.go
Normal file
12
backend/internal/interfaces/http/dto/user_dto.go
Normal file
@ -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"`
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
packages:
|
packages:
|
||||||
- path: github.com/timetracker/backend/internal/domain/entities
|
- path: github.com/timetracker/backend/internal/interfaces/http/dto
|
||||||
type_mappings:
|
type_mappings:
|
||||||
"time.Time": "string"
|
"time.Time": "string"
|
||||||
output_path: ./internal/interfaces/http/dto/typescript
|
"ulid.ULID": "string"
|
||||||
|
output_path: ../frontend/src/types
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
// Code generated by tygo. DO NOT EDIT.
|
// Code generated by tygo. DO NOT EDIT.
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: activity.go
|
// source: activity_dto.go
|
||||||
|
|
||||||
export interface Activity {
|
export interface ActivityDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
Name: string;
|
name: string;
|
||||||
BillingRate: number /* float64 */;
|
billingRate: number /* float64 */;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: company.go
|
// source: company_dto.go
|
||||||
|
|
||||||
export interface Company {
|
export interface CompanyDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
Name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: customer.go
|
// source: customer_dto.go
|
||||||
|
|
||||||
export interface Customer {
|
export interface CustomerDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
Name: string;
|
name: string;
|
||||||
CompanyID: number /* int */;
|
companyId: number /* int */;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: project.go
|
// source: project_dto.go
|
||||||
|
|
||||||
export interface Project {
|
export interface ProjectDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
Name: string;
|
name: string;
|
||||||
CustomerID: number /* int */;
|
customerId: number /* int */;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: timeentry.go
|
// source: timeentry_dto.go
|
||||||
|
|
||||||
export interface TimeEntry {
|
export interface TimeEntryDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
UserID: number /* int */;
|
userId: number /* int */;
|
||||||
ProjectID: number /* int */;
|
projectId: number /* int */;
|
||||||
ActivityID: number /* int */;
|
activityId: number /* int */;
|
||||||
Start: string;
|
start: string;
|
||||||
End: string;
|
end: string;
|
||||||
Description: string;
|
description: string;
|
||||||
Billable: number /* int */; // Percentage (0-100)
|
billable: number /* int */; // Percentage (0-100)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// source: user.go
|
// source: user_dto.go
|
||||||
|
|
||||||
export interface User {
|
export interface UserDto {
|
||||||
ID: number /* int */;
|
id: string;
|
||||||
Username: string;
|
username: string;
|
||||||
Password: string;
|
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
Role: string;
|
role: string;
|
||||||
CompanyID: number /* int */;
|
companyId: number /* int */;
|
||||||
HourlyRate: number /* float64 */;
|
hourlyRate: number /* float64 */;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user