refactored rbac services
parent
1cc2a70a7f
commit
ba89592496
|
@ -66,7 +66,7 @@ class ModuleObjectsBloc extends Bloc<ModuleObjectsEvent, ModuleObjectsState> {
|
||||||
emit(ModuleObjectLoadingState());
|
emit(ModuleObjectLoadingState());
|
||||||
try {
|
try {
|
||||||
bool success = await RbacModuleObjectsServices.instance
|
bool success = await RbacModuleObjectsServices.instance
|
||||||
.deleteRbacModuleObject(moduleObjectId: event.moduleObjectId);
|
.delete(moduleObjectId: event.moduleObjectId);
|
||||||
if (success) {
|
if (success) {
|
||||||
moduleObjects
|
moduleObjects
|
||||||
.removeWhere((element) => element.id == event.moduleObjectId);
|
.removeWhere((element) => element.id == event.moduleObjectId);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/screens/profile/components/other_information/org_membership/add_modal.dart';
|
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
|
@ -10,17 +9,15 @@ import 'package:http/http.dart' as http;
|
||||||
class AgencyServices {
|
class AgencyServices {
|
||||||
static final AgencyServices _instance = AgencyServices();
|
static final AgencyServices _instance = AgencyServices();
|
||||||
static AgencyServices get instance => _instance;
|
static AgencyServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<Agency>> getAgencies() async {
|
|
||||||
List<Agency> agencies = [];
|
|
||||||
String path = Url.instance.agencies();
|
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
String path = Url.instance.postAgencies();
|
||||||
|
|
||||||
|
Future<List<Agency>> getAgencies() async {
|
||||||
|
List<Agency> agencies = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, headers: headers, param: {});
|
.getRequest(path: path, headers: headers, param: {});
|
||||||
|
@ -38,14 +35,9 @@ class AgencyServices {
|
||||||
}
|
}
|
||||||
return agencies;
|
return agencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<dynamic, dynamic>> add({required Agency agency}) async {
|
Future<Map<dynamic, dynamic>> add({required Agency agency}) async {
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
String path = Url.instance.postAgencies();
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": agency.name,
|
"name": agency.name,
|
||||||
"category_id": agency.category!.id,
|
"category_id": agency.category!.id,
|
||||||
|
@ -53,7 +45,8 @@ class AgencyServices {
|
||||||
"contact_info": null,
|
"contact_info": null,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance.postRequest(param: {},path: path, body: body,headers: headers);
|
http.Response response = await Request.instance
|
||||||
|
.postRequest(param: {}, path: path, body: body, headers: headers);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
statusResponse = data;
|
statusResponse = data;
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/profile/assigned_area.dart';
|
import 'package:unit2/model/profile/assigned_area.dart';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../../../utils/request.dart';
|
import '../../../utils/request.dart';
|
||||||
|
|
||||||
class RbacAssignedAreaServices {
|
class RbacAssignedAreaServices {
|
||||||
static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices();
|
static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices();
|
||||||
static RbacAssignedAreaServices get instance => _instance;
|
static RbacAssignedAreaServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
|
|
||||||
List<UserAssignedArea> userAssignedAreas = [];
|
|
||||||
String path = Url.instance.getAssignAreas();
|
String path = Url.instance.getAssignAreas();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
|
||||||
|
List<UserAssignedArea> userAssignedAreas = [];
|
||||||
Map<String, String> param = {
|
Map<String, String> param = {
|
||||||
"assigned_role__user__id": id.toString(),
|
"assigned_role__user__id": id.toString(),
|
||||||
};
|
};
|
||||||
|
@ -39,17 +37,15 @@ class RbacAssignedAreaServices {
|
||||||
}
|
}
|
||||||
return userAssignedAreas;
|
return userAssignedAreas;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> deleteAssignedArea({required int areaId}) async {
|
Future<bool> deleteAssignedArea({required int areaId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getAssignAreas()}$areaId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance.deleteRequest(
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
path: "${path + areaId.toString()}/",
|
||||||
|
headers: headers,
|
||||||
|
body: {},
|
||||||
|
param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,21 +56,23 @@ class RbacAssignedAreaServices {
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
Future<Map<dynamic, dynamic>> add ({required int userId, required int roleId, required int areaTypeId, required String areaId}) async{
|
|
||||||
String path = Url.instance.getAssignAreas();
|
Future<Map<dynamic, dynamic>> add(
|
||||||
Map<String, String> headers = {
|
{required int userId,
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
required int roleId,
|
||||||
'X-Client-Key': xClientKey,
|
required int areaTypeId,
|
||||||
'X-Client-Secret': xClientKeySecret
|
required String areaId}) async {
|
||||||
};
|
|
||||||
Map<dynamic, dynamic>? responseStatus = {};
|
Map<dynamic, dynamic>? responseStatus = {};
|
||||||
Map body = {
|
Map body = {
|
||||||
"user_id": userId,
|
"user_id": userId,
|
||||||
"role_id": roleId,
|
"role_id": roleId,
|
||||||
"assigned_areas": [{"areatypeid":areaTypeId,"areaid":areaId}]
|
"assigned_areas": [
|
||||||
|
{"areatypeid": areaTypeId, "areaid": areaId}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance.postRequest(path: path, headers: headers, body: body, param: {});
|
http.Response response = await Request.instance
|
||||||
|
.postRequest(path: path, headers: headers, body: body, param: {});
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
responseStatus = data;
|
responseStatus = data;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/login_data/user_info/module.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import '../../../model/rbac/rbac_rbac.dart';
|
import '../../../model/rbac/rbac_rbac.dart';
|
||||||
import '../../../utils/request.dart';
|
import '../../../utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
@ -10,16 +9,14 @@ class RbacModuleObjectsServices {
|
||||||
static final RbacModuleObjectsServices _instance =
|
static final RbacModuleObjectsServices _instance =
|
||||||
RbacModuleObjectsServices();
|
RbacModuleObjectsServices();
|
||||||
static RbacModuleObjectsServices get instance => _instance;
|
static RbacModuleObjectsServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
Future<List<ModuleObjects>> getModuleObjects() async {
|
|
||||||
List<ModuleObjects> moduleObjects = [];
|
|
||||||
String path = Url.instance.getModuleObjects();
|
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret':xClientSecret
|
||||||
};
|
};
|
||||||
|
String path = Url.instance.getModuleObjects();
|
||||||
|
Future<List<ModuleObjects>> getModuleObjects() async {
|
||||||
|
List<ModuleObjects> moduleObjects = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -38,19 +35,12 @@ class RbacModuleObjectsServices {
|
||||||
return moduleObjects;
|
return moduleObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
////Add
|
|
||||||
Future<Map<dynamic, dynamic>> add({
|
Future<Map<dynamic, dynamic>> add({
|
||||||
required int assignerId,
|
required int assignerId,
|
||||||
required int? moduleId,
|
required int? moduleId,
|
||||||
required List<int> objectsId,
|
required List<int> objectsId,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getModuleObjects();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"module_id": moduleId,
|
"module_id": moduleId,
|
||||||
"objects": objectsId,
|
"objects": objectsId,
|
||||||
|
@ -76,17 +66,11 @@ class RbacModuleObjectsServices {
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> deleteRbacModuleObject({required int moduleObjectId}) async {
|
Future<bool> delete({required int moduleObjectId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getModuleObjects()}$moduleObjectId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+moduleObjectId.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacModuleServices {
|
class RbacModuleServices {
|
||||||
static final RbacModuleServices _instance = RbacModuleServices();
|
static final RbacModuleServices _instance = RbacModuleServices();
|
||||||
static RbacModuleServices get instance => _instance;
|
static RbacModuleServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RBAC>> getRbacModule() async {
|
|
||||||
List<RBAC> modules = [];
|
|
||||||
String path = Url.instance.getModules();
|
String path = Url.instance.getModules();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key':xClientKey,
|
'X-Client-Key':xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret':xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RBAC>> getRbacModule() async {
|
||||||
|
List<RBAC> modules = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -43,13 +40,7 @@ class RbacModuleServices {
|
||||||
required String? slug,
|
required String? slug,
|
||||||
required String? short,
|
required String? short,
|
||||||
required int id}) async {
|
required int id}) async {
|
||||||
String path = Url.instance.getModules();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -88,13 +79,7 @@ class RbacModuleServices {
|
||||||
required int? createdBy,
|
required int? createdBy,
|
||||||
required int updatedBy,
|
required int updatedBy,
|
||||||
}) async {
|
}) async {
|
||||||
String path = "${Url.instance.getModules()}$moduleId/";
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -106,7 +91,7 @@ class RbacModuleServices {
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.putRequest(path: path, body: body, headers: headers, param: {});
|
.putRequest(path: "${path+moduleId.toString()}/", body: body, headers: headers, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
statusResponse = data;
|
statusResponse = data;
|
||||||
|
@ -127,14 +112,9 @@ class RbacModuleServices {
|
||||||
Future<bool> deleteRbacModule({required int moduleId}) async {
|
Future<bool> deleteRbacModule({required int moduleId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getModules()}$moduleId/";
|
String path = "${Url.instance.getModules()}$moduleId/";
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: '${path+moduleId.toString()}/', headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacObjectServices {
|
class RbacObjectServices {
|
||||||
static final RbacObjectServices _instance = RbacObjectServices();
|
static final RbacObjectServices _instance = RbacObjectServices();
|
||||||
static RbacObjectServices get instance => _instance;
|
static RbacObjectServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RBAC>> getRbacObjects() async {
|
|
||||||
List<RBAC> objects = [];
|
|
||||||
String path = Url.instance.getObject();
|
String path = Url.instance.getObject();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RBAC>> getRbacObjects() async {
|
||||||
|
List<RBAC> objects = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -43,13 +40,7 @@ class RbacObjectServices {
|
||||||
required String? slug,
|
required String? slug,
|
||||||
required String? short,
|
required String? short,
|
||||||
required int id}) async {
|
required int id}) async {
|
||||||
String path = Url.instance.getObject();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -67,7 +58,7 @@ class RbacObjectServices {
|
||||||
} else {
|
} else {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
String message = data['message'];
|
String message = data['message'];
|
||||||
statusResponse.addAll({'message': "Error Adding Object"});
|
statusResponse.addAll({'message': message});
|
||||||
statusResponse.addAll(
|
statusResponse.addAll(
|
||||||
{'success': false},
|
{'success': false},
|
||||||
);
|
);
|
||||||
|
@ -87,13 +78,8 @@ class RbacObjectServices {
|
||||||
required int? createdBy,
|
required int? createdBy,
|
||||||
required int updatedBy,
|
required int updatedBy,
|
||||||
}) async {
|
}) async {
|
||||||
String path = "${Url.instance.getObject()}$objectId/";
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -104,14 +90,14 @@ class RbacObjectServices {
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.putRequest(path: path, body: body, headers: headers, param: {});
|
.putRequest(path: "${path+objectId.toString()}/", body: body, headers: headers, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
statusResponse = data;
|
statusResponse = data;
|
||||||
} else {
|
} else {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
String message = data['message'];
|
String message = data['message'];
|
||||||
statusResponse.addAll({'message': "Error Updating Object"});
|
statusResponse.addAll({'message': message});
|
||||||
statusResponse.addAll(
|
statusResponse.addAll(
|
||||||
{'success': false},
|
{'success': false},
|
||||||
);
|
);
|
||||||
|
@ -124,15 +110,9 @@ class RbacObjectServices {
|
||||||
|
|
||||||
Future<bool> deleteRbacRole({required int objectId}) async {
|
Future<bool> deleteRbacRole({required int objectId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getObject()}$objectId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+objectId.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacOperationServices {
|
class RbacOperationServices {
|
||||||
static final RbacOperationServices _instance = RbacOperationServices();
|
static final RbacOperationServices _instance = RbacOperationServices();
|
||||||
static RbacOperationServices get instance => _instance;
|
static RbacOperationServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RBAC>> getRbacOperations() async {
|
|
||||||
List<RBAC> roles = [];
|
|
||||||
String path = Url.instance.getOperations();
|
String path = Url.instance.getOperations();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RBAC>> getRbacOperations() async {
|
||||||
|
List<RBAC> roles = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -43,13 +40,7 @@ class RbacOperationServices {
|
||||||
required String? slug,
|
required String? slug,
|
||||||
required String? short,
|
required String? short,
|
||||||
required int id}) async {
|
required int id}) async {
|
||||||
String path = Url.instance.getOperations();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -87,13 +78,7 @@ class RbacOperationServices {
|
||||||
required int? createdBy,
|
required int? createdBy,
|
||||||
required int updatedBy,
|
required int updatedBy,
|
||||||
}) async {
|
}) async {
|
||||||
String path = "${Url.instance.getRbacOperations()}$operationId/";
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -104,7 +89,7 @@ class RbacOperationServices {
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.putRequest(path: path, body: body, headers: headers, param: {});
|
.putRequest(path: '${path+operationId.toString()}/', body: body, headers: headers, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
statusResponse = data;
|
statusResponse = data;
|
||||||
|
@ -124,15 +109,9 @@ class RbacOperationServices {
|
||||||
|
|
||||||
Future<bool> delete({required int operation}) async {
|
Future<bool> delete({required int operation}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRbacOperations()}$operation/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: '${path+operation.toString()}/', headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/permission_assignment.dart';
|
import 'package:unit2/model/rbac/permission_assignment.dart';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
@ -9,15 +10,14 @@ class RbacPermissionAssignmentServices {
|
||||||
static final RbacPermissionAssignmentServices _instance =
|
static final RbacPermissionAssignmentServices _instance =
|
||||||
RbacPermissionAssignmentServices();
|
RbacPermissionAssignmentServices();
|
||||||
static RbacPermissionAssignmentServices get instance => _instance;
|
static RbacPermissionAssignmentServices get instance => _instance;
|
||||||
|
String path = Url.instance.getPermissionAssignment();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z",
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': "unitcYqAN7GGalyz"
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
Future<List<PermissionAssignment>> getPermissionAssignment() async {
|
Future<List<PermissionAssignment>> getPermissionAssignment() async {
|
||||||
List<PermissionAssignment> permissionAssignments = [];
|
List<PermissionAssignment> permissionAssignments = [];
|
||||||
String path = Url.instance.getPermissionAssignment();
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -25,7 +25,6 @@ class RbacPermissionAssignmentServices {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
if (data['data'] != null) {
|
if (data['data'] != null) {
|
||||||
for (var rbac in data['data']) {
|
for (var rbac in data['data']) {
|
||||||
|
|
||||||
PermissionAssignment permissionAssignment =
|
PermissionAssignment permissionAssignment =
|
||||||
PermissionAssignment.fromJson(rbac);
|
PermissionAssignment.fromJson(rbac);
|
||||||
permissionAssignments.add(permissionAssignment);
|
permissionAssignments.add(permissionAssignment);
|
||||||
|
@ -40,10 +39,9 @@ class RbacPermissionAssignmentServices {
|
||||||
|
|
||||||
Future<bool> deletePermissionAssignment({required int id}) async {
|
Future<bool> deletePermissionAssignment({required int id}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getPermissionAssignment()}$id/";
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+id.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +55,6 @@ class RbacPermissionAssignmentServices {
|
||||||
{required int assignerId,
|
{required int assignerId,
|
||||||
required List<int> opsId,
|
required List<int> opsId,
|
||||||
required int roleId}) async {
|
required int roleId}) async {
|
||||||
String path = Url.instance.getPermissionAssignment();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map body = {
|
Map body = {
|
||||||
"role_id": roleId,
|
"role_id": roleId,
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/permission.dart';
|
import 'package:unit2/model/rbac/permission.dart';
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacPermissionServices {
|
class RbacPermissionServices {
|
||||||
static final RbacPermissionServices _instance = RbacPermissionServices();
|
static final RbacPermissionServices _instance = RbacPermissionServices();
|
||||||
static RbacPermissionServices get instance => _instance;
|
static RbacPermissionServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RBACPermission>> getRbacPermission() async {
|
|
||||||
List<RBACPermission> permissions = [];
|
|
||||||
String path = Url.instance.getPersmissions();
|
String path = Url.instance.getPersmissions();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key':xClientKey,
|
'X-Client-Key':xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RBACPermission>> getRbacPermission() async {
|
||||||
|
List<RBACPermission> permissions = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -46,13 +42,7 @@ class RbacPermissionServices {
|
||||||
required int? objectId,
|
required int? objectId,
|
||||||
required List<int> operationsId,
|
required List<int> operationsId,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getPersmissions();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"object_id": objectId,
|
"object_id": objectId,
|
||||||
"operations": operationsId,
|
"operations": operationsId,
|
||||||
|
@ -80,15 +70,9 @@ class RbacPermissionServices {
|
||||||
|
|
||||||
Future<bool> deletePermission ({required int permissionId}) async {
|
Future<bool> deletePermission ({required int permissionId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getPersmissions()}$permissionId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+permissionId.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/assigned_role.dart';
|
import 'package:unit2/model/rbac/assigned_role.dart';
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import '../../../model/profile/basic_information/primary-information.dart';
|
import '../../../model/profile/basic_information/primary-information.dart';
|
||||||
|
|
||||||
class RbacRoleAssignmentServices {
|
class RbacRoleAssignmentServices {
|
||||||
static final RbacRoleAssignmentServices _instance =
|
static final RbacRoleAssignmentServices _instance =
|
||||||
RbacRoleAssignmentServices();
|
RbacRoleAssignmentServices();
|
||||||
static RbacRoleAssignmentServices get instance => _instance;
|
static RbacRoleAssignmentServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<AssignedRole>> getAssignedRoles(
|
|
||||||
{required String firstname, required String lastname}) async {
|
|
||||||
List<AssignedRole> assignedRoles = [];
|
|
||||||
String path = Url.instance.getRoleAssignment();
|
String path = Url.instance.getRoleAssignment();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<AssignedRole>> getAssignedRoles(
|
||||||
|
{required String firstname, required String lastname}) async {
|
||||||
|
List<AssignedRole> assignedRoles = [];
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> param = {
|
Map<String, String> param = {
|
||||||
"user__first_name__icontains": firstname,
|
"user__first_name__icontains": firstname,
|
||||||
"user__last_name__icontains": lastname
|
"user__last_name__icontains": lastname
|
||||||
|
@ -49,15 +46,9 @@ class RbacRoleAssignmentServices {
|
||||||
|
|
||||||
Future<bool> deleteAssignedRole({required int roleId}) async {
|
Future<bool> deleteAssignedRole({required int roleId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRoleAssignment()}$roleId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: '${path+roleId.toString()}/', headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -72,13 +63,7 @@ class RbacRoleAssignmentServices {
|
||||||
required int? assignerId,
|
required int? assignerId,
|
||||||
required List<int> roles,
|
required List<int> roles,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getRoleAssignment();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"user_id": userId,
|
"user_id": userId,
|
||||||
"roles": roles,
|
"roles": roles,
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/role_extend.dart';
|
import 'package:unit2/model/rbac/role_extend.dart';
|
||||||
import 'package:unit2/model/rbac/role_under.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import '../../../utils/request.dart';
|
import '../../../utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacRoleExtendServices {
|
class RbacRoleExtendServices {
|
||||||
static final RbacRoleExtendServices _instance = RbacRoleExtendServices();
|
static final RbacRoleExtendServices _instance = RbacRoleExtendServices();
|
||||||
static RbacRoleExtendServices get instance => _instance;
|
static RbacRoleExtendServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RolesExtend>> getRolesExtend() async {
|
|
||||||
List<RolesExtend> rolesextend = [];
|
|
||||||
String path = Url.instance.getRoleExtend();
|
String path = Url.instance.getRoleExtend();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
// try {
|
Future<List<RolesExtend>> getRolesExtend() async {
|
||||||
|
List<RolesExtend> rolesextend = [];
|
||||||
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
@ -32,9 +29,9 @@ class RbacRoleExtendServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// throw e.toString();
|
throw e.toString();
|
||||||
// }
|
}
|
||||||
return rolesextend;
|
return rolesextend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +40,7 @@ class RbacRoleExtendServices {
|
||||||
required int? roleId,
|
required int? roleId,
|
||||||
required List<int> rolesExtendsId,
|
required List<int> rolesExtendsId,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getRoleExtend();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"role_main_id": roleId,
|
"role_main_id": roleId,
|
||||||
"roles_extend": rolesExtendsId,
|
"roles_extend": rolesExtendsId,
|
||||||
|
@ -77,14 +68,12 @@ class RbacRoleExtendServices {
|
||||||
Future<bool> delete({required int roleExtendId}) async {
|
Future<bool> delete({required int roleExtendId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRoleExtend()}$roleExtendId/";
|
String path = "${Url.instance.getRoleExtend()}$roleExtendId/";
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance.deleteRequest(
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
path: '${path + roleExtendId.toString()}/',
|
||||||
|
headers: headers,
|
||||||
|
body: {},
|
||||||
|
param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/login_data/user_info/module.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:unit2/model/rbac/role_module.dart';
|
import 'package:unit2/model/rbac/role_module.dart';
|
||||||
import '../../../model/rbac/rbac_rbac.dart';
|
import 'package:unit2/utils/global.dart';
|
||||||
import '../../../utils/request.dart';
|
import '../../../utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
|
@ -11,17 +10,14 @@ class RbacRoleModuleServices {
|
||||||
static final RbacRoleModuleServices _instance =
|
static final RbacRoleModuleServices _instance =
|
||||||
RbacRoleModuleServices();
|
RbacRoleModuleServices();
|
||||||
static RbacRoleModuleServices get instance => _instance;
|
static RbacRoleModuleServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RoleModules>> getRoleModules() async {
|
|
||||||
List<RoleModules> roleModules = [];
|
|
||||||
String path = Url.instance.getRoleModules();
|
String path = Url.instance.getRoleModules();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RoleModules>> getRoleModules() async {
|
||||||
|
List<RoleModules> roleModules = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -46,13 +42,7 @@ class RbacRoleModuleServices {
|
||||||
required int? roleId,
|
required int? roleId,
|
||||||
required List<int> moduleIds,
|
required List<int> moduleIds,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getRoleModules();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"role_id": roleId,
|
"role_id": roleId,
|
||||||
"modules": moduleIds,
|
"modules": moduleIds,
|
||||||
|
@ -80,15 +70,9 @@ class RbacRoleModuleServices {
|
||||||
|
|
||||||
Future<bool> deleteRbacRoleModule({required int moduleObjectId}) async {
|
Future<bool> deleteRbacRoleModule({required int moduleObjectId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRoleModules()}$moduleObjectId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+moduleObjectId.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/rbac.dart';
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
import 'package:unit2/sevices/profile/education_services.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacRoleServices {
|
class RbacRoleServices {
|
||||||
static final RbacRoleServices _instance = RbacRoleServices();
|
static final RbacRoleServices _instance = RbacRoleServices();
|
||||||
static RbacRoleServices get instance => _instance;
|
static RbacRoleServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RBAC>> getRbacRoles() async {
|
|
||||||
List<RBAC> roles = [];
|
|
||||||
String path = Url.instance.getRbacRoles();
|
String path = Url.instance.getRbacRoles();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RBAC>> getRbacRoles() async {
|
||||||
|
List<RBAC> roles = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -45,13 +41,7 @@ class RbacRoleServices {
|
||||||
required String? slug,
|
required String? slug,
|
||||||
required String? short,
|
required String? short,
|
||||||
required int id}) async {
|
required int id}) async {
|
||||||
String path = Url.instance.getRbacRoles();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -89,13 +79,7 @@ class RbacRoleServices {
|
||||||
required int? createdBy,
|
required int? createdBy,
|
||||||
required int updatedBy,
|
required int updatedBy,
|
||||||
}) async {
|
}) async {
|
||||||
String path = "${Url.instance.getRbacRoles()}$roleId/";
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String? newSlug = slug?.replaceAll(" ", "-");
|
String? newSlug = slug?.replaceAll(" ", "-");
|
||||||
Map body = {
|
Map body = {
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -105,8 +89,11 @@ class RbacRoleServices {
|
||||||
"updated_by_id": updatedBy
|
"updated_by_id": updatedBy
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance.putRequest(
|
||||||
.putRequest(path: path, body: body, headers: headers, param: {});
|
path: "${path + roleId.toString()}/",
|
||||||
|
body: body,
|
||||||
|
headers: headers,
|
||||||
|
param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map data = jsonDecode(response.body);
|
Map data = jsonDecode(response.body);
|
||||||
statusResponse = data;
|
statusResponse = data;
|
||||||
|
@ -126,15 +113,12 @@ class RbacRoleServices {
|
||||||
|
|
||||||
Future<bool> deleteRbacRole({required int roleId}) async {
|
Future<bool> deleteRbacRole({required int roleId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRbacRoles()}$roleId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance.deleteRequest(
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
path: "${path + roleId.toString()}/",
|
||||||
|
headers: headers,
|
||||||
|
body: {},
|
||||||
|
param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,21 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/rbac/role_under.dart';
|
import 'package:unit2/model/rbac/role_under.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import '../../../utils/request.dart';
|
import '../../../utils/request.dart';
|
||||||
import '../../../utils/urls.dart';
|
import '../../../utils/urls.dart';
|
||||||
|
|
||||||
class RbacRoleUnderServices {
|
class RbacRoleUnderServices {
|
||||||
static final RbacRoleUnderServices _instance = RbacRoleUnderServices();
|
static final RbacRoleUnderServices _instance = RbacRoleUnderServices();
|
||||||
static RbacRoleUnderServices get instance => _instance;
|
static RbacRoleUnderServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RolesUnder>> getRolesUnder() async {
|
|
||||||
List<RolesUnder> rolesUnder = [];
|
|
||||||
String path = Url.instance.getRolesUnder();
|
String path = Url.instance.getRolesUnder();
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RolesUnder>> getRolesUnder() async {
|
||||||
|
List<RolesUnder> rolesUnder = [];
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: {}, path: path, headers: headers);
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
@ -42,13 +40,8 @@ class RbacRoleUnderServices {
|
||||||
required int? roleId,
|
required int? roleId,
|
||||||
required List<int> rolesId,
|
required List<int> rolesId,
|
||||||
}) async {
|
}) async {
|
||||||
String path = Url.instance.getRolesUnder();
|
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
Map body = {
|
Map body = {
|
||||||
"role_main_id": roleId,
|
"role_main_id": roleId,
|
||||||
"roles_under": rolesId,
|
"roles_under": rolesId,
|
||||||
|
@ -76,15 +69,9 @@ class RbacRoleUnderServices {
|
||||||
|
|
||||||
Future<bool> deleteRbacRoleUnder({required int roleUnderId}) async {
|
Future<bool> deleteRbacRoleUnder({required int roleUnderId}) async {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
String path = "${Url.instance.getRolesUnder ()}$roleUnderId/";
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
.deleteRequest(path: "${path+roleUnderId.toString()}/", headers: headers, body: {}, param: {});
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,24 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:unit2/model/utils/position.dart';
|
import 'package:unit2/model/utils/position.dart';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import '../../../model/rbac/rbac_station.dart';
|
import '../../../model/rbac/rbac_station.dart';
|
||||||
import '../../../model/rbac/station_type.dart';
|
import '../../../model/rbac/station_type.dart';
|
||||||
import '../../../model/roles/pass_check/station_assign_area.dart';
|
|
||||||
|
|
||||||
class RbacStationServices {
|
class RbacStationServices {
|
||||||
static final RbacStationServices _instance = RbacStationServices();
|
static final RbacStationServices _instance = RbacStationServices();
|
||||||
static RbacStationServices get instance => _instance;
|
static RbacStationServices get instance => _instance;
|
||||||
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
|
||||||
String xClientKeySecret = "unitcYqAN7GGalyz";
|
|
||||||
|
|
||||||
Future<List<RbacStation>> getStations({required String agencyId}) async {
|
|
||||||
List<RbacStation> stations = [];
|
|
||||||
String path = Url.instance.getStation();
|
String path = Url.instance.getStation();
|
||||||
Map<String, String> param = {"government_agency_id": agencyId.toString()};
|
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
'X-Client-Key': xClientKey,
|
'X-Client-Key': xClientKey,
|
||||||
'X-Client-Secret': xClientKeySecret
|
'X-Client-Secret': xClientSecret
|
||||||
};
|
};
|
||||||
|
Future<List<RbacStation>> getStations({required String agencyId}) async {
|
||||||
|
List<RbacStation> stations = [];
|
||||||
|
Map<String, String> param = {"government_agency_id": agencyId.toString()};
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(param: param, path: path, headers: headers);
|
.getRequest(param: param, path: path, headers: headers);
|
||||||
|
@ -42,9 +39,6 @@ class RbacStationServices {
|
||||||
|
|
||||||
Future<List<StationType>> getStationTypes() async {
|
Future<List<StationType>> getStationTypes() async {
|
||||||
String path = Url.instance.getStationType();
|
String path = Url.instance.getStationType();
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
};
|
|
||||||
List<StationType> stationTypes = [];
|
List<StationType> stationTypes = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -67,11 +61,7 @@ class RbacStationServices {
|
||||||
|
|
||||||
Future<List<PositionTitle>> getPositionTitle() async {
|
Future<List<PositionTitle>> getPositionTitle() async {
|
||||||
String path = Url.instance.getPositionTitle();
|
String path = Url.instance.getPositionTitle();
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
};
|
|
||||||
List<PositionTitle> positions = [];
|
List<PositionTitle> positions = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http.Response response = await Request.instance
|
http.Response response = await Request.instance
|
||||||
.getRequest(path: path, param: {}, headers: headers);
|
.getRequest(path: path, param: {}, headers: headers);
|
||||||
|
@ -93,13 +83,7 @@ class RbacStationServices {
|
||||||
Future<Map<dynamic, dynamic>> addStation(
|
Future<Map<dynamic, dynamic>> addStation(
|
||||||
{required RbacStation station}) async {
|
{required RbacStation station}) async {
|
||||||
Map<dynamic, dynamic> statusResponse = {};
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
'X-Client-Key': xClientKey,
|
|
||||||
'X-Client-Secret': xClientKeySecret
|
|
||||||
};
|
|
||||||
String path = Url.instance.postStation();
|
String path = Url.instance.postStation();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map body = {
|
Map body = {
|
||||||
"station_name": station.stationName,
|
"station_name": station.stationName,
|
||||||
|
|
|
@ -10,7 +10,6 @@ double safeAreaHorizontal = 0;
|
||||||
double safeAreaVertical = 0;
|
double safeAreaVertical = 0;
|
||||||
double safeBlockHorizontal = 0;
|
double safeBlockHorizontal = 0;
|
||||||
double safeBlockVertical = 0;
|
double safeBlockVertical = 0;
|
||||||
|
|
||||||
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
|
||||||
const xClientSecret = "unitcYqAN7GGalyz";
|
const xClientSecret = "unitcYqAN7GGalyz";
|
||||||
String? globalFistname;
|
String? globalFistname;
|
||||||
|
|
Loading…
Reference in New Issue