1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-16 07:24:40 +02:00

refactor(server): use date type for entities (#2602)

This commit is contained in:
Michel Heusschen
2023-05-30 15:15:56 +02:00
committed by GitHub
parent 3d505e425d
commit 789e3e3924
49 changed files with 243 additions and 217 deletions

View File

@ -28,7 +28,7 @@ class AdminSignupResponseDto {
String lastName;
String createdAt;
DateTime createdAt;
@override
bool operator ==(Object other) => identical(this, other) || other is AdminSignupResponseDto &&
@ -56,7 +56,7 @@ class AdminSignupResponseDto {
json[r'email'] = this.email;
json[r'firstName'] = this.firstName;
json[r'lastName'] = this.lastName;
json[r'createdAt'] = this.createdAt;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
return json;
}
@ -83,7 +83,7 @@ class AdminSignupResponseDto {
email: mapValueOfType<String>(json, r'email')!,
firstName: mapValueOfType<String>(json, r'firstName')!,
lastName: mapValueOfType<String>(json, r'lastName')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!,
createdAt: mapDateTime(json, r'createdAt', '')!,
);
}
return null;

View File

@ -34,9 +34,9 @@ class AlbumResponseDto {
String albumName;
String createdAt;
DateTime createdAt;
String updatedAt;
DateTime updatedAt;
String? albumThumbnailAssetId;
@ -86,8 +86,8 @@ class AlbumResponseDto {
json[r'id'] = this.id;
json[r'ownerId'] = this.ownerId;
json[r'albumName'] = this.albumName;
json[r'createdAt'] = this.createdAt;
json[r'updatedAt'] = this.updatedAt;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
if (this.albumThumbnailAssetId != null) {
json[r'albumThumbnailAssetId'] = this.albumThumbnailAssetId;
} else {
@ -123,8 +123,8 @@ class AlbumResponseDto {
id: mapValueOfType<String>(json, r'id')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!,
albumName: mapValueOfType<String>(json, r'albumName')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!,
updatedAt: mapValueOfType<String>(json, r'updatedAt')!,
createdAt: mapDateTime(json, r'createdAt', '')!,
updatedAt: mapDateTime(json, r'updatedAt', '')!,
albumThumbnailAssetId: mapValueOfType<String>(json, r'albumThumbnailAssetId'),
shared: mapValueOfType<bool>(json, r'shared')!,
sharedUsers: UserResponseDto.listFromJson(json[r'sharedUsers']),

View File

@ -23,9 +23,9 @@ class APIKeyResponseDto {
String name;
String createdAt;
DateTime createdAt;
String updatedAt;
DateTime updatedAt;
@override
bool operator ==(Object other) => identical(this, other) || other is APIKeyResponseDto &&
@ -49,8 +49,8 @@ class APIKeyResponseDto {
final json = <String, dynamic>{};
json[r'id'] = this.id;
json[r'name'] = this.name;
json[r'createdAt'] = this.createdAt;
json[r'updatedAt'] = this.updatedAt;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
return json;
}
@ -75,8 +75,8 @@ class APIKeyResponseDto {
return APIKeyResponseDto(
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!,
updatedAt: mapValueOfType<String>(json, r'updatedAt')!,
createdAt: mapDateTime(json, r'createdAt', '')!,
updatedAt: mapDateTime(json, r'updatedAt', '')!,
);
}
return null;

View File

@ -29,7 +29,7 @@ class CreateAssetsShareLinkDto {
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? expiresAt;
DateTime? expiresAt;
///
/// Please note: This property should have been non-nullable! Since the specification file
@ -89,7 +89,7 @@ class CreateAssetsShareLinkDto {
final json = <String, dynamic>{};
json[r'assetIds'] = this.assetIds;
if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt;
json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else {
// json[r'expiresAt'] = null;
}
@ -138,7 +138,7 @@ class CreateAssetsShareLinkDto {
assetIds: json[r'assetIds'] is Iterable
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
expiresAt: mapValueOfType<String>(json, r'expiresAt'),
expiresAt: mapDateTime(json, r'expiresAt', ''),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'),

View File

@ -28,7 +28,7 @@ class EditSharedLinkDto {
///
String? description;
String? expiresAt;
DateTime? expiresAt;
///
/// Please note: This property should have been non-nullable! Since the specification file
@ -82,7 +82,7 @@ class EditSharedLinkDto {
// json[r'description'] = null;
}
if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt;
json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else {
// json[r'expiresAt'] = null;
}
@ -124,7 +124,7 @@ class EditSharedLinkDto {
return EditSharedLinkDto(
description: mapValueOfType<String>(json, r'description'),
expiresAt: mapValueOfType<String>(json, r'expiresAt'),
expiresAt: mapDateTime(json, r'expiresAt', ''),
allowUpload: mapValueOfType<bool>(json, r'allowUpload'),
allowDownload: mapValueOfType<bool>(json, r'allowDownload'),
showExif: mapValueOfType<bool>(json, r'showExif'),

View File

@ -43,9 +43,9 @@ class SharedLinkResponseDto {
String key;
String createdAt;
DateTime createdAt;
String? expiresAt;
DateTime? expiresAt;
List<AssetResponseDto> assets;
@ -108,9 +108,9 @@ class SharedLinkResponseDto {
}
json[r'userId'] = this.userId;
json[r'key'] = this.key;
json[r'createdAt'] = this.createdAt;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
if (this.expiresAt != null) {
json[r'expiresAt'] = this.expiresAt;
json[r'expiresAt'] = this.expiresAt!.toUtc().toIso8601String();
} else {
// json[r'expiresAt'] = null;
}
@ -150,8 +150,8 @@ class SharedLinkResponseDto {
description: mapValueOfType<String>(json, r'description'),
userId: mapValueOfType<String>(json, r'userId')!,
key: mapValueOfType<String>(json, r'key')!,
createdAt: mapValueOfType<String>(json, r'createdAt')!,
expiresAt: mapValueOfType<String>(json, r'expiresAt'),
createdAt: mapDateTime(json, r'createdAt', '')!,
expiresAt: mapDateTime(json, r'expiresAt', ''),
assets: AssetResponseDto.listFromJson(json[r'assets']),
album: AlbumResponseDto.fromJson(json[r'album']),
allowUpload: mapValueOfType<bool>(json, r'allowUpload')!,

View File

@ -18,12 +18,12 @@ class UserResponseDto {
required this.firstName,
required this.lastName,
required this.storageLabel,
required this.createdAt,
required this.profileImagePath,
required this.shouldChangePassword,
required this.isAdmin,
this.deletedAt,
this.updatedAt,
required this.createdAt,
required this.deletedAt,
required this.updatedAt,
required this.oauthId,
});
@ -37,29 +37,17 @@ class UserResponseDto {
String? storageLabel;
String createdAt;
String profileImagePath;
bool shouldChangePassword;
bool isAdmin;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime createdAt;
DateTime? deletedAt;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? updatedAt;
DateTime updatedAt;
String oauthId;
@ -70,10 +58,10 @@ class UserResponseDto {
other.firstName == firstName &&
other.lastName == lastName &&
other.storageLabel == storageLabel &&
other.createdAt == createdAt &&
other.profileImagePath == profileImagePath &&
other.shouldChangePassword == shouldChangePassword &&
other.isAdmin == isAdmin &&
other.createdAt == createdAt &&
other.deletedAt == deletedAt &&
other.updatedAt == updatedAt &&
other.oauthId == oauthId;
@ -86,16 +74,16 @@ class UserResponseDto {
(firstName.hashCode) +
(lastName.hashCode) +
(storageLabel == null ? 0 : storageLabel!.hashCode) +
(createdAt.hashCode) +
(profileImagePath.hashCode) +
(shouldChangePassword.hashCode) +
(isAdmin.hashCode) +
(createdAt.hashCode) +
(deletedAt == null ? 0 : deletedAt!.hashCode) +
(updatedAt == null ? 0 : updatedAt!.hashCode) +
(updatedAt.hashCode) +
(oauthId.hashCode);
@override
String toString() => 'UserResponseDto[id=$id, email=$email, firstName=$firstName, lastName=$lastName, storageLabel=$storageLabel, createdAt=$createdAt, profileImagePath=$profileImagePath, shouldChangePassword=$shouldChangePassword, isAdmin=$isAdmin, deletedAt=$deletedAt, updatedAt=$updatedAt, oauthId=$oauthId]';
String toString() => 'UserResponseDto[id=$id, email=$email, firstName=$firstName, lastName=$lastName, storageLabel=$storageLabel, profileImagePath=$profileImagePath, shouldChangePassword=$shouldChangePassword, isAdmin=$isAdmin, createdAt=$createdAt, deletedAt=$deletedAt, updatedAt=$updatedAt, oauthId=$oauthId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -108,20 +96,16 @@ class UserResponseDto {
} else {
// json[r'storageLabel'] = null;
}
json[r'createdAt'] = this.createdAt;
json[r'profileImagePath'] = this.profileImagePath;
json[r'shouldChangePassword'] = this.shouldChangePassword;
json[r'isAdmin'] = this.isAdmin;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
if (this.deletedAt != null) {
json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String();
} else {
// json[r'deletedAt'] = null;
}
if (this.updatedAt != null) {
json[r'updatedAt'] = this.updatedAt;
} else {
// json[r'updatedAt'] = null;
}
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
json[r'oauthId'] = this.oauthId;
return json;
}
@ -150,12 +134,12 @@ class UserResponseDto {
firstName: mapValueOfType<String>(json, r'firstName')!,
lastName: mapValueOfType<String>(json, r'lastName')!,
storageLabel: mapValueOfType<String>(json, r'storageLabel'),
createdAt: mapValueOfType<String>(json, r'createdAt')!,
profileImagePath: mapValueOfType<String>(json, r'profileImagePath')!,
shouldChangePassword: mapValueOfType<bool>(json, r'shouldChangePassword')!,
isAdmin: mapValueOfType<bool>(json, r'isAdmin')!,
createdAt: mapDateTime(json, r'createdAt', '')!,
deletedAt: mapDateTime(json, r'deletedAt', ''),
updatedAt: mapValueOfType<String>(json, r'updatedAt'),
updatedAt: mapDateTime(json, r'updatedAt', '')!,
oauthId: mapValueOfType<String>(json, r'oauthId')!,
);
}
@ -209,10 +193,12 @@ class UserResponseDto {
'firstName',
'lastName',
'storageLabel',
'createdAt',
'profileImagePath',
'shouldChangePassword',
'isAdmin',
'createdAt',
'deletedAt',
'updatedAt',
'oauthId',
};
}