extentions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
f6d68fb1fc
commit
f18dd0d7ac
2 changed files with 55 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:mnemo_cards_backend/database/database.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
/// Extension для конвертации GameCard в GameCardDto для admin API
|
||||
extension GameCardAdminExtension on GameCard {
|
||||
/// Конвертация GameCard в GameCardDto с учетом packId и конвертации изображений
|
||||
GameCardDto toGameCardDtoWithPack(
|
||||
String? packId,
|
||||
String? Function(String?, String?, String) convertImageToUrl,
|
||||
String? Function(String?, String?, String) convertImageBackToUrl,
|
||||
) {
|
||||
return GameCardDto(
|
||||
id: id,
|
||||
original: original,
|
||||
translation: translation,
|
||||
mnemo: mnemo ?? '',
|
||||
image: convertImageToUrl(image, packId, id),
|
||||
imageBack: convertImageBackToUrl(imageBack, packId, id),
|
||||
back: back,
|
||||
transcription: transcription ?? '',
|
||||
transcriptionMnemo: transcriptionMnemo,
|
||||
);
|
||||
}
|
||||
|
||||
/// Простая конвертация GameCard в GameCardDto без конвертации изображений
|
||||
GameCardDto toGameCardDto() {
|
||||
return GameCardDto(
|
||||
id: id,
|
||||
original: original,
|
||||
translation: translation,
|
||||
mnemo: mnemo ?? '',
|
||||
image: image,
|
||||
imageBack: imageBack,
|
||||
back: back,
|
||||
transcription: transcription ?? '',
|
||||
transcriptionMnemo: transcriptionMnemo,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:mnemo_cards_backend/database/database.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
/// Extension для конвертации VoiceModel в AdminVoiceResponse
|
||||
extension VoiceModelAdminExtension on VoiceModel {
|
||||
/// Конвертация VoiceModel в AdminVoiceResponse
|
||||
AdminVoiceResponse toAdminVoiceResponse() {
|
||||
return AdminVoiceResponse(
|
||||
id: id,
|
||||
cardId: cardId,
|
||||
voiceUrl: voiceUrl,
|
||||
language: language,
|
||||
createdAt: createdAt.dateTime.toIso8601String(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue