mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
create space model
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class TagBodyModel {
|
||||
late String uuid;
|
||||
late String tag;
|
||||
late final String? productUuid;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'tag': tag,
|
||||
'productUuid': productUuid,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toJson().toString();
|
||||
}
|
||||
}
|
||||
|
||||
class CreateSubspaceTemplateModel {
|
||||
late String subspaceName;
|
||||
late List<TagBodyModel>? tags;
|
||||
}
|
||||
|
||||
class CreateSpaceTemplateBodyModel {
|
||||
final String modelName;
|
||||
final List<dynamic>? tags;
|
||||
final List<dynamic>? subspaceModels;
|
||||
|
||||
CreateSpaceTemplateBodyModel({
|
||||
required this.modelName,
|
||||
this.tags,
|
||||
this.subspaceModels,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'modelName': modelName,
|
||||
'tags': tags,
|
||||
'subspaceModels': subspaceModels,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,16 +1,20 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class SpaceTemplateModel {
|
||||
class SpaceTemplateModel extends Equatable {
|
||||
final String? uuid;
|
||||
String modelName;
|
||||
List<SubspaceTemplateModel>? subspaceModels;
|
||||
final List<TagModel>? tags;
|
||||
String internalId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [modelName, subspaceModels];
|
||||
|
||||
SpaceTemplateModel({
|
||||
this.uuid,
|
||||
String? internalId,
|
||||
@ -26,9 +30,10 @@ class SpaceTemplateModel {
|
||||
uuid: json['uuid'] ?? '',
|
||||
internalId: internalId,
|
||||
modelName: json['modelName'] ?? '',
|
||||
subspaceModels: (json['subspaceModels'] as List)
|
||||
.map((item) => SubspaceTemplateModel.fromJson(item))
|
||||
.toList(),
|
||||
subspaceModels: (json['subspaceModels'] as List<dynamic>?)
|
||||
?.map((e) => SubspaceTemplateModel.fromJson(e))
|
||||
.toList() ??
|
||||
[],
|
||||
tags: (json['tags'] as List)
|
||||
.map((item) => TagModel.fromJson(item))
|
||||
.toList(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class TagModel {
|
||||
@ -50,3 +50,12 @@ class TagModel {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extension TagModelExtensions on TagModel {
|
||||
TagBodyModel toTagBodyModel() {
|
||||
return TagBodyModel()
|
||||
..uuid = uuid ?? ''
|
||||
..tag = tag ?? ''
|
||||
..productUuid = product?.uuid;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user