feat:"初始化仓库,并更新基础代码。"
This commit is contained in:
39
lib/models/category_model.dart
Normal file
39
lib/models/category_model.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
class Category {
|
||||
final int? id;
|
||||
final String name;
|
||||
final String type; // 'income' or 'expense'
|
||||
final String icon;
|
||||
final int color;
|
||||
final int? parentId; // 支持多级分类
|
||||
|
||||
Category({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
this.parentId,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'type': type,
|
||||
'icon': icon,
|
||||
'color': color,
|
||||
'parentId': parentId,
|
||||
};
|
||||
}
|
||||
|
||||
factory Category.fromMap(Map<String, dynamic> map) {
|
||||
return Category(
|
||||
id: map['id'],
|
||||
name: map['name'],
|
||||
type: map['type'],
|
||||
icon: map['icon'],
|
||||
color: map['color'],
|
||||
parentId: map['parentId'],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user