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 {}
|
||||
Reference in new issue
Block a user