feat:超市实体
This commit is contained in:
1 parent
321ae3378a
commit
c0fbf652fb
16 files changed
+640
-80
No files matched your search
@@ -1,14 +1,33 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
abstract class AppSettingTool {
|
||||
static const String _tag = "app配置工具";
|
||||
|
||||
static const String _settingKey = "setting";
|
||||
|
||||
// 自定义缓存管理器
|
||||
static final CacheManager _settingCache = CacheManager(
|
||||
Config(
|
||||
'setting_cache',
|
||||
stalePeriod: const Duration(days: 7),
|
||||
maxNrOfCacheObjects: 10,
|
||||
),
|
||||
);
|
||||
|
||||
static Future<SettingEntity> _getSetting() async {
|
||||
// 尝试从缓存获取
|
||||
final fileInfo = await _settingCache.getFileFromCache(_settingKey);
|
||||
if (fileInfo != null) {
|
||||
final content = await fileInfo.file.readAsString();
|
||||
return SettingEntity.fromJson(json.decode(content));
|
||||
}
|
||||
final app = Get.find<AppControl>();
|
||||
final settingDao = app.dataBase.getSettingDao;
|
||||
final setting = await settingDao.get();
|
||||
@@ -64,9 +83,12 @@ abstract class AppSettingTool {
|
||||
canteenExtraPriceConfig.toJson(),
|
||||
);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userJson)) {}
|
||||
if (ObjectUtil.isNotEmpty(canteenExtraPriceConfig)) {}
|
||||
await settingDao.edit(setting);
|
||||
await _settingCache.putFile(
|
||||
'setting',
|
||||
Uint8List.fromList(utf8.encode(json.encode(setting.toJson()))),
|
||||
fileExtension: 'json',
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ abstract class SyncProductTool {
|
||||
apiList?.forEach((v) => v.saleDate = dayStr);
|
||||
}
|
||||
} else if (sysType == SysType.SUPERMARKET) {
|
||||
apiList = await ProductApi.supermarketProduct(null);
|
||||
apiList = await ProductApi.supermarketSpu(null);
|
||||
}
|
||||
if (apiList == null) return;
|
||||
if (ObjectUtil.isEmptyList(apiList)) {
|
||||
|
||||
Reference in new issue
Block a user