Skip to content

Commit 3bd83ea

Browse files
committed
feat(lib-interfaces): implement project CRUD on interfaces #3
1 parent 9c43145 commit 3bd83ea

33 files changed

+1084
-298
lines changed

devtools_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This file stores settings for Dart & Flutter DevTools.
2+
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
3+
extensions:

lib/domain/entities.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export "entities/product_entity.dart";
2-
export "entities/user_entity.dart";
31
export "entities/modules.dart";

lib/domain/entities/libs/types/entity.dart

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ part "entity.g.dart";
88

99
@Freezed(copyWith: false)
1010
@JsonSerializable()
11-
abstract base class Entity with _$Entity {
12-
Entity({this.id = 0, DateTime? createdAt, DateTime? updatedAt}) {
13-
final now = DateTime.now().toUtc();
14-
15-
this.createdAt = createdAt ?? now;
16-
this.updatedAt = updatedAt ?? now;
17-
}
18-
11+
class Entity with _$Entity {
1912
/// Entity identifier.
2013
///
2114
/// Should only be provided if you want to update this entity.
@@ -32,10 +25,14 @@ abstract base class Entity with _$Entity {
3225
@override
3326
late final DateTime updatedAt;
3427

28+
Entity({this.id = 0, DateTime? createdAt, DateTime? updatedAt}) {
29+
final now = DateTime.now().toUtc();
30+
31+
this.createdAt = createdAt ?? now;
32+
this.updatedAt = updatedAt ?? now;
33+
}
34+
3535
factory Entity.fromJson(Map<String, dynamic> json) => _$EntityFromJson(json);
3636

3737
Map<String, dynamic> toJson() => _$EntityToJson(this);
38-
39-
/// Creates a copy of this entity with the specified properties.
40-
Object get copyWith;
4138
}

lib/domain/entities/modules/project.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ part "project.g.dart";
88
@freezed
99
@JsonSerializable()
1010
final class Project extends Entity with _$Project {
11+
@override
12+
final String name;
13+
14+
@override
15+
final String? description;
16+
1117
Project({
1218
super.id,
1319
super.createdAt,
@@ -16,12 +22,6 @@ final class Project extends Entity with _$Project {
1622
this.description,
1723
});
1824

19-
@override
20-
final String name;
21-
22-
@override
23-
final String? description;
24-
2525
factory Project.fromJson(Map<String, dynamic> json) =>
2626
_$ProjectFromJson(json);
2727

lib/domain/entities/product_entity.dart

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/domain/entities/user_entity.dart

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/infrastructures/libs/data/local/modules/projects_local_data.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ class ProjectsLocalData extends DatabaseAccessor<AppDatabase>
1818
required String name,
1919
String? description,
2020
}) async {
21+
final Value<String?> descriptionValue =
22+
description?.isNotEmpty ?? true ? Value(description) : Value(null);
23+
2124
return projects.insertReturning(
22-
ProjectsCompanion.insert(name: name, description: Value(description)),
25+
ProjectsCompanion.insert(name: name, description: descriptionValue),
2326
);
2427
}
2528

@@ -44,12 +47,14 @@ class ProjectsLocalData extends DatabaseAccessor<AppDatabase>
4447
final updatedAt = DateTime.now().toUtc();
4548

4649
final Value<String> nameValue = name == null ? Value.absent() : Value(name);
50+
final Value<String?> descriptionValue =
51+
description?.isNotEmpty ?? true ? Value(description) : Value(null);
4752

4853
final results = await (projects.update()..where((e) => e.id.equals(id)))
4954
.writeReturning(
5055
ProjectsCompanion(
5156
name: nameValue,
52-
description: Value(description),
57+
description: descriptionValue,
5358
updatedAt: Value(updatedAt),
5459
),
5560
);

lib/interfaces/libs/providers.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export "providers/auth_provider.dart";
2-
export "providers/product_providers.dart";
1+
export "providers/projects_provider.dart";
2+
export "providers/project_detail_provider.dart";

lib/interfaces/libs/providers/auth_provider.dart

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/interfaces/libs/providers/product_providers.dart

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)