Skip to content

Commit ab6d92c

Browse files
committed
增加数据库逻辑和数据库注释
1 parent d985821 commit ab6d92c

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎lib/common/dao/EventDao.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class EventDao {
7777
}
7878
if(needDb) {
7979
List<Event> dbList = await provider.getEvents();
80+
if(dbList == null && dbList.length == 0) {
81+
return await next();
82+
}
8083
DataResult dataResult = new DataResult(dbList, true, next: next());
8184
return dataResult;
8285
}

‎lib/common/dao/UserDao.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ class UserDao {
105105

106106
if (needDb) {
107107
User user = await provider.getUserInfo(userName);
108+
if(user == null) {
109+
return await next();
110+
}
108111
DataResult dataResult = new DataResult(user, true, next: next());
109112
return dataResult;
110113
}

‎lib/page/PersonPage.dart‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class _PersonState extends GSYListState<PersonPage> {
6464
}
6565
isLoading = true;
6666
page = 1;
67+
///从Dao中获取数据
68+
///如果第一次返回的是网络数据,next为空
69+
///如果返回的是数据库数据,next不为空
70+
///这样数据库返回数据较快,马上显示
71+
///next异步再请求后,再更新
6772
var userResult = await UserDao.getUserInfo(userName, needDb: true);
6873
if (userResult != null && userResult.result) {
6974
_resolveUserInfo(userResult);

0 commit comments

Comments
 (0)