This commit is contained in:
Mohamed Nouffer
2022-05-12 02:17:08 +05:30
parent 9d253fc5e2
commit 80a976baa0
37 changed files with 1159 additions and 592 deletions

View File

@ -0,0 +1,43 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
class ActionService{
static Future<Map<String, dynamic>> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async {
Map<String, dynamic> cats = {};
String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
}
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
static Future<List<dynamic>?> userAction(int user_id, int location_id) async {
List<dynamic> cats = [];
String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

View File

@ -0,0 +1,53 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
class AuthService{
static Future<Map<String, dynamic>> login(String email, String password) async {
Map<String, dynamic> cats = {};
String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'email': email,
'password': password
}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
static Future<Map<String, dynamic>> register(String email, String password) async {
Map<String, dynamic> cats = {};
String url = 'http://localhost:8100/api/register/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'email': email,
'password': password
}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

View File

@ -0,0 +1,28 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
class CatService{
static Future<List<dynamic>?> loadCats() async {
List<dynamic> cats = [];
String url = 'http://localhost:8100/api/cats/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

View File

@ -0,0 +1,41 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
class DestinationService{
static Future<List<dynamic>> getDestinations(int user_id) async {
List<dynamic> cats = [];
String url = "http://localhost:8100/api/destinations/?user_id=${user_id}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
}
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
static Future<int> updateOrder(int action_id, int order, String dir) async {
int cats = 0;
String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
}
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

View File

@ -7,7 +7,7 @@ class LocationLineService{
final geo = GeoJson();
GeoJsonFeature? fs;
String url = 'http://container.intranet.sumasen.net:8100/api/location_line/';
String url = 'http://localhost:8100/api/location_line/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -7,7 +7,7 @@ class LocationPolygonervice{
final geo = GeoJson();
GeoJsonFeature? fs;
String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/';
String url = 'http://localhost:8100/api/location_polygon/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
String url = 'http://container.intranet.sumasen.net:8100/api/location/';
String url = 'http://localhost:8100/api/location/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -20,8 +20,15 @@ class LocationService{
return null;
}
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture) async {
String url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture;
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
String url = "";
if(cat.isNotEmpty){
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
}
else{
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
}
//String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -37,8 +44,14 @@ class LocationService{
}
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture) async {
String url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture;
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
String url = "";
if(cat.isNotEmpty){
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
}
else{
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
}
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -6,7 +6,7 @@ class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/';
String url = 'http://localhost:8100/api/perf_main/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -22,7 +22,7 @@ class PerfectureService{
static Future<List<dynamic>?> loadSubPerfectures(String sub) async {
List<dynamic> perfs = [];
String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub;
String url = 'http://localhost:8100/api/subperfinmain/?perf=' + sub;
//String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
@ -40,7 +40,7 @@ class PerfectureService{
static Future<List<dynamic>?> getMainPerfExt(String id) async {
List<dynamic> perfs = [];
String url = 'http://container.intranet.sumasen.net:8100/api/mainperfext/?perf=' + id;
String url = 'http://localhost:8100/api/mainperfext/?perf=' + id;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -57,7 +57,7 @@ class PerfectureService{
static Future<List<dynamic>?> getSubExt(String id) async {
List<dynamic> perfs = [];
String url = 'http://container.intranet.sumasen.net:8100/api/perfext/?sub_perf=' + id;
String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',