Skip to content

Commit 122183d

Browse files
committed
feat: forum with api(many ai codes)
1 parent 6802609 commit 122183d

15 files changed

Lines changed: 1347 additions & 566 deletions

lib/l10n/app_en.arb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,5 +722,14 @@
722722
"forumMdList": "List",
723723
"forumMdQuote": "Quote",
724724
"forumMdCode": "Code",
725-
"forumMdLink": "Link"
725+
"forumMdLink": "Link",
726+
"forumCreateTitle": "Create Forum",
727+
"forumCreateTitleHint": "Forum name",
728+
"forumCreateDescriptionHint": "Description (optional)",
729+
"forumCreateSuccess": "Forum submitted for review",
730+
"forumCreateFailed": "Failed to create forum",
731+
"forumPinPost": "Pin Post",
732+
"forumUnpinPost": "Unpin Post",
733+
"forumDeleteSuccess": "Forum deleted successfully",
734+
"forumDeleteFailed": "Failed to delete forum"
726735
}

lib/l10n/app_localizations.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,6 +3483,60 @@ abstract class AppLocalizations {
34833483
/// In en, this message translates to:
34843484
/// **'Link'**
34853485
String get forumMdLink;
3486+
3487+
/// No description provided for @forumCreateTitle.
3488+
///
3489+
/// In en, this message translates to:
3490+
/// **'Create Forum'**
3491+
String get forumCreateTitle;
3492+
3493+
/// No description provided for @forumCreateTitleHint.
3494+
///
3495+
/// In en, this message translates to:
3496+
/// **'Forum name'**
3497+
String get forumCreateTitleHint;
3498+
3499+
/// No description provided for @forumCreateDescriptionHint.
3500+
///
3501+
/// In en, this message translates to:
3502+
/// **'Description (optional)'**
3503+
String get forumCreateDescriptionHint;
3504+
3505+
/// No description provided for @forumCreateSuccess.
3506+
///
3507+
/// In en, this message translates to:
3508+
/// **'Forum submitted for review'**
3509+
String get forumCreateSuccess;
3510+
3511+
/// No description provided for @forumCreateFailed.
3512+
///
3513+
/// In en, this message translates to:
3514+
/// **'Failed to create forum'**
3515+
String get forumCreateFailed;
3516+
3517+
/// No description provided for @forumPinPost.
3518+
///
3519+
/// In en, this message translates to:
3520+
/// **'Pin Post'**
3521+
String get forumPinPost;
3522+
3523+
/// No description provided for @forumUnpinPost.
3524+
///
3525+
/// In en, this message translates to:
3526+
/// **'Unpin Post'**
3527+
String get forumUnpinPost;
3528+
3529+
/// No description provided for @forumDeleteSuccess.
3530+
///
3531+
/// In en, this message translates to:
3532+
/// **'Forum deleted successfully'**
3533+
String get forumDeleteSuccess;
3534+
3535+
/// No description provided for @forumDeleteFailed.
3536+
///
3537+
/// In en, this message translates to:
3538+
/// **'Failed to delete forum'**
3539+
String get forumDeleteFailed;
34863540
}
34873541

34883542
class _AppLocalizationsDelegate

lib/l10n/app_localizations_en.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,4 +1824,31 @@ class AppLocalizationsEn extends AppLocalizations {
18241824

18251825
@override
18261826
String get forumMdLink => 'Link';
1827+
1828+
@override
1829+
String get forumCreateTitle => 'Create Forum';
1830+
1831+
@override
1832+
String get forumCreateTitleHint => 'Forum name';
1833+
1834+
@override
1835+
String get forumCreateDescriptionHint => 'Description (optional)';
1836+
1837+
@override
1838+
String get forumCreateSuccess => 'Forum submitted for review';
1839+
1840+
@override
1841+
String get forumCreateFailed => 'Failed to create forum';
1842+
1843+
@override
1844+
String get forumPinPost => 'Pin Post';
1845+
1846+
@override
1847+
String get forumUnpinPost => 'Unpin Post';
1848+
1849+
@override
1850+
String get forumDeleteSuccess => 'Forum deleted successfully';
1851+
1852+
@override
1853+
String get forumDeleteFailed => 'Failed to delete forum';
18271854
}

lib/l10n/app_localizations_och.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,4 +1746,31 @@ class AppLocalizationsOch extends AppLocalizations {
17461746

17471747
@override
17481748
String get forumMdLink => '鏈接';
1749+
1750+
@override
1751+
String get forumCreateTitle => '建論壇';
1752+
1753+
@override
1754+
String get forumCreateTitleHint => '論壇之名';
1755+
1756+
@override
1757+
String get forumCreateDescriptionHint => '述(非必填)';
1758+
1759+
@override
1760+
String get forumCreateSuccess => '論壇已呈,待審';
1761+
1762+
@override
1763+
String get forumCreateFailed => '建論壇未成';
1764+
1765+
@override
1766+
String get forumPinPost => '置頂';
1767+
1768+
@override
1769+
String get forumUnpinPost => '去置頂';
1770+
1771+
@override
1772+
String get forumDeleteSuccess => '論壇已毀';
1773+
1774+
@override
1775+
String get forumDeleteFailed => '毀論壇未成';
17491776
}

lib/l10n/app_localizations_zh.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,4 +1747,31 @@ class AppLocalizationsZh extends AppLocalizations {
17471747

17481748
@override
17491749
String get forumMdLink => '链接';
1750+
1751+
@override
1752+
String get forumCreateTitle => '创建论坛';
1753+
1754+
@override
1755+
String get forumCreateTitleHint => '论坛名称';
1756+
1757+
@override
1758+
String get forumCreateDescriptionHint => '简介(可选)';
1759+
1760+
@override
1761+
String get forumCreateSuccess => '论坛已提交审核';
1762+
1763+
@override
1764+
String get forumCreateFailed => '创建论坛失败';
1765+
1766+
@override
1767+
String get forumPinPost => '置顶帖子';
1768+
1769+
@override
1770+
String get forumUnpinPost => '取消置顶';
1771+
1772+
@override
1773+
String get forumDeleteSuccess => '论坛已删除';
1774+
1775+
@override
1776+
String get forumDeleteFailed => '删除论坛失败';
17501777
}

lib/l10n/app_och.arb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,5 +692,14 @@
692692
"forumMdList": "列",
693693
"forumMdQuote": "引",
694694
"forumMdCode": "代碼",
695-
"forumMdLink": "鏈接"
695+
"forumMdLink": "鏈接",
696+
"forumCreateTitle": "建論壇",
697+
"forumCreateTitleHint": "論壇之名",
698+
"forumCreateDescriptionHint": "述(非必填)",
699+
"forumCreateSuccess": "論壇已呈,待審",
700+
"forumCreateFailed": "建論壇未成",
701+
"forumPinPost": "置頂",
702+
"forumUnpinPost": "去置頂",
703+
"forumDeleteSuccess": "論壇已毀",
704+
"forumDeleteFailed": "毀論壇未成"
696705
}

lib/l10n/app_zh.arb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,5 +693,14 @@
693693
"forumMdList": "列表",
694694
"forumMdQuote": "引用",
695695
"forumMdCode": "代码",
696-
"forumMdLink": "链接"
696+
"forumMdLink": "链接",
697+
"forumCreateTitle": "创建论坛",
698+
"forumCreateTitleHint": "论坛名称",
699+
"forumCreateDescriptionHint": "简介(可选)",
700+
"forumCreateSuccess": "论坛已提交审核",
701+
"forumCreateFailed": "创建论坛失败",
702+
"forumPinPost": "置顶帖子",
703+
"forumUnpinPost": "取消置顶",
704+
"forumDeleteSuccess": "论坛已删除",
705+
"forumDeleteFailed": "删除论坛失败"
697706
}

lib/models/forum_model.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Forum {
3535
}
3636

3737
factory Forum.fromServerRow(List<dynamic> row) {
38-
final ms = ((row[3] as num).toDouble() * 1000).toInt();
38+
final ms = ((double.tryParse(row[3].toString()) ?? 0) * 1000).toInt();
3939
return Forum(
4040
id: row[0].toString(),
4141
name: row[1] as String,
@@ -67,12 +67,16 @@ class PendingForumApproval {
6767
final String creatorUid;
6868
final String forumName;
6969
final String introduction;
70+
final String type; // "create" "edit"
71+
final int? originalFid;
7072

7173
const PendingForumApproval({
7274
required this.queueId,
7375
required this.creatorUid,
7476
required this.forumName,
7577
required this.introduction,
78+
this.type = 'create',
79+
this.originalFid,
7680
});
7781

7882
factory PendingForumApproval.fromQueueEntry(
@@ -84,6 +88,8 @@ class PendingForumApproval {
8488
creatorUid: json['creater'].toString(),
8589
forumName: json['forumname'] as String? ?? '',
8690
introduction: json['introduction'] as String? ?? '',
91+
type: json['type'] as String? ?? 'create',
92+
originalFid: json['fid'] is int ? json['fid'] as int : null,
8793
);
8894
}
8995
}
@@ -118,6 +124,20 @@ class ForumMember {
118124
);
119125
}
120126

127+
/// [row] = [fid, uid, role, join_time]
128+
factory ForumMember.fromServerRow(List<dynamic> row) {
129+
final ms = ((double.tryParse(row[3].toString()) ?? 0) * 1000).toInt();
130+
final joinTime = DateTime.fromMillisecondsSinceEpoch(ms);
131+
return ForumMember(
132+
forumId: row[0].toString(),
133+
accountUid: row[1].toString(),
134+
role: (row[2] as num).toInt(),
135+
joinedAt: joinTime,
136+
createdAt: joinTime,
137+
updatedAt: joinTime,
138+
);
139+
}
140+
121141
Map<String, dynamic> toJson() {
122142
return {
123143
'forum_id': forumId,
@@ -165,7 +185,7 @@ class ForumPost {
165185
}
166186

167187
factory ForumPost.fromServerRow(String forumId, List<dynamic> row) {
168-
final ms = ((row[4] as num).toDouble() * 1000).toInt();
188+
final ms = ((double.tryParse(row[4].toString()) ?? 0) * 1000).toInt();
169189
return ForumPost(
170190
id: row[0].toString(),
171191
forumId: forumId,

0 commit comments

Comments
 (0)