Compare commits
No commits in common. "115f2667f6dca9f9f2aa1498356f34fe6b25b67a" and "9749d5658cc8ab67be4eb43e9dead0087cb2cb7a" have entirely different histories.
115f2667f6
...
9749d5658c
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
BillingRate float64
|
BillingRate float64
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
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"
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package entities
|
|||||||
import "github.com/oklog/ulid/v2"
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Customer struct {
|
type Customer struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
CompanyID int
|
CompanyID int
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package entities
|
|||||||
import "github.com/oklog/ulid/v2"
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
CustomerID int
|
CustomerID int
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TimeEntry struct {
|
type TimeEntry struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
UserID int
|
UserID int
|
||||||
ProjectID int
|
ProjectID int
|
||||||
ActivityID int
|
ActivityID int
|
||||||
|
@ -3,7 +3,7 @@ package entities
|
|||||||
import "github.com/oklog/ulid/v2"
|
import "github.com/oklog/ulid/v2"
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
EntityBase
|
ID ulid.ULID
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Role string
|
Role string
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/oklog/ulid/v2"
|
"github.com/oklog/ulid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ActivityDto struct {
|
type ActivityDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Name string `json:"name"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
BillingRate float64 `json:"billingRate"`
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
BillingRate float64 `json:"billingRate"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActivityCreateDto struct {
|
type ActivityCreateDto struct {
|
||||||
@ -21,10 +16,7 @@ type ActivityCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ActivityUpdateDto struct {
|
type ActivityUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
Name *string `json:"name"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
BillingRate *float64 `json:"billingRate"`
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name *string `json:"name"`
|
|
||||||
BillingRate *float64 `json:"billingRate"`
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/oklog/ulid/v2"
|
"github.com/oklog/ulid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CompanyDto struct {
|
type CompanyDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Name string `json:"name"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompanyCreateDto struct {
|
type CompanyCreateDto struct {
|
||||||
@ -19,9 +14,6 @@ type CompanyCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CompanyUpdateDto struct {
|
type CompanyUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
Name *string `json:"name"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name *string `json:"name"`
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/oklog/ulid/v2"
|
"github.com/oklog/ulid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CustomerDto struct {
|
type CustomerDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Name string `json:"name"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CompanyID int `json:"companyId"`
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
CompanyID int `json:"companyId"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomerCreateDto struct {
|
type CustomerCreateDto struct {
|
||||||
@ -21,10 +16,7 @@ type CustomerCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CustomerUpdateDto struct {
|
type CustomerUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
Name *string `json:"name"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
CompanyID *int `json:"companyId"`
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name *string `json:"name"`
|
|
||||||
CompanyID *int `json:"companyId"`
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/oklog/ulid/v2"
|
"github.com/oklog/ulid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectDto struct {
|
type ProjectDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Name string `json:"name"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CustomerID int `json:"customerId"`
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
CustomerID int `json:"customerId"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProjectCreateDto struct {
|
type ProjectCreateDto struct {
|
||||||
@ -21,10 +16,7 @@ type ProjectCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProjectUpdateDto struct {
|
type ProjectUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
Name *string `json:"name"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
CustomerID *int `json:"customerId"`
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
|
||||||
Name *string `json:"name"`
|
|
||||||
CustomerID *int `json:"customerId"`
|
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TimeEntryDto struct {
|
type TimeEntryDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
UserID int `json:"userId"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
ProjectID int `json:"projectId"`
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
ActivityID int `json:"activityId"`
|
||||||
UserID int `json:"userId"`
|
Start time.Time `json:"start"`
|
||||||
ProjectID int `json:"projectId"`
|
End time.Time `json:"end"`
|
||||||
ActivityID int `json:"activityId"`
|
Description string `json:"description"`
|
||||||
Start time.Time `json:"start"`
|
Billable int `json:"billable"` // Percentage (0-100)
|
||||||
End time.Time `json:"end"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Billable int `json:"billable"` // Percentage (0-100)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeEntryCreateDto struct {
|
type TimeEntryCreateDto struct {
|
||||||
@ -31,15 +28,12 @@ type TimeEntryCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TimeEntryUpdateDto struct {
|
type TimeEntryUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
UserID *int `json:"userId"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
ProjectID *int `json:"projectId"`
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
ActivityID *int `json:"activityId"`
|
||||||
UserID *int `json:"userId"`
|
Start *time.Time `json:"start"`
|
||||||
ProjectID *int `json:"projectId"`
|
End *time.Time `json:"end"`
|
||||||
ActivityID *int `json:"activityId"`
|
Description *string `json:"description"`
|
||||||
Start *time.Time `json:"start"`
|
Billable *int `json:"billable"` // Percentage (0-100)
|
||||||
End *time.Time `json:"end"`
|
|
||||||
Description *string `json:"description"`
|
|
||||||
Billable *int `json:"billable"` // Percentage (0-100)
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/oklog/ulid/v2"
|
"github.com/oklog/ulid/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserDto struct {
|
type UserDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Username string `json:"username"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
Password string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
LastEditorID ulid.ULID `json:"lastEditorID"`
|
Role string `json:"role"`
|
||||||
Username string `json:"username"`
|
CompanyID int `json:"companyId"`
|
||||||
Password string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
HourlyRate float64 `json:"hourlyRate"`
|
||||||
Role string `json:"role"`
|
|
||||||
CompanyID int `json:"companyId"`
|
|
||||||
HourlyRate float64 `json:"hourlyRate"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserCreateDto struct {
|
type UserCreateDto struct {
|
||||||
@ -27,13 +22,10 @@ type UserCreateDto struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserUpdateDto struct {
|
type UserUpdateDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
CreatedAt *time.Time `json:"createdAt"`
|
Username *string `json:"username"`
|
||||||
UpdatedAt *time.Time `json:"updatedAt"`
|
Password *string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
LastEditorID *ulid.ULID `json:"lastEditorID"`
|
Role *string `json:"role"`
|
||||||
Username *string `json:"username"`
|
CompanyID *int `json:"companyId"`
|
||||||
Password *string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
HourlyRate *float64 `json:"hourlyRate"`
|
||||||
Role *string `json:"role"`
|
|
||||||
CompanyID *int `json:"companyId"`
|
|
||||||
HourlyRate *float64 `json:"hourlyRate"`
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@ This document provides an overview of the Time Tracking and Management System. F
|
|||||||
- [Extensibility and Integrations](extensibility_integrations.md)
|
- [Extensibility and Integrations](extensibility_integrations.md)
|
||||||
- [LLM Guidance](llm_guidance.md)
|
- [LLM Guidance](llm_guidance.md)
|
||||||
- [Roadmap](Roadmap.md)
|
- [Roadmap](Roadmap.md)
|
||||||
- [Domain Types](domain_types.md)
|
|
||||||
- [DTOs](dtos.md)
|
|
||||||
|
|
||||||
## Code Examples
|
## Code Examples
|
||||||
- [GORM Entities](code_examples/gorm_entities.go)
|
- [GORM Entities](code_examples/gorm_entities.go)
|
||||||
|
@ -13,40 +13,6 @@ CREATE TABLE companies (
|
|||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Go structs for creating and updating customers
|
|
||||||
-- type CustomerCreate struct {
|
|
||||||
-- Name string
|
|
||||||
-- CompanyID int
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- type CustomerUpdate struct {
|
|
||||||
-- ID ulid.ULID
|
|
||||||
-- Name *string
|
|
||||||
-- CompanyID *int
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- Go structs for creating and updating companies
|
|
||||||
-- type CompanyCreate struct {
|
|
||||||
-- Name string
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- type CompanyUpdate struct {
|
|
||||||
-- ID ulid.ULID
|
|
||||||
-- Name *string
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- Go structs for creating and updating activities
|
|
||||||
-- type ActivityCreate struct {
|
|
||||||
-- Name string
|
|
||||||
-- BillingRate float64
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- type ActivityUpdate struct {
|
|
||||||
-- ID ulid.ULID
|
|
||||||
-- Name *string
|
|
||||||
-- BillingRate *float64
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- Users and Roles
|
-- Users and Roles
|
||||||
CREATE TABLE roles (
|
CREATE TABLE roles (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# Domain Types
|
|
||||||
|
|
||||||
This document describes the domain types used in the Time Tracker application. Domain types represent the core business concepts and are used throughout the application.
|
|
||||||
|
|
||||||
## Activity
|
|
||||||
|
|
||||||
The `Activity` type represents a specific activity that can be tracked, such as "Development", "Meeting", or "Bug Fixing".
|
|
||||||
|
|
||||||
## Company
|
|
||||||
|
|
||||||
The `Company` type represents a tenant in the multi-tenant application. Each company has its own set of users, customers, projects, and activities.
|
|
||||||
|
|
||||||
## Customer
|
|
||||||
|
|
||||||
The `Customer` type represents a customer of a company.
|
|
||||||
|
|
||||||
## Project
|
|
||||||
|
|
||||||
The `Project` type represents a project for a specific customer.
|
|
||||||
|
|
||||||
## TimeEntry
|
|
||||||
|
|
||||||
The `TimeEntry` type represents a time booking for a specific user, project, and activity.
|
|
||||||
|
|
||||||
## User
|
|
||||||
|
|
||||||
The `User` type represents a user of the application. Each user belongs to a company and has a specific role.
|
|
27
docu/dtos.md
27
docu/dtos.md
@ -1,27 +0,0 @@
|
|||||||
# Data Transfer Objects (DTOs)
|
|
||||||
|
|
||||||
This document describes the Data Transfer Objects (DTOs) used in the Time Tracker application. DTOs are used to transfer data between the backend and frontend, and between different layers of the backend.
|
|
||||||
|
|
||||||
## ActivityDto
|
|
||||||
|
|
||||||
The `ActivityDto` type represents a specific activity that can be tracked, such as "Development", "Meeting", or "Bug Fixing". It is used to transfer activity data between the backend and frontend.
|
|
||||||
|
|
||||||
## CompanyDto
|
|
||||||
|
|
||||||
The `CompanyDto` type represents a tenant in the multi-tenant application. Each company has its own set of users, customers, projects, and activities. It is used to transfer company data between the backend and frontend.
|
|
||||||
|
|
||||||
## CustomerDto
|
|
||||||
|
|
||||||
The `CustomerDto` type represents a customer of a company. It is used to transfer customer data between the backend and frontend.
|
|
||||||
|
|
||||||
## ProjectDto
|
|
||||||
|
|
||||||
The `ProjectDto` type represents a project for a specific customer. It is used to transfer project data between the backend and frontend.
|
|
||||||
|
|
||||||
## TimeEntryDto
|
|
||||||
|
|
||||||
The `TimeEntryDto` type represents a time booking for a specific user, project, and activity. It is used to transfer time entry data between the backend and frontend.
|
|
||||||
|
|
||||||
## UserDto
|
|
||||||
|
|
||||||
The `UserDto` type represents a user of the application. Each user belongs to a company and has a specific role. It is used to transfer user data between the backend and frontend.
|
|
@ -1,17 +1,9 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { ActivityDto, ActivityCreateDto, ActivityUpdateDto } from "./dto";
|
import { ActivityDto, ActivityCreateDto, ActivityUpdateDto } from "./dto";
|
||||||
import { UserId, ActivityId } from "./value-ids";
|
|
||||||
|
|
||||||
export type Activity = Omit<ActivityDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
|
export type Activity = ActivityDto;
|
||||||
id: ActivityId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapActivityDtoToActivity = (dto: ActivityDto): Activity => ({
|
export const mapActivityDtoToActivity = (dto: ActivityDto): Activity => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as ActivityId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ActivityCreate = ActivityCreateDto;
|
export type ActivityCreate = ActivityCreateDto;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { UserId } from "./value-ids";
|
|
||||||
|
|
||||||
export type BaseEntity = {
|
|
||||||
createdAt: Date;
|
|
||||||
updatedAt: Date;
|
|
||||||
lastEditorID: UserId;
|
|
||||||
};
|
|
||||||
|
|
@ -1,17 +1,9 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { CompanyDto, CompanyCreateDto, CompanyUpdateDto } from "./dto";
|
import { CompanyDto, CompanyCreateDto, CompanyUpdateDto } from "./dto";
|
||||||
import { UserId, CompanyId } from "./value-ids";
|
|
||||||
|
|
||||||
export type Company = Omit<CompanyDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
|
export type Company = CompanyDto;
|
||||||
id: CompanyId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapCompanyDtoToCompany = (dto: CompanyDto): Company => ({
|
export const mapCompanyDtoToCompany = (dto: CompanyDto): Company => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as CompanyId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CompanyCreate = CompanyCreateDto;
|
export type CompanyCreate = CompanyCreateDto;
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { CustomerDto, CustomerCreateDto, CustomerUpdateDto } from "./dto";
|
import { CustomerDto, CustomerCreateDto, CustomerUpdateDto } from "./dto";
|
||||||
import { UserId, CustomerId } from "./value-ids";
|
|
||||||
|
|
||||||
export type Customer = Omit<CustomerDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
|
export type Customer = CustomerDto;
|
||||||
id: CustomerId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapCustomerDtoToCustomer = (dto: CustomerDto): Customer => ({
|
export const mapCustomerDtoToCustomer = (dto: CustomerDto): Customer => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as CustomerId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CustomerCreate = CustomerCreateDto;
|
export type CustomerCreate = CustomerCreateDto;
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
export interface ActivityDto {
|
export interface ActivityDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
billingRate: number /* float64 */;
|
billingRate: number /* float64 */;
|
||||||
}
|
}
|
||||||
@ -17,9 +14,6 @@ export interface ActivityCreateDto {
|
|||||||
}
|
}
|
||||||
export interface ActivityUpdateDto {
|
export interface ActivityUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
billingRate?: number /* float64 */;
|
billingRate?: number /* float64 */;
|
||||||
}
|
}
|
||||||
@ -29,9 +23,6 @@ export interface ActivityUpdateDto {
|
|||||||
|
|
||||||
export interface CompanyDto {
|
export interface CompanyDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface CompanyCreateDto {
|
export interface CompanyCreateDto {
|
||||||
@ -39,9 +30,6 @@ export interface CompanyCreateDto {
|
|||||||
}
|
}
|
||||||
export interface CompanyUpdateDto {
|
export interface CompanyUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,9 +38,6 @@ export interface CompanyUpdateDto {
|
|||||||
|
|
||||||
export interface CustomerDto {
|
export interface CustomerDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
companyId: number /* int */;
|
companyId: number /* int */;
|
||||||
}
|
}
|
||||||
@ -62,9 +47,6 @@ export interface CustomerCreateDto {
|
|||||||
}
|
}
|
||||||
export interface CustomerUpdateDto {
|
export interface CustomerUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
companyId?: number /* int */;
|
companyId?: number /* int */;
|
||||||
}
|
}
|
||||||
@ -74,9 +56,6 @@ export interface CustomerUpdateDto {
|
|||||||
|
|
||||||
export interface ProjectDto {
|
export interface ProjectDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
customerId: number /* int */;
|
customerId: number /* int */;
|
||||||
}
|
}
|
||||||
@ -86,9 +65,6 @@ export interface ProjectCreateDto {
|
|||||||
}
|
}
|
||||||
export interface ProjectUpdateDto {
|
export interface ProjectUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
customerId?: number /* int */;
|
customerId?: number /* int */;
|
||||||
}
|
}
|
||||||
@ -98,9 +74,6 @@ export interface ProjectUpdateDto {
|
|||||||
|
|
||||||
export interface TimeEntryDto {
|
export interface TimeEntryDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
userId: number /* int */;
|
userId: number /* int */;
|
||||||
projectId: number /* int */;
|
projectId: number /* int */;
|
||||||
activityId: number /* int */;
|
activityId: number /* int */;
|
||||||
@ -120,9 +93,6 @@ export interface TimeEntryCreateDto {
|
|||||||
}
|
}
|
||||||
export interface TimeEntryUpdateDto {
|
export interface TimeEntryUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
userId?: number /* int */;
|
userId?: number /* int */;
|
||||||
projectId?: number /* int */;
|
projectId?: number /* int */;
|
||||||
activityId?: number /* int */;
|
activityId?: number /* int */;
|
||||||
@ -137,9 +107,6 @@ export interface TimeEntryUpdateDto {
|
|||||||
|
|
||||||
export interface UserDto {
|
export interface UserDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
lastEditorID: string;
|
|
||||||
username: string;
|
username: string;
|
||||||
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
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;
|
||||||
@ -155,9 +122,6 @@ export interface UserCreateDto {
|
|||||||
}
|
}
|
||||||
export interface UserUpdateDto {
|
export interface UserUpdateDto {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt?: string;
|
|
||||||
updatedAt?: string;
|
|
||||||
lastEditorID?: string;
|
|
||||||
username?: string;
|
username?: string;
|
||||||
password?: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
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;
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { ProjectDto, ProjectCreateDto, ProjectUpdateDto } from "./dto";
|
import { ProjectDto, ProjectCreateDto, ProjectUpdateDto } from "./dto";
|
||||||
import { UserId, ProjectId } from "./value-ids";
|
|
||||||
|
|
||||||
export type Project = Omit<ProjectDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
|
export type Project = ProjectDto;
|
||||||
id: ProjectId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapProjectDtoToProject = (dto: ProjectDto): Project => ({
|
export const mapProjectDtoToProject = (dto: ProjectDto): Project => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as ProjectId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type ProjectCreate = ProjectCreateDto;
|
export type ProjectCreate = ProjectCreateDto;
|
||||||
|
@ -1,27 +1,14 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { TimeEntryDto, TimeEntryCreateDto, TimeEntryUpdateDto } from "./dto";
|
import { TimeEntryDto, TimeEntryCreateDto, TimeEntryUpdateDto } from "./dto";
|
||||||
import { UserId, ProjectId, ActivityId, TimeEntryId } from "./value-ids";
|
|
||||||
|
|
||||||
export type TimeEntry = Omit<TimeEntryDto, "id" | "start" | "end" | "userId" | "projectId" | "activityId" | "lastEditorID" | "createdAt" | "updatedAt"> & {
|
export type TimeEntry = Omit<TimeEntryDto, "start" | "end"> & {
|
||||||
id: TimeEntryId;
|
|
||||||
start: Date;
|
start: Date;
|
||||||
end: Date;
|
end: Date;
|
||||||
userId: UserId;
|
};
|
||||||
projectId: ProjectId;
|
|
||||||
activityId: ActivityId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapTimeEntryDtoToTimeEntry = (dto: TimeEntryDto): TimeEntry => ({
|
export const mapTimeEntryDtoToTimeEntry = (dto: TimeEntryDto): TimeEntry => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as TimeEntryId,
|
|
||||||
start: new Date(dto.start),
|
start: new Date(dto.start),
|
||||||
end: new Date(dto.end),
|
end: new Date(dto.end),
|
||||||
userId: dto.userId.toString() as UserId,
|
|
||||||
projectId: dto.projectId.toString() as ProjectId,
|
|
||||||
activityId: dto.activityId.toString() as ActivityId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TimeEntryCreate = Omit<TimeEntryCreateDto, "start" | "end"> & {
|
export type TimeEntryCreate = Omit<TimeEntryCreateDto, "start" | "end"> & {
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import { BaseEntity } from "./base";
|
|
||||||
import { UserDto, UserCreateDto, UserUpdateDto } from "./dto";
|
import { UserDto, UserCreateDto, UserUpdateDto } from "./dto";
|
||||||
import { UserId } from "./value-ids";
|
|
||||||
|
|
||||||
export type User = Omit<UserDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
|
export type User = Omit<UserDto, never>;
|
||||||
id: UserId;
|
|
||||||
} & BaseEntity;
|
|
||||||
|
|
||||||
export const mapUserDtoToUser = (dto: UserDto): User => ({
|
export const mapUserDtoToUser = (dto: UserDto): User => ({
|
||||||
...dto,
|
...dto,
|
||||||
id: dto.id as UserId,
|
|
||||||
createdAt: new Date(dto.createdAt),
|
|
||||||
updatedAt: new Date(dto.updatedAt),
|
|
||||||
lastEditorID: dto.lastEditorID as UserId,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UserCreate = Omit<UserCreateDto, never>;
|
export type UserCreate = Omit<UserCreateDto, never>;
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
export type ValueId<T = string> = string & { __valueId: T };
|
|
||||||
|
|
||||||
export type CustomerId = ValueId<"CustomerId">;
|
|
||||||
export type ProjectId = ValueId<"ProjectId">;
|
|
||||||
export type TimeEntryId = ValueId<"TimeEntryId">;
|
|
||||||
export type CompanyId = ValueId<"CompanyId">;
|
|
||||||
export type UserId = ValueId<"UserId">;
|
|
||||||
export type RoleId = ValueId<"RoleId">;
|
|
||||||
export type PermissionId = ValueId<"PermissionId">;
|
|
||||||
export type ActivityId = ValueId<"ActivityId">;
|
|
Loading…
x
Reference in New Issue
Block a user