feat:超市数据库
This commit is contained in:
1 parent
9a98ac8e1c
commit
fa4bb78f8b
25 files changed
+307
-185
No files matched your search
+32
-36
@@ -7,10 +7,10 @@ import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
@dao
|
||||
abstract class ProductDao {
|
||||
@insert
|
||||
Future<void> save(ProductEntity entity);
|
||||
Future<void> save(CanteenSpuEntity entity);
|
||||
|
||||
@insert
|
||||
Future<void> batchSave(List<ProductEntity> entitys);
|
||||
Future<void> batchSave(List<CanteenSpuEntity> entitys);
|
||||
|
||||
Future<int> delByIds(List<String> codes) async {
|
||||
if (ObjectUtil.isEmptyList(codes)) return -1;
|
||||
@@ -18,26 +18,22 @@ abstract class ProductDao {
|
||||
final database = app.dataBase.database;
|
||||
final placeholders = List.generate(codes.length, (index) => '?').join(', ');
|
||||
final sql = '''
|
||||
UPDATE product SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders)
|
||||
UPDATE canteen_spu SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders)
|
||||
AND (sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
''';
|
||||
return await database.rawUpdate(sql, [...codes]);
|
||||
}
|
||||
|
||||
@Query('''
|
||||
DELETE FROM product
|
||||
WHERE
|
||||
(:sysType = '-1' OR sysType = :sysType)
|
||||
DELETE FROM canteen_spu
|
||||
''')
|
||||
Future<void> delAllByType(
|
||||
String sysType,
|
||||
);
|
||||
Future<void> delAllByType();
|
||||
|
||||
@delete
|
||||
Future<void> batchDel(List<ProductEntity> entitys);
|
||||
Future<void> batchDel(List<CanteenSpuEntity> entitys);
|
||||
|
||||
@Query("""
|
||||
UPDATE product SET isDefault = :isDefault
|
||||
UPDATE canteen_spu SET isDefault = :isDefault
|
||||
WHERE
|
||||
delFlag = 0
|
||||
AND serviceUniqueCode = :uniqueCode AND hourType = :hourType
|
||||
@@ -46,10 +42,10 @@ abstract class ProductDao {
|
||||
Future<void> edit(bool isDefault, String uniqueCode, String hourType);
|
||||
|
||||
@update
|
||||
Future<void> batchEdit(List<ProductEntity> entitys);
|
||||
Future<void> batchEdit(List<CanteenSpuEntity> entitys);
|
||||
|
||||
@Query("""
|
||||
SELECT DISTINCT COUNT(0) FROM product
|
||||
SELECT DISTINCT COUNT(0) FROM canteen_spu
|
||||
WHERE
|
||||
delFlag = 0
|
||||
AND (:sysType = '-1' OR sysType = :sysType)
|
||||
@@ -62,42 +58,42 @@ abstract class ProductDao {
|
||||
);
|
||||
|
||||
@Query('''
|
||||
SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = :code
|
||||
SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = :code
|
||||
''')
|
||||
Future<ProductEntity?> getByCode(String code);
|
||||
Future<CanteenSpuEntity?> getByCode(String code);
|
||||
|
||||
@Query('''
|
||||
SELECT product.*
|
||||
FROM product
|
||||
LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode
|
||||
SELECT canteen_spu.*
|
||||
FROM canteen_spu
|
||||
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
|
||||
WHERE
|
||||
product.delFlag = 0 AND
|
||||
(:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
|
||||
canteen_spu.delFlag = 0 AND
|
||||
(:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
|
||||
(:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND
|
||||
(:sysType = '-1' OR product.sysType = :sysType)
|
||||
ORDER BY classify.sort, product.price
|
||||
(:sysType = '-1' OR canteen_spu.sysType = :sysType)
|
||||
ORDER BY classify.sort, canteen_spu.price
|
||||
''')
|
||||
Future<List<ProductEntity>> getAll(
|
||||
Future<List<CanteenSpuEntity>> getAll(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
);
|
||||
|
||||
// GROUP BY product.serviceUniqueCode
|
||||
// GROUP BY canteen_spu.serviceUniqueCode
|
||||
@Query('''
|
||||
SELECT product.*
|
||||
FROM product
|
||||
LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode
|
||||
SELECT canteen_spu.*
|
||||
FROM canteen_spu
|
||||
LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode
|
||||
WHERE
|
||||
product.delFlag = 0 AND
|
||||
(:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
|
||||
(:hourType = '-1' OR INSTR(',' || product.hourType || ',', ',' || :hourType || ',') > 0) AND
|
||||
(:sysType = '-1' OR product.sysType = :sysType) AND
|
||||
(:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', product.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
ORDER BY classify.sort, classify.id, product.price
|
||||
canteen_spu.delFlag = 0 AND
|
||||
(:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND
|
||||
(:hourType = '-1' OR INSTR(',' || canteen_spu.hourType || ',', ',' || :hourType || ',') > 0) AND
|
||||
(:sysType = '-1' OR canteen_spu.sysType = :sysType) AND
|
||||
(:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', canteen_spu.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
ORDER BY classify.sort, classify.id, canteen_spu.price
|
||||
LIMIT :pageSize OFFSET :offset
|
||||
''')
|
||||
Future<List<ProductEntity>> getAllPage(
|
||||
Future<List<CanteenSpuEntity>> getAllPage(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
@@ -106,7 +102,7 @@ abstract class ProductDao {
|
||||
);
|
||||
|
||||
@Query('''
|
||||
SELECT * FROM product
|
||||
SELECT * FROM canteen_spu
|
||||
WHERE
|
||||
delFlag = 0
|
||||
AND isDefault = 1
|
||||
@@ -114,5 +110,5 @@ abstract class ProductDao {
|
||||
AND (:hourType = '-1' OR hourType = :hourType)
|
||||
AND (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime'))
|
||||
''')
|
||||
Future<List<ProductEntity>> getDefault(String sysType, String hourType);
|
||||
Future<List<CanteenSpuEntity>> getDefault(String sysType, String hourType);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:floor/floor.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
@dao
|
||||
abstract class SupermarketSkuDao {}
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:floor/floor.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
@dao
|
||||
abstract class SupermarketSpuDao {}
|
||||
@@ -9,7 +9,9 @@ part 'database.g.dart';
|
||||
|
||||
const entities = <Type>[
|
||||
OrderEntity,
|
||||
ProductEntity,
|
||||
CanteenSpuEntity,
|
||||
SupermarketSkuEntity,
|
||||
SupermarketSpuEntity,
|
||||
ShopCardEntity,
|
||||
ClassifyEntity,
|
||||
PrintHistoryEntity,
|
||||
|
||||
@@ -112,7 +112,11 @@ class _$AppDatabase extends AppDatabase {
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `order_record` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uniqueCode` TEXT NOT NULL, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `userCode` TEXT NOT NULL, `username` TEXT, `hourType` TEXT, `price` INTEGER NOT NULL, `extraPrice` INTEGER NOT NULL, `payPrice` INTEGER NOT NULL, `walletId` TEXT, `orderSourceTypeId` TEXT, `type` TEXT NOT NULL, `status` TEXT NOT NULL, `payType` TEXT NOT NULL, `productDesc` TEXT, `count` INTEGER NOT NULL, `weight` REAL NOT NULL, `payTime` TEXT, `createTime` TEXT NOT NULL)');
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `product` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)');
|
||||
'CREATE TABLE IF NOT EXISTS `canteen_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)');
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `supermarket_sku` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)');
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)');
|
||||
await database.execute(
|
||||
'CREATE TABLE IF NOT EXISTS `shop_card` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `orderId` INTEGER NOT NULL, `productServiceUniqueCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productPic` TEXT NOT NULL, `productPrice` INTEGER NOT NULL, `productNumber` INTEGER NOT NULL, `productWidget` REAL NOT NULL, `totalPrice` INTEGER NOT NULL)');
|
||||
await database.execute(
|
||||
@@ -443,13 +447,12 @@ class _$ProductDao extends ProductDao {
|
||||
this.database,
|
||||
this.changeListener,
|
||||
) : _queryAdapter = QueryAdapter(database),
|
||||
_productEntityInsertionAdapter = InsertionAdapter(
|
||||
_canteenSpuEntityInsertionAdapter = InsertionAdapter(
|
||||
database,
|
||||
'product',
|
||||
(ProductEntity item) => <String, Object?>{
|
||||
'canteen_spu',
|
||||
(CanteenSpuEntity item) => <String, Object?>{
|
||||
'id': item.id,
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
@@ -463,14 +466,13 @@ class _$ProductDao extends ProductDao {
|
||||
'updateTime': _dateTimeConverter.encode(item.updateTime),
|
||||
'delFlag': _boolConverter.encode(item.delFlag)
|
||||
}),
|
||||
_productEntityUpdateAdapter = UpdateAdapter(
|
||||
_canteenSpuEntityUpdateAdapter = UpdateAdapter(
|
||||
database,
|
||||
'product',
|
||||
'canteen_spu',
|
||||
['id'],
|
||||
(ProductEntity item) => <String, Object?>{
|
||||
(CanteenSpuEntity item) => <String, Object?>{
|
||||
'id': item.id,
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
@@ -484,14 +486,13 @@ class _$ProductDao extends ProductDao {
|
||||
'updateTime': _dateTimeConverter.encode(item.updateTime),
|
||||
'delFlag': _boolConverter.encode(item.delFlag)
|
||||
}),
|
||||
_productEntityDeletionAdapter = DeletionAdapter(
|
||||
_canteenSpuEntityDeletionAdapter = DeletionAdapter(
|
||||
database,
|
||||
'product',
|
||||
'canteen_spu',
|
||||
['id'],
|
||||
(ProductEntity item) => <String, Object?>{
|
||||
(CanteenSpuEntity item) => <String, Object?>{
|
||||
'id': item.id,
|
||||
'serviceUniqueCode': item.serviceUniqueCode,
|
||||
'sysType': _sysTypeConverter.encode(item.sysType),
|
||||
'classifyServiceUniqueCode': item.classifyServiceUniqueCode,
|
||||
'hourType': item.hourType?.index,
|
||||
'saleDate': _dateTimeEmptyConverter.encode(item.saleDate),
|
||||
@@ -512,17 +513,15 @@ class _$ProductDao extends ProductDao {
|
||||
|
||||
final QueryAdapter _queryAdapter;
|
||||
|
||||
final InsertionAdapter<ProductEntity> _productEntityInsertionAdapter;
|
||||
final InsertionAdapter<CanteenSpuEntity> _canteenSpuEntityInsertionAdapter;
|
||||
|
||||
final UpdateAdapter<ProductEntity> _productEntityUpdateAdapter;
|
||||
final UpdateAdapter<CanteenSpuEntity> _canteenSpuEntityUpdateAdapter;
|
||||
|
||||
final DeletionAdapter<ProductEntity> _productEntityDeletionAdapter;
|
||||
final DeletionAdapter<CanteenSpuEntity> _canteenSpuEntityDeletionAdapter;
|
||||
|
||||
@override
|
||||
Future<void> delAllByType(String sysType) async {
|
||||
await _queryAdapter.queryNoReturn(
|
||||
'DELETE FROM product WHERE (?1 = \'-1\' OR sysType = ?1)',
|
||||
arguments: [sysType]);
|
||||
Future<void> delAllByType() async {
|
||||
await _queryAdapter.queryNoReturn('DELETE FROM canteen_spu');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -532,7 +531,7 @@ class _$ProductDao extends ProductDao {
|
||||
String hourType,
|
||||
) async {
|
||||
await _queryAdapter.queryNoReturn(
|
||||
'UPDATE product SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
'UPDATE canteen_spu SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]);
|
||||
}
|
||||
|
||||
@@ -542,51 +541,33 @@ class _$ProductDao extends ProductDao {
|
||||
String hourType,
|
||||
) async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT DISTINCT COUNT(0) FROM product WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
'SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
mapper: (Map<String, Object?> row) => row.values.first as int,
|
||||
arguments: [sysType, hourType]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProductEntity?> getByCode(String code) async {
|
||||
Future<CanteenSpuEntity?> getByCode(String code) async {
|
||||
return _queryAdapter.query(
|
||||
'SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = ?1',
|
||||
mapper: (Map<String, Object?> row) => ProductEntity(
|
||||
id: row['id'] as int?,
|
||||
serviceUniqueCode: row['serviceUniqueCode'] as String,
|
||||
sysType: _sysTypeConverter.decode(row['sysType'] as String),
|
||||
classifyServiceUniqueCode:
|
||||
row['classifyServiceUniqueCode'] as String,
|
||||
hourType: row['hourType'] == null
|
||||
? null
|
||||
: ProductHourType.values[row['hourType'] as int],
|
||||
saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String),
|
||||
name: row['name'] as String,
|
||||
price: row['price'] as int,
|
||||
image: row['image'] as String?,
|
||||
isDefault: _boolConverter.decode(row['isDefault'] as int),
|
||||
status: row['status'] as int,
|
||||
sort: row['sort'] as int,
|
||||
createTime: _dateTimeConverter.decode(row['createTime'] as String),
|
||||
updateTime: _dateTimeConverter.decode(row['updateTime'] as String),
|
||||
delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
'SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1',
|
||||
mapper: (Map<String, Object?> row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
arguments: [code]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductEntity>> getAll(
|
||||
Future<List<CanteenSpuEntity>> getAll(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) ORDER BY classify.sort, product.price',
|
||||
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR canteen_spu.sysType = ?3) ORDER BY classify.sort, canteen_spu.price',
|
||||
mapper: (Map<String, Object?> row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
arguments: [classifyServiceUniqueCode, hourType, sysType]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductEntity>> getAllPage(
|
||||
Future<List<CanteenSpuEntity>> getAllPage(
|
||||
String classifyServiceUniqueCode,
|
||||
String hourType,
|
||||
String sysType,
|
||||
@@ -594,8 +575,8 @@ class _$ProductDao extends ProductDao {
|
||||
int offset,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || product.hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', product.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, product.price LIMIT ?4 OFFSET ?5',
|
||||
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || canteen_spu.hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR canteen_spu.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', canteen_spu.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT ?4 OFFSET ?5',
|
||||
mapper: (Map<String, Object?> row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
arguments: [
|
||||
classifyServiceUniqueCode,
|
||||
hourType,
|
||||
@@ -606,37 +587,37 @@ class _$ProductDao extends ProductDao {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<ProductEntity>> getDefault(
|
||||
Future<List<CanteenSpuEntity>> getDefault(
|
||||
String sysType,
|
||||
String hourType,
|
||||
) async {
|
||||
return _queryAdapter.queryList(
|
||||
'SELECT * FROM product WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
mapper: (Map<String, Object?> row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
'SELECT * FROM canteen_spu WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))',
|
||||
mapper: (Map<String, Object?> row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)),
|
||||
arguments: [sysType, hourType]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(ProductEntity entity) async {
|
||||
await _productEntityInsertionAdapter.insert(
|
||||
Future<void> save(CanteenSpuEntity entity) async {
|
||||
await _canteenSpuEntityInsertionAdapter.insert(
|
||||
entity, OnConflictStrategy.abort);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> batchSave(List<ProductEntity> entitys) async {
|
||||
await _productEntityInsertionAdapter.insertList(
|
||||
Future<void> batchSave(List<CanteenSpuEntity> entitys) async {
|
||||
await _canteenSpuEntityInsertionAdapter.insertList(
|
||||
entitys, OnConflictStrategy.abort);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> batchEdit(List<ProductEntity> entitys) async {
|
||||
await _productEntityUpdateAdapter.updateList(
|
||||
Future<void> batchEdit(List<CanteenSpuEntity> entitys) async {
|
||||
await _canteenSpuEntityUpdateAdapter.updateList(
|
||||
entitys, OnConflictStrategy.abort);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> batchDel(List<ProductEntity> entitys) async {
|
||||
await _productEntityDeletionAdapter.deleteList(entitys);
|
||||
Future<void> batchDel(List<CanteenSpuEntity> entitys) async {
|
||||
await _canteenSpuEntityDeletionAdapter.deleteList(entitys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-12
@@ -4,11 +4,11 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/models/index.dart';
|
||||
|
||||
part 'product_entity.g.dart';
|
||||
part 'canteen_spu_entity.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@Entity(tableName: "product")
|
||||
class ProductEntity extends Equatable {
|
||||
@Entity(tableName: "canteen_spu")
|
||||
class CanteenSpuEntity extends Equatable {
|
||||
/// 自增ID
|
||||
@PrimaryKey(autoGenerate: true)
|
||||
int? id;
|
||||
@@ -16,9 +16,6 @@ class ProductEntity extends Equatable {
|
||||
/// 服务端唯一标识
|
||||
String serviceUniqueCode;
|
||||
|
||||
/// 平台类型
|
||||
SysType sysType;
|
||||
|
||||
/// 分类 serviceID
|
||||
String classifyServiceUniqueCode;
|
||||
|
||||
@@ -55,10 +52,9 @@ class ProductEntity extends Equatable {
|
||||
/// 是否删除
|
||||
bool delFlag;
|
||||
|
||||
ProductEntity({
|
||||
CanteenSpuEntity({
|
||||
this.id,
|
||||
required this.serviceUniqueCode,
|
||||
required this.sysType,
|
||||
required this.classifyServiceUniqueCode,
|
||||
this.hourType,
|
||||
this.saleDate,
|
||||
@@ -73,15 +69,14 @@ class ProductEntity extends Equatable {
|
||||
required this.delFlag,
|
||||
});
|
||||
|
||||
factory ProductEntity.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProductEntityFromJson(json);
|
||||
factory CanteenSpuEntity.fromJson(Map<String, dynamic> json) =>
|
||||
_$CanteenSpuEntityFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ProductEntityToJson(this);
|
||||
Map<String, dynamic> toJson() => _$CanteenSpuEntityToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
serviceUniqueCode,
|
||||
sysType,
|
||||
classifyServiceUniqueCode,
|
||||
hourType,
|
||||
name,
|
||||
+4
-11
@@ -1,16 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'product_entity.dart';
|
||||
part of 'canteen_spu_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) =>
|
||||
ProductEntity(
|
||||
CanteenSpuEntity _$CanteenSpuEntityFromJson(Map<String, dynamic> json) =>
|
||||
CanteenSpuEntity(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
serviceUniqueCode: json['serviceUniqueCode'] as String,
|
||||
sysType: $enumDecode(_$SysTypeEnumMap, json['sysType']),
|
||||
classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String,
|
||||
hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']),
|
||||
saleDate: json['saleDate'] == null
|
||||
@@ -27,11 +26,10 @@ ProductEntity _$ProductEntityFromJson(Map<String, dynamic> json) =>
|
||||
delFlag: json['delFlag'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ProductEntityToJson(ProductEntity instance) =>
|
||||
Map<String, dynamic> _$CanteenSpuEntityToJson(CanteenSpuEntity instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'serviceUniqueCode': instance.serviceUniqueCode,
|
||||
'sysType': _$SysTypeEnumMap[instance.sysType]!,
|
||||
'classifyServiceUniqueCode': instance.classifyServiceUniqueCode,
|
||||
'hourType': _$ProductHourTypeEnumMap[instance.hourType],
|
||||
'saleDate': instance.saleDate?.toIso8601String(),
|
||||
@@ -46,11 +44,6 @@ Map<String, dynamic> _$ProductEntityToJson(ProductEntity instance) =>
|
||||
'delFlag': instance.delFlag,
|
||||
};
|
||||
|
||||
const _$SysTypeEnumMap = {
|
||||
SysType.SUPERMARKET: 'SUPERMARKET',
|
||||
SysType.CANTEEN: 'CANTEEN',
|
||||
};
|
||||
|
||||
const _$ProductHourTypeEnumMap = {
|
||||
ProductHourType.TOTAL: 'TOTAL',
|
||||
ProductHourType.MORNING: 'MORNING',
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:floor/floor.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'supermarket_sku_entity.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@Entity(tableName: "supermarket_sku")
|
||||
class SupermarketSkuEntity {
|
||||
/// 自增ID
|
||||
@PrimaryKey(autoGenerate: true)
|
||||
int? id;
|
||||
|
||||
SupermarketSkuEntity({
|
||||
this.id,
|
||||
});
|
||||
|
||||
factory SupermarketSkuEntity.fromJson(Map<String, dynamic> json) =>
|
||||
_$SupermarketSkuEntityFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SupermarketSkuEntityToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'supermarket_sku_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SupermarketSkuEntity _$SupermarketSkuEntityFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SupermarketSkuEntity(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SupermarketSkuEntityToJson(
|
||||
SupermarketSkuEntity instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:floor/floor.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'supermarket_spu_entity.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@Entity(tableName: "supermarket_spu")
|
||||
class SupermarketSpuEntity {
|
||||
/// 自增ID
|
||||
@PrimaryKey(autoGenerate: true)
|
||||
int? id;
|
||||
|
||||
SupermarketSpuEntity({
|
||||
this.id,
|
||||
});
|
||||
|
||||
factory SupermarketSpuEntity.fromJson(Map<String, dynamic> json) =>
|
||||
_$SupermarketSpuEntityFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SupermarketSpuEntityToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'supermarket_spu_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
SupermarketSpuEntity _$SupermarketSpuEntityFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SupermarketSpuEntity(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SupermarketSpuEntityToJson(
|
||||
SupermarketSpuEntity instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
};
|
||||
@@ -8,16 +8,20 @@ export './database/dao/classify_dao.dart';
|
||||
export './database/dao/face_dao.dart';
|
||||
export './database/dao/order_dao.dart';
|
||||
export './database/dao/print_history_dao.dart';
|
||||
export './database/dao/product_dao.dart';
|
||||
export './database/dao/canteen_spu_dao.dart';
|
||||
export './database/dao/setting_dao.dart';
|
||||
export './database/dao/shop_card_dao.dart';
|
||||
export './database/dao/supermarket_sku_dao.dart';
|
||||
export './database/dao/supermarket_spu_dao.dart';
|
||||
export './database/dao/user_dao.dart';
|
||||
|
||||
export './database/entity/classify_entity.dart';
|
||||
export './database/entity/face_entity.dart';
|
||||
export './database/entity/order_entity.dart';
|
||||
export './database/entity/print_history_entity.dart';
|
||||
export './database/entity/product_entity.dart';
|
||||
export './database/entity/canteen_spu_entity.dart';
|
||||
export './database/entity/setting_entity.dart';
|
||||
export './database/entity/shop_card_entity.dart';
|
||||
export './database/entity/supermarket_sku_entity.dart';
|
||||
export './database/entity/supermarket_spu_entity.dart';
|
||||
export './database/entity/user_entity.dart';
|
||||
Reference in new issue
Block a user