feat: 更新广播间隔、数据库版本及广播逻辑
- 将广播间隔从10分钟缩短至3分钟 - 更新数据库版本至2,并调整相关实体和查询逻辑 - 修复广播记录保存和查询时的字段初始化问题 - 在广播消息中添加时间段类型字段 - 优化广播记录的UI显示和操作逻辑
This commit is contained in:
1 parent
45c2ea384d
commit
cc98644cb5
13 files changed
+89
-44
No files matched your search
@@ -102,7 +102,7 @@ class _$AppDatabase extends AppDatabase {
|
||||
Callback? callback,
|
||||
]) async {
|
||||
final databaseOptions = sqflite.OpenDatabaseOptions(
|
||||
version: 1,
|
||||
version: 2,
|
||||
onConfigure: (database) async {
|
||||
await database.execute('PRAGMA foreign_keys = ON');
|
||||
await callback?.onConfigure?.call(database);
|
||||
@@ -223,6 +223,28 @@ class _$BroadcastDao extends BroadcastDao {
|
||||
_broadcastEntityInsertionAdapter = InsertionAdapter(
|
||||
database,
|
||||
'broadcast',
|
||||
(BroadcastEntity item) => <String, Object?>{
|
||||
'id': item.id,
|
||||
'content': item.content,
|
||||
'broadcastCount': item.broadcastCount,
|
||||
'broadcastMaxCount': item.broadcastMaxCount,
|
||||
'isBroadcast': _boolConverter.encode(item.isBroadcast),
|
||||
'isDone': _boolConverter.encode(item.isDone),
|
||||
'isDoneTime': _dateTimeEmptyConverter.encode(item.isDoneTime),
|
||||
'serviceCode': item.serviceCode,
|
||||
'userId': item.userId,
|
||||
'username': item.username,
|
||||
'userMobile': item.userMobile,
|
||||
'productDesc': item.productDesc,
|
||||
'payPrice': item.payPrice,
|
||||
'hourType': item.hourType?.index,
|
||||
'enable': _boolConverter.encode(item.enable),
|
||||
'createTime': _dateTimeConverter.encode(item.createTime)
|
||||
}),
|
||||
_broadcastEntityUpdateAdapter = UpdateAdapter(
|
||||
database,
|
||||
'broadcast',
|
||||
['id'],
|
||||
(BroadcastEntity item) => <String, Object?>{
|
||||
'id': item.id,
|
||||
'content': item.content,
|
||||
@@ -250,22 +272,30 @@ class _$BroadcastDao extends BroadcastDao {
|
||||
|
||||
final InsertionAdapter<BroadcastEntity> _broadcastEntityInsertionAdapter;
|
||||
|
||||
final UpdateAdapter<BroadcastEntity> _broadcastEntityUpdateAdapter;
|
||||
|
||||
@override
|
||||
Future<List<BroadcastEntity>> getAll() async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT * FROM broadcast WHERE isDone = 0 AND enable = true AND broadcastCount < broadcastMaxCount AND strftime(\'%Y-%m-%d\', createTime) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')',
|
||||
'SELECT * FROM broadcast WHERE isDone = 0 AND enable = 1 AND broadcastCount < broadcastMaxCount AND strftime(\'%Y-%m-%d\', createTime) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')',
|
||||
mapper: (Map<String, Object?> row) => BroadcastEntity(
|
||||
id: row['id'] as int?,
|
||||
content: row['content'] as String,
|
||||
broadcastCount: row['broadcastCount'] as int,
|
||||
broadcastMaxCount: row['broadcastMaxCount'] as int,
|
||||
isBroadcast: _boolConverter.decode(row['isBroadcast'] as int),
|
||||
isDone: _boolConverter.decode(row['isDone'] as int),
|
||||
createTime: _dateTimeConverter.decode(row['createTime'] as String),
|
||||
serviceCode: row['serviceCode'] as String,
|
||||
userId: row['userId'] as String,
|
||||
username: row['username'] as String,
|
||||
userMobile: row['userMobile'] as String,
|
||||
productDesc: row['productDesc'] as String,
|
||||
payPrice: row['payPrice'] as int));
|
||||
payPrice: row['payPrice'] as int,
|
||||
hourType: row['hourType'] == null
|
||||
? null
|
||||
: ProductHourType.values[row['hourType'] as int],
|
||||
enable: _boolConverter.decode(row['enable'] as int)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -276,7 +306,7 @@ class _$BroadcastDao extends BroadcastDao {
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT * FROM broadcast WHERE strftime(\'%Y-%m-%d\', createTime) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\') AND (?1 = \'-1\' OR hourType = ?1) LIMIT ?2 OFFSET ?3',
|
||||
mapper: (Map<String, Object?> row) => BroadcastEntity(id: row['id'] as int?, content: row['content'] as String, broadcastMaxCount: row['broadcastMaxCount'] as int, isBroadcast: _boolConverter.decode(row['isBroadcast'] as int), createTime: _dateTimeConverter.decode(row['createTime'] as String), serviceCode: row['serviceCode'] as String, userId: row['userId'] as String, username: row['username'] as String, userMobile: row['userMobile'] as String, productDesc: row['productDesc'] as String, payPrice: row['payPrice'] as int),
|
||||
mapper: (Map<String, Object?> row) => BroadcastEntity(id: row['id'] as int?, content: row['content'] as String, broadcastCount: row['broadcastCount'] as int, broadcastMaxCount: row['broadcastMaxCount'] as int, isBroadcast: _boolConverter.decode(row['isBroadcast'] as int), isDone: _boolConverter.decode(row['isDone'] as int), createTime: _dateTimeConverter.decode(row['createTime'] as String), serviceCode: row['serviceCode'] as String, userId: row['userId'] as String, username: row['username'] as String, userMobile: row['userMobile'] as String, productDesc: row['productDesc'] as String, payPrice: row['payPrice'] as int, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], enable: _boolConverter.decode(row['enable'] as int)),
|
||||
arguments: [hourType, pageSize, offset]);
|
||||
}
|
||||
|
||||
@@ -299,6 +329,12 @@ class _$BroadcastDao extends BroadcastDao {
|
||||
await _broadcastEntityInsertionAdapter.insertList(
|
||||
entitys, OnConflictStrategy.abort);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> edit(BroadcastEntity entity) async {
|
||||
await _broadcastEntityUpdateAdapter.update(
|
||||
entity, OnConflictStrategy.abort);
|
||||
}
|
||||
}
|
||||
|
||||
class _$OrderDao extends OrderDao {
|
||||
|
||||
Reference in new issue
Block a user