feat:"初始化仓库,并更新基础代码。"

This commit is contained in:
2026-01-14 09:25:52 +08:00
commit 9a91c40a97
140 changed files with 6513 additions and 0 deletions

View 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'],
);
}
}

View File

@@ -0,0 +1,47 @@
class TransactionModel {
final String id;
final double amount;
final String type; // 'income' or 'expense'
final int categoryId;
final DateTime date;
final String? note;
final DateTime createdAt;
final DateTime updatedAt;
TransactionModel({
required this.id,
required this.amount,
required this.type,
required this.categoryId,
required this.date,
this.note,
required this.createdAt,
required this.updatedAt,
});
Map<String, dynamic> toMap() {
return {
'id': id,
'amount': amount,
'type': type,
'categoryId': categoryId,
'date': date.millisecondsSinceEpoch,
'note': note,
'createdAt': createdAt.millisecondsSinceEpoch,
'updatedAt': updatedAt.millisecondsSinceEpoch,
};
}
factory TransactionModel.fromMap(Map<String, dynamic> map) {
return TransactionModel(
id: map['id'],
amount: map['amount'],
type: map['type'],
categoryId: map['categoryId'],
date: DateTime.fromMillisecondsSinceEpoch(map['date']),
note: map['note'],
createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']),
updatedAt: DateTime.fromMillisecondsSinceEpoch(map['updatedAt']),
);
}
}