app-starlock/star_lock/lib/network/api_provider.dart
2023-09-18 09:29:33 +08:00

912 lines
27 KiB
Dart

import 'dart:convert';
import 'package:get/get.dart';
import 'api_provider_base.dart';
class ApiProvider extends BaseProvider {
Future<Response> getVerificationCode(String countryCode, String account,
String channel, String codeType, String uniqueid, String xWidth) =>
post(
getVerificationCodeUrl.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
"channel": channel,
'codeType': codeType,
"uniqueid": uniqueid,
'xWidth': xWidth,
}));
Future<Response> register(String countryCode, String countryId, String mobile,
String password, String uniqueid, String verificationCode) =>
post(registerUrl.toUrl, null, query: {
'countryCode': countryCode,
'countryId': countryId,
"mobile": mobile,
'password': password,
'platId': "2",
"uniqueid": uniqueid,
'verificationCode': verificationCode,
});
// post(
// registerUrl.toUrl,
// jsonEncode({
// 'countryCode': countryCode,
// 'countryId': countryId,
// "mobile": mobile,
// 'password': password,
// 'platId': "2",
// "uniqueid": uniqueid,
// 'verificationCode': verificationCode,
// }));
Future<Response> getSliderVerifyImg(String countryCode, String account) =>
post(
getSliderVerifyImgUrl.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
}));
Future<Response> checkSliderVerifyImg(
String countryCode, String account, String xWidth) =>
post(
checkImgUrl.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
'xWidth': xWidth,
}));
Future<Response> login(String loginType, String password, String countryCode,
String username) =>
post(
loginUrl.toUrl,
jsonEncode({
'loginType': loginType,
'password': password,
"platId": "2",
'uniqueid': "477E6814-289D-402A-9F49-F89A8BD05D63",
'countryCode': countryCode,
"username": username
}));
Future<Response> resetPassword(
String countryCode,
String account,
String date,
String newPassword,
String uniqueid,
String verificationCode) =>
post(
resetPasswordURL.toUrl,
jsonEncode({
'countryCode': countryCode,
'account': account,
"date": date,
'newPassword': newPassword,
"uniqueid": uniqueid,
'verificationCode': verificationCode,
}));
Future<Response> getCountryRegion(String type) =>
post(getCountryRegionURL.toUrl, jsonEncode({'type': type}));
Future<Response> electronicKeyList(
String endDate,
String keyId,
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
String startDate,
String keyRight) =>
post(
electronicKeyListURL.toUrl,
jsonEncode({
'endDate': endDate,
'keyId': keyId,
"keyStatus": keyStatus,
'lockId': lockId,
"operatorUid": operatorUid,
'pageNo': pageNo,
'pageSize': pageSize,
'startDate': startDate,
'keyRight': keyRight
}));
Future<Response> sendElectronicKey(
String createUser,
String countryCode,
String usernameType,
String endDate,
String faceAuthentication,
String isCameraEnable,
String isRemoteUnlock,
String keyNameForAdmin,
String keyRight,
String keyType,
String lockId,
String operatorUid,
String receiverUsername,
String remarks,
String startDate,
List weekDays) =>
post(
sendElectronicKeyURL.toUrl,
jsonEncode({
'createUser': createUser,
'countryCode': countryCode,
'usernameType': usernameType,
'endDate': endDate,
'faceAuthentication': faceAuthentication,
'isCameraEnable': isCameraEnable,
'isRemoteUnlock': isRemoteUnlock,
'keyNameForAdmin': keyNameForAdmin,
'keyRight': keyRight,
'keyType': keyType,
'lockId': lockId,
'operatorUid': operatorUid,
'receiverUsername': receiverUsername,
'remarks': remarks,
'startDate': startDate,
'weekDays': weekDays
}));
Future<Response> uploadElectricQuantity(
String electricQuantity,
String lockId,
) =>
post(
uploadElectricQuantityURL.toUrl,
jsonEncode({
'electricQuantity': electricQuantity,
'lockId': lockId,
}));
Future<Response> modifyKeyName(
String keyId,
String lockId,
String keyName,
String operatorUid,
) =>
post(
modifyKeyNameURL.toUrl,
jsonEncode({
'keyId': keyId,
'lockId': lockId,
'keyName': keyName,
'operatorUid': operatorUid,
}));
Future<Response> modifyKeyNameForAdmin(
String keyId,
String keyNameForAdmin,
String operatorUid,
) =>
post(
modifyKeyNameForAdminURL.toUrl,
jsonEncode({
'keyId': keyId,
'keyNameForAdmin': keyNameForAdmin,
'operatorUid': operatorUid,
}));
Future<Response> updateKeyDate(
String keyId,
String lockId,
String endDate,
String endDay,
String operatorUid,
String startDate,
String startDay,
List weekDays) =>
post(
updateKeyDateURL.toUrl,
jsonEncode({
'keyId': keyId,
'lockId': lockId,
'endDate': endDate,
'endDay': endDay,
'operatorUid': operatorUid,
'startDate': startDate,
'startDay': startDay,
'weekDays': weekDays,
}));
Future<Response> resetElectronicKey(String lockId, String operatorUid) =>
post(resetElectronicKeyURL.toUrl,
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
Future<Response> lockRecordList(
String endDate,
String keyId,
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
String startDate,
String recordType,
String searchStr,
String timezoneRawOffSet,
String keyboardPwdId,
String cardId,
String fingerprintId) =>
post(
keyOperationRecordURL.toUrl,
jsonEncode({
'endDate': endDate,
'keyId': keyId,
"keyStatus": keyStatus,
'lockId': lockId,
"operatorUid": operatorUid,
'pageNo': pageNo,
'pageSize': pageSize,
'startDate': startDate,
'recordType': recordType,
'searchStr': searchStr,
'timezoneRawOffSet': timezoneRawOffSet,
'keyboardPwdId': keyboardPwdId,
'cardId': cardId,
'fingerprintId': fingerprintId
}));
// 绑定蓝牙管理员
Future<Response> bindingBlueAdmin(
String bindingDate,
String hotelMode,
String lockAlias,
Map lockData,
String nbInitSuccess,
Map position,
Map bluetooth,
String deviceNo,
String lockUserNo,
String pwdTimestamp) =>
post(
bindingBlueAdminURL.toUrl,
jsonEncode({
'bindingDate': bindingDate,
'hotelMode': hotelMode,
"lockAlias": lockAlias,
'lockData': lockData,
"nbInitSuccess": nbInitSuccess,
'position': position,
'bluetooth': bluetooth,
'deviceNo': deviceNo,
'lockUserNo': lockUserNo,
'pwdTimestamp': pwdTimestamp,
}));
// 获取锁信息
Future<Response> getLockInfo(String lastUpdateDate, String pageNo) => post(
getLockInfoURL.toUrl,
jsonEncode({
'lastUpdateDate': lastUpdateDate,
"pageNo": pageNo,
}));
// 删除锁
Future<Response> deletLockInfo(String lockId) => post(
deletLockURL.toUrl,
jsonEncode({
'lockId': lockId,
}));
// 获取Wifi锁服务器
Future<Response> getWifiLockServiceIpAndPort() =>
post(getWifiServiceIpURL.toUrl, jsonEncode({}));
Future<Response> passwordKeyList(
String keyStatus,
String lockId,
String operatorUid,
String pageNo,
String pageSize,
) =>
post(
passwordKeyListURL.toUrl,
jsonEncode({
'keyStatus': keyStatus,
'lockId': lockId,
'operatorUid': operatorUid,
'pageNo': pageNo,
'pageSize': pageSize
}));
Future<Response> resetPasswordKey(String lockId, String operatorUid) => post(
resetPasswordURL.toUrl,
jsonEncode({'lockId': lockId, 'operatorUid': operatorUid}));
Future<Response> getKeyboardPwd(
String endDate,
String isExclusive,
String keyboardPwdName,
String keyboardPwdType,
String keyboardPwdVersion,
String lockId,
String operatorUid,
String startDate,
String timezoneRawOffSet,
) =>
post(
passwordKeyGetURL.toUrl,
jsonEncode({
'endDate': endDate,
'isExclusive': isExclusive,
'keyboardPwdName': keyboardPwdName,
'keyboardPwdType': keyboardPwdType,
'keyboardPwdVersion': keyboardPwdVersion,
'lockId': lockId,
'operatorUid': operatorUid,
'startDate': startDate,
'timezoneRawOffSet': timezoneRawOffSet
}));
Future<Response> addKeyboardPwd(
String lockId,
String keyboardPwdName,
String keyboardPwd,
String keyboardPwdType,
String startDate,
String endDate,
String addType,
) =>
post(
passwordKeyAddURL.toUrl,
jsonEncode({
'lockId': lockId,
'keyboardPwdName': keyboardPwdName,
'keyboardPwd': keyboardPwd,
'keyboardPwdType': keyboardPwdType,
'startDate': startDate,
'endDate': endDate,
'addType': addType,
}));
Future<Response> updateKeyboardPwd(
String lockId,
String keyboardPwdId,
String keyboardPwdName,
String newKeyboardPwd,
String startDate,
String endDate,
String changeType,
) =>
post(
updatePasswordKeyURL.toUrl,
jsonEncode({
'lockId': lockId,
'keyboardPwdId': keyboardPwdId,
'keyboardPwdName': keyboardPwdName,
'newKeyboardPwd': newKeyboardPwd,
'startDate': startDate,
'endDate': endDate,
'changeType': changeType,
}));
Future<Response> clearOperationRecord(String lockId) =>
post(clearOperationRecordURL.toUrl, jsonEncode({'lockId': lockId}));
Future<Response> addLockGroup(String groupName, String operatorUid) => post(
addlockGroupURL.toUrl,
jsonEncode({'groupName': groupName, 'operatorUid': operatorUid}));
Future<Response> setLockGroup(String lockId, String groupId) => post(
setlockGroupURL.toUrl,
jsonEncode({'lockId': lockId, 'groupId': groupId}));
Future<Response> lockGroupList(String type) =>
post(lockGroupListURL.toUrl, jsonEncode({'type': type}));
Future<Response> deleteElectronicKey(String keyId) =>
post(deleteElectronicKeyURL.toUrl, jsonEncode({'keyId': keyId}));
Future<Response> deleteAdministrator(String uid, String includeUnderlings) =>
post(deleteElectronicKeyURL.toUrl,
jsonEncode({'uid': uid, 'includeUnderlings': includeUnderlings}));
Future<Response> updateAdministrator(String uid, String name, String endDate,
String startDate, String isRemoteUnlock) =>
post(
deleteElectronicKeyURL.toUrl,
jsonEncode({
'uid': uid,
'name': name,
'endDate': endDate,
'startDate': startDate,
'isRemoteUnlock': isRemoteUnlock
}));
Future<Response> expireLockList(
String operatorUid, String pageNo, String pageSize) =>
post(
expireLockListURL.toUrl,
jsonEncode({
'operatorUid': operatorUid,
'pageNo': pageNo,
'pageSize': pageSize,
}));
Future<Response> deleteKeyboardPwd(
String lockId, String keyboardPwdId, String deleteType) =>
post(
deleteKeyboardPwdURL.toUrl,
jsonEncode({
'lockId': lockId,
'keyboardPwdId': keyboardPwdId,
'deleteType': deleteType
}));
Future<Response> updateSetting(String lockId, String isOn, String type) =>
post(updateSettingURL.toUrl,
jsonEncode({'lockId': lockId, 'isOn': isOn, 'type': type}));
Future<Response> keyGroupList(String type) =>
post(keyGroupListURL.toUrl, jsonEncode({'type': type}));
Future<Response> lockListByGroup(String type, String keyGroupId) => post(
lockListByGroupURL.toUrl,
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
/// 锁设置模块
// 远程开锁
Future<Response> remoteUnlockingOpenOrCloseLoadData(
String lockId, String featureValue) =>
post(
updateSpecialValueUrl.toUrl,
jsonEncode({
'lockId': lockId,
'featureValue': featureValue,
}));
// 自动闭锁
Future<Response> setAutoUnlockLoadData(
String lockId, String autoLockTime, String type) =>
post(
setAutoLockTimeUrl.toUrl,
jsonEncode({
'lockId': lockId,
'autoLockTime': autoLockTime,
'type': type,
}));
// 获取锁的常开模式设置
Future<Response> getPassageModeConfigLoadData(String lockId) => post(
getPassageModeConfigUrl.toUrl,
jsonEncode({
'lockId': lockId,
}));
// 获取锁的常开模式设置
Future<Response> configPassageMode(
String lockId,
String passageMode,
String autoUnlock,
String type,
String startDate,
String endDate,
String isAllDay,
List weekDays) =>
post(
configPassageModeUrl.toUrl,
jsonEncode({
'lockId': lockId,
'passageMode': passageMode,
'autoUnlock': autoUnlock,
'type': type,
'startDate': startDate,
'endDate': endDate,
'isAllDay': isAllDay,
'weekDays': weekDays,
}));
// 获取锁的常开模式设置
Future<Response> setLockSetGeneralSetting(
String lockId, String changeType, String isOn, String type) =>
post(
updateSettingUrl.toUrl,
jsonEncode({
'lockId': lockId,
'changeType': changeType,
'isOn': isOn,
'type': type,
}));
// 通过网关获取锁的时间
Future<Response> getLockTimeFromGatewayLoadData(String lockId) => post(
roomQueryDateUrl.toUrl,
jsonEncode({
'lockId': lockId,
}));
// 获取服务器当前时间
Future<Response> getServerDatetimeLoadData(String lockId) => post(
getServerDatetimeUrl.toUrl,
jsonEncode({
'lockId': lockId,
}));
// 锁诊断
Future<Response> setLockDiagnoseData(
String lockId,
String electricQuantity,
String firmwareRevision,
String hardwareRevision,
String lockDate,
String modelNum,
String pwdInfo,
String timestamp) =>
post(
lockDiagnoseUrl.toUrl,
jsonEncode({
'lockId': lockId,
'electricQuantity': electricQuantity,
'firmwareRevision': firmwareRevision,
'hardwareRevision': hardwareRevision,
'lockDate': lockDate,
'modelNum': modelNum,
'pwdInfo': pwdInfo,
'timestamp': timestamp,
}));
// 获取锁版本信息
Future<Response> getLockVersionInfoLoadData(String lockId) => post(
getLockVersionInfoUrl.toUrl,
jsonEncode({
'lockId': lockId,
}));
// 开启考勤获取考勤信息
Future<Response> openCheckingInGetData(String lockId) => post(
openCheckingInURL.toUrl,
jsonEncode({
'lockId': lockId,
}),
isUnShowLoading: true
);
// 设置考勤时创建公司
Future<Response> setCheckInCreateCompanyData(
String lockId,
String attendanceType,
String companyName,
List workDay,
String workEndTime,
String workStartTime) =>
post(
setCheckInCreateCompanyURL.toUrl,
jsonEncode({
'lockId': lockId,
'attendanceType': attendanceType,
'companyName': companyName,
'workDay': workDay,
'workEndTime': workEndTime,
'workStartTime': workStartTime,
}));
// 获取开锁提醒
Future<Response> setLockPickingReminderData(
String lockId, String keyId, String monitorFlag) =>
post(
setLockPickingReminderDataURL.toUrl,
jsonEncode({
'lockId': lockId,
'keyId': keyId,
'monitorFlag': monitorFlag,
}));
// 获取员工列表
Future<Response> getStaffListData(String companyId, String lockId) => post(
getStaffListURL.toUrl,
jsonEncode({
'companyId': companyId,
'lockId': lockId,
}));
// 添加员工
Future<Response> addStaffData(
String attendanceType,
String attendanceWay,
String companyId,
String have,
String staffName,
String countryCode,
String usernameType) =>
post(
addStaffURL.toUrl,
jsonEncode({
'attendanceType': attendanceType,
'attendanceWay': attendanceWay,
'companyId': companyId,
'have': have,
'staffName': staffName,
'countryCode': countryCode,
'usernameType': usernameType,
}));
// 编辑员工 addHolidaysData
Future<Response> editStaffData(
String attendanceType,
String attendanceWay,
String staffId,
String have,
String staffName,
String countryCode,
String usernameType) =>
post(
editStaffURL.toUrl,
jsonEncode({
'attendanceType': attendanceType,
'attendanceWay': attendanceWay,
'staffId': staffId,
'have': have,
'staffName': staffName,
'countryCode': countryCode,
'usernameType': usernameType,
}));
// 添加员工选择钥匙
Future<Response> addStaffSeletKeyData(
String companyId,
String type) =>
post(
addStaffSeletKeyURL.toUrl,
jsonEncode({
'companyId': companyId,
'type': type,
}));
// 添加假期
Future<Response> addHolidaysData(
String companyId,
String fillClassDate,
String vacationEndDate,
String vacationName,
String vacationStartDate) =>
post(
addHolidaysURL.toUrl,
jsonEncode({
'companyId': companyId,
'fillClassDate': fillClassDate,
'vacationEndDate': vacationEndDate,
'vacationName': vacationName,
'vacationStartDate': vacationStartDate,
}));
// 假期列表
Future<Response> holidaysListData(
String companyId,
String vacationYear) =>
post(
holidaysListURL.toUrl,
jsonEncode({
'companyId': companyId,
'vacationYear': vacationYear,
}));
// 删除假期
Future<Response> deletHolidaysData(
String vacationId) =>
post(
holidaysDeleteURL.toUrl,
jsonEncode({
'vacationId': vacationId,
}));
// 获取考勤设置信息
Future<Response> getCheckInSetInfoData(
String companyId) =>
post(
getCheckInSetInfoURL.toUrl,
jsonEncode({
'companyId': companyId,
}));
// 修改考勤设置信息
Future<Response> editCheckInSetInfoData(
String attendanceType,
String companyId,
String type,
String companyName,
String workEndTime,
String workStartTime,
List<int> workDay) =>
post(
editCheckInSetInfoURL.toUrl,
jsonEncode({
'attendanceType': attendanceType,
'companyId': companyId,
'type': type,
'companyName': companyName,
'workEndTime': workEndTime,
'workStartTime': workStartTime,
'workDay': workDay,
}));
// 获取考勤列表 -- 早到榜日榜
Future<Response> getCheckInListEarlyArrivalWithDateData(String companyId, String attendanceDate) =>
post(
getAttendanceRecordListByDateURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
}));
// 获取考勤列表 -- 早到榜月榜
Future<Response> getCheckInListEarlyArrivalWithMonthData(String companyId, String attendanceDate) =>
post(
getAttendanceRecordListByMonthURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
}));
// 获取考勤列表 -- 迟到榜日榜
Future<Response> getCheckInListLateTimesWithDateData(String companyId, String attendanceDate) =>
post(
getAttendanceRecordListLateTimesByDateURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
}));
// 获取考勤列表 -- 迟到榜月榜
Future<Response> getCheckInListLateTimesWithMonthData(String companyId, String attendanceDate) =>
post(
getAttendanceRecordListLateTimesByMonthURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
}));
// 获取考勤列表 -- 勤奋榜
Future<Response> getCheckInListHardworkingData(String companyId, String attendanceDate, String type) =>
post(
getAttendanceRecordHardworkingListURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
'type': type,
}));
// 获取考勤详情
Future<Response> getCheckInDetailData(String companyId, String attendanceDate, String staffId) =>
post(
getAttendanceRecordDtailURL.toUrl,
jsonEncode({
'companyId': companyId,
'attendanceDate': attendanceDate,
'staffId': staffId,
}));
// 获取指纹列表
Future<Response> getFingerprintsListData(String lockId, String pageNo, String pageSize, String searchStr) =>
post(
getFingerprintListURL.toUrl,
jsonEncode({
'lockId': lockId,
'pageNo': pageNo,
'pageSize': pageSize,
'searchStr': searchStr,
}));
// 添加指纹
Future<Response> addFingerprintsData(
String lockId,
String endDate,
String addType,
String fingerprintName,
String fingerprintNumber,
String fingerprintType,
String isCoerced,
String startDate,
String cyclicConfig,) =>
post(
addFingerprintURL.toUrl,
jsonEncode({
'lockId': lockId,
'endDate': endDate,
'addType': addType,
'fingerprintName': fingerprintName,
'fingerprintNumber': fingerprintNumber,
'fingerprintType': fingerprintType,
'isCoerced': isCoerced,
'startDate': startDate,
'cyclicConfig': cyclicConfig,
}));
Future<Response> listLockByGroup(String type, String keyGroupId) => post(
listLockByGroupURL.toUrl,
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
Future<Response> getKeyDetail(String lockId) =>
post(getKeyDetailURL.toUrl, jsonEncode({'lockId': lockId}));
Future<Response> lockUserList(
String pageNo, String pageSize, String searchStr) =>
post(
lockUserListURL.toUrl,
jsonEncode(
{'pageNo': pageNo, 'pageSize': pageSize, 'searchStr': searchStr}));
Future<Response> keyListByUser(String pageNo, String pageSize, String uid) =>
post(keyListByUserURL.toUrl,
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize, 'uid': uid}));
Future<Response> authorizedAdminList(String pageNo, String pageSize) => post(
authorizedAdminListURL.toUrl,
jsonEncode({'pageNo': pageNo, 'pageSize': pageSize}));
Future<Response> canSendKey(
String endDate, List keyGroupIdList, List lockIdList) =>
post(
canSendKeyURL.toUrl,
jsonEncode({
'endDate': endDate,
'keyGroupIdList': keyGroupIdList,
'lockIdList': lockIdList
}));
Future<Response> batchSendKey(
String endDate,
List keyGroupIdList,
List lockIdList,
String createUser,
String isRemoteUnlock,
String keyNameForAdmin,
String receiverUsername,
String startDate,
String countryCode,
String usernameType,
List weekDays) =>
post(
batchSendKeyURL.toUrl,
jsonEncode({
'endDate': endDate,
'keyGroupIdList': keyGroupIdList,
'lockIdList': lockIdList,
'createUser': createUser,
'isRemoteUnlock': isRemoteUnlock,
'keyNameForAdmin': keyNameForAdmin,
'receiverUsername': receiverUsername,
'startDate': startDate,
'countryCode': countryCode,
'usernameType': usernameType,
'weekDays': weekDays,
}));
Future<Response> addAuthorizedAdmin(
String createUser,
String endDate,
String isRemoteUnlock,
List keyGroupIdList,
List lockIdList,
String name,
String startDate,
String userid,
String countryCode,
String usernameType) =>
post(
addAuthorizedAdminURL.toUrl,
jsonEncode({
'createUser': createUser,
'endDate': endDate,
'isRemoteUnlock': isRemoteUnlock,
'keyGroupIdList': keyGroupIdList,
'lockIdList': lockIdList,
'name': name,
'startDate': startDate,
'userid': userid,
'countryCode': countryCode,
'usernameType': usernameType
}));
}
extension ExtensionString on String {
String get toUrl => this;
}