update for reorder and location points
This commit is contained in:
@ -41,14 +41,17 @@ class DatabaseHelper{
|
||||
checkin_radious REAL,
|
||||
auto_checkin INTEGER,
|
||||
selected INTEGER,
|
||||
checkedin INTEGER
|
||||
checkedin INTEGER,
|
||||
cp REAL,
|
||||
checkin_point REAL,
|
||||
buy_point REAL
|
||||
)
|
||||
''');
|
||||
}
|
||||
|
||||
Future<List<Destination>> getDestinations() async {
|
||||
Database db = await instance.database;
|
||||
var dest = await db.query('destination');
|
||||
var dest = await db.query('destination', orderBy: 'list_order');
|
||||
List<Destination> destList = dest.isNotEmpty ?
|
||||
dest.map((e) => Destination.fromMap(e)).toList() : [];
|
||||
print("--------- ${destList}");
|
||||
@ -57,7 +60,7 @@ class DatabaseHelper{
|
||||
|
||||
Future<List<Destination>> getDestinationByLatLon(double lat, double lon) async {
|
||||
Database db = await instance.database;
|
||||
var dest = await db.query('destination', where: "lat = ${lat} and lon= ${lon}");
|
||||
var dest = await db.query('destination', where: "lat = ${lat} and lon= ${lon}", orderBy: 'list_order');
|
||||
List<Destination> destList = dest.isNotEmpty
|
||||
? dest.map((e) => Destination.fromMap(e)).toList() : [];
|
||||
return destList;
|
||||
@ -78,6 +81,10 @@ class DatabaseHelper{
|
||||
|
||||
Future<int> insertDestination(Destination dest) async {
|
||||
Database db = await instance.database;
|
||||
int? next_order = Sqflite.firstIntValue(await db.rawQuery('SELECT MAX(list_order) FROM destination'));
|
||||
next_order = next_order==null ? 0 : next_order;
|
||||
next_order = next_order + 1;
|
||||
dest.list_order = next_order;
|
||||
int res = await db.insert(
|
||||
'destination',
|
||||
dest.toMap(),
|
||||
|
||||
Reference in New Issue
Block a user