| POST | /category |
|---|
import 'package:servicestack/servicestack.dart';
enum CategoryTypes
{
Department,
PartyGroup,
DocGroup,
DocType,
IssuingAgency,
Status,
Subjects,
Workflow,
}
class CategoryRequest implements IConvertible
{
int? id;
CategoryTypes? type;
String? name;
int? parentId;
CategoryRequest({this.id,this.type,this.name,this.parentId});
CategoryRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
type = JsonConverters.fromJson(json['type'],'CategoryTypes',context!);
name = json['name'];
parentId = json['parentId'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'type': JsonConverters.toJson(type,'CategoryTypes',context!),
'name': name,
'parentId': parentId
};
getTypeName() => "CategoryRequest";
TypeContext? context = _ctx;
}
class SearchCategoryRequest extends CategoryRequest implements IConvertible
{
SearchCategoryRequest();
SearchCategoryRequest.fromJson(Map<String, dynamic> json) : super.fromJson(json);
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
return this;
}
Map<String, dynamic> toJson() => super.toJson();
getTypeName() => "SearchCategoryRequest";
TypeContext? context = _ctx;
}
class CreateCategoryModel implements IConvertible
{
String? name;
String? description;
CategoryTypes? type;
bool? isParty;
// @ignore()
List<int>? childList;
CreateCategoryModel({this.name,this.description,this.type,this.isParty,this.childList});
CreateCategoryModel.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
name = json['name'];
description = json['description'];
type = JsonConverters.fromJson(json['type'],'CategoryTypes',context!);
isParty = json['isParty'];
childList = JsonConverters.fromJson(json['childList'],'List<int>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'name': name,
'description': description,
'type': JsonConverters.toJson(type,'CategoryTypes',context!),
'isParty': isParty,
'childList': JsonConverters.toJson(childList,'List<int>',context!)
};
getTypeName() => "CreateCategoryModel";
TypeContext? context = _ctx;
}
class Category extends CreateCategoryModel implements IConvertible
{
int? id;
int? level;
int? sortOrder;
DateTime? lastUpdate;
// @ignore()
List<Category>? children;
Category({this.id,this.level,this.sortOrder,this.lastUpdate,this.children});
Category.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
id = json['id'];
level = json['level'];
sortOrder = json['sortOrder'];
lastUpdate = JsonConverters.fromJson(json['lastUpdate'],'DateTime',context!);
children = JsonConverters.fromJson(json['children'],'List<Category>',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'id': id,
'level': level,
'sortOrder': sortOrder,
'lastUpdate': JsonConverters.toJson(lastUpdate,'DateTime',context!),
'children': JsonConverters.toJson(children,'List<Category>',context!)
});
getTypeName() => "Category";
TypeContext? context = _ctx;
}
class BaseResponse<List> implements IResponseRequest, IConvertible
{
int? code;
String? message;
List<Category>? data;
BaseResponse({this.code,this.message,this.data});
BaseResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
code = json['code'];
message = json['message'];
data = JsonConverters.fromJson(json['data'],'List<Category>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'code': code,
'message': message,
'data': JsonConverters.toJson(data,'List<Category>',context!)
};
getTypeName() => "BaseResponse<$List`1>";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'etc_api.vsmlab.vn', types: <String, TypeInfo> {
'CategoryTypes': TypeInfo(TypeOf.Enum, enumValues:CategoryTypes.values),
'CategoryRequest': TypeInfo(TypeOf.Class, create:() => CategoryRequest()),
'SearchCategoryRequest': TypeInfo(TypeOf.Class, create:() => SearchCategoryRequest()),
'CreateCategoryModel': TypeInfo(TypeOf.Class, create:() => CreateCategoryModel()),
'Category': TypeInfo(TypeOf.Class, create:() => Category()),
'List<Category>': TypeInfo(TypeOf.Class, create:() => <Category>[]),
'BaseResponse<List>': TypeInfo(TypeOf.Class, create:() => BaseResponse<List>()),
});
Dart SearchCategoryRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /category HTTP/1.1
Host: etc-api.vsmlab.vn
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
id: 0,
type: Department,
name: String,
parentId: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
code: 0,
message: String,
data:
[
{
id: 0,
level: 0,
sortOrder: 0,
lastUpdate: "0001-01-01T00:00:00.0000000+07:06",
children:
[
{
id: 0,
level: 0,
sortOrder: 0,
lastUpdate: "0001-01-01T00:00:00.0000000+07:06",
children:
[
{
id: 0,
level: 0,
sortOrder: 0,
lastUpdate: "0001-01-01T00:00:00.0000000+07:06",
name: String,
description: String,
type: Department,
isParty: False,
childList:
[
0
]
}
],
name: String,
description: String,
type: Department,
isParty: False,
childList:
[
0
]
}
],
name: String,
description: String,
type: Department,
isParty: False,
childList:
[
0
]
}
]
}