implemented other repos, services, objects ...
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:backend_dart/application/service/dto/project_dto.dart';
|
||||
import 'package:backend_dart/domain/entities/project.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class ProjectDtoMapper {
|
||||
TaskEither<IError, ProjectDto> to(Project entity) => TaskEither.of(ProjectDto(
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
description: entity.description,
|
||||
clientId: entity.clientId,
|
||||
userId: entity.userId,
|
||||
createdAt: entity.createdAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
));
|
||||
|
||||
TaskEither<IError, List<ProjectDto>> listTo(Iterable<Project> origins) {
|
||||
return TaskEither.traverseList(origins.toList(), to);
|
||||
}
|
||||
|
||||
TaskEither<IError, ProjectCreate> fromCreateTo(ProjectCreateDto origin) =>
|
||||
TaskEither.of(ProjectCreate(
|
||||
name: origin.name,
|
||||
description: origin.description,
|
||||
clientId: origin.clientId,
|
||||
userId: origin.userId,
|
||||
));
|
||||
|
||||
TaskEither<IError, ProjectUpdate> fromUpdateTo(
|
||||
ProjectUpdateDto origin, String id) =>
|
||||
TaskEither.of(ProjectUpdate(
|
||||
id: id,
|
||||
name: origin.name,
|
||||
description: origin.description,
|
||||
clientId: origin.clientId,
|
||||
userId: origin.userId,
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:backend_dart/application/service/dto/project_task_dto.dart';
|
||||
import 'package:backend_dart/domain/entities/project_task.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class ProjectTaskDtoMapper {
|
||||
TaskEither<IError, ProjectTaskDto> to(ProjectTask entity) =>
|
||||
TaskEither.of(ProjectTaskDto(
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
description: entity.description,
|
||||
projectId: entity.projectId,
|
||||
createdAt: entity.createdAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
));
|
||||
|
||||
TaskEither<IError, List<ProjectTaskDto>> listTo(
|
||||
Iterable<ProjectTask> origins) {
|
||||
return TaskEither.traverseList(origins.toList(), to);
|
||||
}
|
||||
|
||||
TaskEither<IError, ProjectTaskCreate> fromCreateTo(
|
||||
ProjectTaskCreateDto origin) =>
|
||||
TaskEither.of(ProjectTaskCreate(
|
||||
name: origin.name,
|
||||
description: origin.description,
|
||||
projectId: origin.projectId,
|
||||
));
|
||||
|
||||
TaskEither<IError, ProjectTaskUpdate> fromUpdateTo(
|
||||
ProjectTaskUpdateDto origin, String id) =>
|
||||
TaskEither.of(ProjectTaskUpdate(
|
||||
id: id,
|
||||
name: origin.name,
|
||||
description: origin.description,
|
||||
projectId: origin.projectId,
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:backend_dart/application/service/dto/time_entry_dto.dart';
|
||||
import 'package:backend_dart/domain/entities/time_entry.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class TimeEntryDtoMapper {
|
||||
TaskEither<IError, TimeEntryDto> to(TimeEntry entity) => TaskEither.of(
|
||||
TimeEntryDto(
|
||||
id: entity.id,
|
||||
startTime: entity.startTime,
|
||||
endTime: entity.endTime,
|
||||
description: entity.description,
|
||||
userId: entity.userId,
|
||||
projectId: entity.projectId,
|
||||
createdAt: entity.createdAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
),
|
||||
);
|
||||
|
||||
TaskEither<IError, List<TimeEntryDto>> listTo(Iterable<TimeEntry> origins) {
|
||||
return TaskEither.traverseList(origins.toList(), to);
|
||||
}
|
||||
|
||||
TaskEither<IError, TimeEntryCreate> fromCreateTo(TimeEntryCreateDto origin) =>
|
||||
TaskEither.of(TimeEntryCreate(
|
||||
startTime: origin.startTime,
|
||||
endTime: origin.endTime,
|
||||
description: origin.description,
|
||||
userId: origin.userId,
|
||||
projectId: origin.projectId,
|
||||
));
|
||||
|
||||
TaskEither<IError, TimeEntryUpdate> fromUpdateTo(
|
||||
TimeEntryUpdateDto origin, String id) =>
|
||||
TaskEither.of(TimeEntryUpdate(
|
||||
id: id,
|
||||
startTime: origin.startTime,
|
||||
endTime: origin.endTime,
|
||||
description: origin.description,
|
||||
userId: origin.userId,
|
||||
projectId: origin.projectId,
|
||||
));
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'package:backend_dart/application/service/dto/user_dto.dart';
|
||||
import 'package:backend_dart/domain/entities/user.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:backend_dart/domain/interface/mapper.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class UserDtoMapper implements IMapper<User, UserDto> {
|
||||
@override
|
||||
class UserDtoMapper {
|
||||
TaskEither<IError, UserDto> to(User entity) => TaskEither.of(UserDto(
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
@@ -13,21 +11,7 @@ class UserDtoMapper implements IMapper<User, UserDto> {
|
||||
createdAt: entity.createdAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
));
|
||||
@override
|
||||
TaskEither<IError, User> from(UserDto dto) => TaskEither.of(User(
|
||||
id: dto.id,
|
||||
name: dto.name,
|
||||
email: dto.email,
|
||||
createdAt: dto.createdAt,
|
||||
updatedAt: dto.updatedAt,
|
||||
));
|
||||
|
||||
@override
|
||||
TaskEither<IError, List<User>> listFrom(Iterable<UserDto> targets) {
|
||||
return TaskEither.traverseList(targets.toList(), from);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<IError, List<UserDto>> listTo(Iterable<User> origins) {
|
||||
return TaskEither.traverseList(origins.toList(), to);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user