implemented other repos, services, objects ...
This commit is contained in:
@@ -7,18 +7,6 @@ import 'package:fpdart/fpdart.dart';
|
||||
import 'package:orm/orm.dart';
|
||||
|
||||
class ProjectDboMapper {
|
||||
TaskEither<IError, ProjectDbo> toDbo(Project project) {
|
||||
return TaskEither.of(ProjectDbo(
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
description: project.description,
|
||||
clientId: project.clientId,
|
||||
userId: project.userId,
|
||||
createdAt: project.createdAt,
|
||||
updatedAt: project.updatedAt,
|
||||
));
|
||||
}
|
||||
|
||||
TaskEither<IError, Project> fromDbo(ProjectDbo dbo) {
|
||||
return TaskEither.of(Project(
|
||||
id: dbo.id!,
|
||||
@@ -31,9 +19,14 @@ class ProjectDboMapper {
|
||||
));
|
||||
}
|
||||
|
||||
TaskEither<IError, List<Project>> listFrom(Iterable<ProjectDbo> dbos) {
|
||||
return TaskEither.traverseList(dbos.toList(), fromDbo);
|
||||
}
|
||||
|
||||
TaskEither<IError, ProjectDboCreateInput> fromCreatetoDbo(
|
||||
ProjectCreate project) {
|
||||
return TaskEither.of(ProjectDboCreateInput(
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
description: project.description.let(PrismaUnion.$1),
|
||||
clientId: project.clientId.let(PrismaUnion.$1),
|
||||
@@ -57,8 +50,4 @@ class ProjectDboMapper {
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
TaskEither<IError, List<Project>> listFrom(Iterable<ProjectDbo> dbos) {
|
||||
return TaskEither.traverseList(dbos.toList(), fromDbo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:backend_dart/common/extensions.dart';
|
||||
import 'package:backend_dart/domain/entities/project_task.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:backend_dart/infrastructure/persistence/db/model.dart';
|
||||
import 'package:backend_dart/infrastructure/persistence/db/prisma.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:orm/orm.dart';
|
||||
|
||||
class ProjectTaskDboMapper {
|
||||
TaskEither<IError, ProjectTask> from(ProjectTaskDbo target) =>
|
||||
TaskEither.of(ProjectTask(
|
||||
id: target.id!,
|
||||
name: target.name!,
|
||||
description: target.description,
|
||||
projectId: target.projectId!,
|
||||
createdAt: target.createdAt!,
|
||||
updatedAt: target.updatedAt!,
|
||||
));
|
||||
|
||||
TaskEither<IError, List<ProjectTask>> listFrom(
|
||||
Iterable<ProjectTaskDbo> targets) {
|
||||
return TaskEither.traverseList(targets.toList(), from);
|
||||
}
|
||||
|
||||
TaskEither<IError, ProjectTaskDboCreateInput> fromCreateTo(
|
||||
ProjectTaskCreate origin) =>
|
||||
TaskEither.of(ProjectTaskDboCreateInput(
|
||||
id: origin.id,
|
||||
name: origin.name,
|
||||
description: origin.description.let(PrismaUnion.$1),
|
||||
project: ProjectDboCreateNestedOneWithoutTasksInput(
|
||||
connect: ProjectDboWhereUniqueInput(
|
||||
id: origin.projectId,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
TaskEither<IError, ProjectTaskDboUpdateInput> fromUpdateTo(
|
||||
ProjectTaskUpdate origin) =>
|
||||
TaskEither.of(ProjectTaskDboUpdateInput(
|
||||
id: PrismaUnion.$1(origin.id),
|
||||
name: origin.name?.let(PrismaUnion.$1),
|
||||
description: origin.description?.let(PrismaUnion.$1),
|
||||
project: origin.projectId?.let(
|
||||
(projectId) => ProjectDboUpdateOneRequiredWithoutTasksNestedInput(
|
||||
connect: ProjectDboWhereUniqueInput(
|
||||
id: projectId,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:backend_dart/common/extensions.dart';
|
||||
import 'package:backend_dart/domain/entities/time_entry.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:backend_dart/infrastructure/persistence/db/model.dart';
|
||||
import 'package:backend_dart/infrastructure/persistence/db/prisma.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:orm/orm.dart';
|
||||
|
||||
class TimeEntryDboMapper {
|
||||
TaskEither<IError, TimeEntry> from(TimeEntryDbo target) => TaskEither.of(
|
||||
TimeEntry(
|
||||
id: target.id!,
|
||||
startTime: target.startTime!,
|
||||
endTime: target.endTime!,
|
||||
description: target.description,
|
||||
userId: target.userId!,
|
||||
projectId: target.projectId!,
|
||||
createdAt: target.createdAt!,
|
||||
updatedAt: target.updatedAt!,
|
||||
),
|
||||
);
|
||||
|
||||
TaskEither<IError, List<TimeEntry>> listFrom(Iterable<TimeEntryDbo> targets) {
|
||||
return TaskEither.traverseList(targets.toList(), from);
|
||||
}
|
||||
|
||||
TaskEither<IError, TimeEntryDboCreateInput> fromCreateTo(
|
||||
TimeEntryCreate origin) =>
|
||||
TaskEither.of(TimeEntryDboCreateInput(
|
||||
id: origin.id,
|
||||
startTime: origin.startTime,
|
||||
endTime: origin.endTime,
|
||||
description: origin.description.let(PrismaUnion.$1),
|
||||
user: UserDboCreateNestedOneWithoutTimeEntriesInput(
|
||||
connect: UserDboWhereUniqueInput(
|
||||
id: origin.userId,
|
||||
),
|
||||
),
|
||||
project: ProjectDboCreateNestedOneWithoutTimeEntriesInput(
|
||||
connect: ProjectDboWhereUniqueInput(
|
||||
id: origin.projectId,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
TaskEither<IError, TimeEntryDboUpdateInput> fromUpdateTo(
|
||||
TimeEntryUpdate origin) =>
|
||||
TaskEither.of(TimeEntryDboUpdateInput(
|
||||
id: PrismaUnion.$1(origin.id),
|
||||
startTime: origin.startTime?.let(PrismaUnion.$1),
|
||||
endTime: origin.endTime?.let(PrismaUnion.$1),
|
||||
description: origin.description?.let(PrismaUnion.$1),
|
||||
user: origin.userId?.let(
|
||||
(userId) => UserDboUpdateOneRequiredWithoutTimeEntriesNestedInput(
|
||||
connect: UserDboWhereUniqueInput(
|
||||
id: userId,
|
||||
),
|
||||
),
|
||||
),
|
||||
project: origin.projectId?.let(
|
||||
(projectId) =>
|
||||
ProjectDboUpdateOneRequiredWithoutTimeEntriesNestedInput(
|
||||
connect: ProjectDboWhereUniqueInput(
|
||||
id: projectId,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user