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/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
|
||||
|
@ -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/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
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/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
@ -1,7 +1,9 @@
|
||||
package entities
|
||||
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type Activity struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
Name string
|
||||
BillingRate float64
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package entities
|
||||
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type Company struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
Name string
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package entities
|
||||
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type Customer struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
Name string
|
||||
CompanyID int
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package entities
|
||||
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type Project struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
Name string
|
||||
CustomerID int
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package entities
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/oklog/ulid/v2"
|
||||
)
|
||||
|
||||
type TimeEntry struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
UserID int
|
||||
ProjectID int
|
||||
ActivityID int
|
||||
|
@ -1,7 +1,9 @@
|
||||
package entities
|
||||
|
||||
import "github.com/oklog/ulid/v2"
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
ID ulid.ULID
|
||||
Username string
|
||||
Password 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:
|
||||
- path: github.com/timetracker/backend/internal/domain/entities
|
||||
- path: github.com/timetracker/backend/internal/interfaces/http/dto
|
||||
type_mappings:
|
||||
"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.
|
||||
|
||||
//////////
|
||||
// source: activity.go
|
||||
// source: activity_dto.go
|
||||
|
||||
export interface Activity {
|
||||
ID: number /* int */;
|
||||
Name: string;
|
||||
BillingRate: number /* float64 */;
|
||||
export interface ActivityDto {
|
||||
id: string;
|
||||
name: string;
|
||||
billingRate: number /* float64 */;
|
||||
}
|
||||
|
||||
//////////
|
||||
// source: company.go
|
||||
// source: company_dto.go
|
||||
|
||||
export interface Company {
|
||||
ID: number /* int */;
|
||||
Name: string;
|
||||
export interface CompanyDto {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
//////////
|
||||
// source: customer.go
|
||||
// source: customer_dto.go
|
||||
|
||||
export interface Customer {
|
||||
ID: number /* int */;
|
||||
Name: string;
|
||||
CompanyID: number /* int */;
|
||||
export interface CustomerDto {
|
||||
id: string;
|
||||
name: string;
|
||||
companyId: number /* int */;
|
||||
}
|
||||
|
||||
//////////
|
||||
// source: project.go
|
||||
// source: project_dto.go
|
||||
|
||||
export interface Project {
|
||||
ID: number /* int */;
|
||||
Name: string;
|
||||
CustomerID: number /* int */;
|
||||
export interface ProjectDto {
|
||||
id: string;
|
||||
name: string;
|
||||
customerId: number /* int */;
|
||||
}
|
||||
|
||||
//////////
|
||||
// source: timeentry.go
|
||||
// source: timeentry_dto.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)
|
||||
export interface TimeEntryDto {
|
||||
id: string;
|
||||
userId: number /* int */;
|
||||
projectId: number /* int */;
|
||||
activityId: number /* int */;
|
||||
start: string;
|
||||
end: string;
|
||||
description: string;
|
||||
billable: number /* int */; // Percentage (0-100)
|
||||
}
|
||||
|
||||
//////////
|
||||
// source: user.go
|
||||
// source: user_dto.go
|
||||
|
||||
export interface User {
|
||||
ID: number /* int */;
|
||||
Username: string;
|
||||
Password: string;
|
||||
Role: string;
|
||||
CompanyID: number /* int */;
|
||||
HourlyRate: number /* float64 */;
|
||||
export interface UserDto {
|
||||
id: string;
|
||||
username: string;
|
||||
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||
role: string;
|
||||
companyId: number /* int */;
|
||||
hourlyRate: number /* float64 */;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user