“DaisyWu” 30d8e8d525 1,预计产生短信条数,短信和邮件差异化处理
2,模板内容没有对应的,已参考通通锁修改
3,列表和点开详情,只有自己输入的内容已修改
2024-07-02 17:42:26 +08:00

102 lines
2.6 KiB
Dart

import 'dart:convert';
class NewSMSTemplateEntity {
NewSMSTemplateEntity({
this.errorCode,
this.description,
this.errorMsg,
this.dataList,
});
NewSMSTemplateEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
if (json['data'] != null) {
dataList = <SMSTemplateData>[];
json['data'].forEach((v) {
dataList!.add(SMSTemplateData.fromJson(v));
});
}
}
int? errorCode;
String? description;
String? errorMsg;
List<SMSTemplateData>? dataList;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (dataList != null) {
data['data'] = dataList!.map((v) => v.toJson()).toList();
}
return data;
}
}
class SMSTemplateData {
SMSTemplateData({
this.contentType,
this.typeName,
this.template,
this.fixedKey,
this.templatePreviewCode,
});
SMSTemplateData.fromJson(Map<String, dynamic> json) {
contentType = json['content_type'];
typeName = json['typeName'];
template = json['template'];
fixedKey = json['fixed_key'];
templatePreviewCode = json['template_preview_code'] != null
? jsonEncode(json['template_preview_code'])
: null;
}
int? contentType;
String? typeName;
String? template;
String? fixedKey;
String? templatePreviewCode; // Changed to String
String? regards = '';
String? tips = '';
int? id;
String? name;
int? type;
bool? isUpdate = false;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['content_type'] = contentType;
data['typeName'] = typeName;
data['template'] = template;
data['fixed_key'] = fixedKey;
if (templatePreviewCode != null) {
data['template_preview_code'] = jsonDecode(templatePreviewCode!);
}
return data;
}
// New method to replace template variables with values from templatePreviewCode
String generatePreview() {
if (template == null || templatePreviewCode == null) {
return '';
}
// Decode the templatePreviewCode string back to a map
final Map<String, String> previewCodeMap =
Map<String, String>.from(jsonDecode(templatePreviewCode!));
String previewTemplate = template!;
previewCodeMap.forEach((String key, String value) {
previewTemplate = previewTemplate.replaceAll(
key, value + (value.length > 2 ? '\n' : ''));
});
return previewTemplate;
}
}