2023-07-27 15:29:37 +08:00
|
|
|
|
import 'package:get/get.dart';
|
2023-08-23 14:27:50 +08:00
|
|
|
|
import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart';
|
2023-08-17 18:54:19 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
2023-08-16 17:35:43 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
2023-08-23 14:27:50 +08:00
|
|
|
|
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
2023-07-29 18:33:48 +08:00
|
|
|
|
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
|
|
|
|
|
|
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
|
2023-07-29 09:25:21 +08:00
|
|
|
|
import '../login/login/entity/LoginEntity.dart';
|
2023-08-02 09:22:39 +08:00
|
|
|
|
import '../login/register/entity/SendValidationCodeEntity.dart';
|
2023-07-27 15:29:37 +08:00
|
|
|
|
import 'api_provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class ApiRepository {
|
|
|
|
|
|
final ApiProvider apiProvider;
|
|
|
|
|
|
|
|
|
|
|
|
static ApiRepository get to => Get.find<ApiRepository>();
|
|
|
|
|
|
ApiRepository(this.apiProvider);
|
|
|
|
|
|
|
2023-08-07 10:32:24 +08:00
|
|
|
|
// 发送验证码 1注册,2找回密码,3绑定手机号,4解绑(换绑),5删除账号
|
2023-08-02 09:22:39 +08:00
|
|
|
|
Future<SendValidationCodeEntity> sendValidationCode(
|
|
|
|
|
|
String countryCode,
|
|
|
|
|
|
String account,
|
|
|
|
|
|
String channel,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String codeType,
|
2023-08-02 09:22:39 +08:00
|
|
|
|
String uniqueid,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String xWidth) async {
|
|
|
|
|
|
final res = await apiProvider.getVerificationCode(
|
|
|
|
|
|
countryCode, account, channel, codeType, uniqueid, xWidth);
|
2023-08-02 09:22:39 +08:00
|
|
|
|
return SendValidationCodeEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 注册
|
|
|
|
|
|
Future<LoginEntity> register(
|
|
|
|
|
|
String countryCode,
|
|
|
|
|
|
String countryId,
|
|
|
|
|
|
String mobile,
|
|
|
|
|
|
String password,
|
|
|
|
|
|
String uniqueid,
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String verificationCode) async {
|
|
|
|
|
|
final res = await apiProvider.register(
|
|
|
|
|
|
countryCode, countryId, mobile, password, uniqueid, verificationCode);
|
2023-07-29 09:25:21 +08:00
|
|
|
|
return LoginEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-02 09:22:39 +08:00
|
|
|
|
// 获取图片验证码
|
|
|
|
|
|
Future<SafetyVerificationEntity> getSliderVerifyImg(
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String countryCode, String account) async {
|
2023-07-29 18:33:48 +08:00
|
|
|
|
final res = await apiProvider.getSliderVerifyImg(countryCode, account);
|
|
|
|
|
|
return SafetyVerificationEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-02 09:22:39 +08:00
|
|
|
|
// 检验图片验证码
|
|
|
|
|
|
Future<CheckSafetyVerificationEntity> checkSliderVerifyImg(
|
2023-08-07 10:32:24 +08:00
|
|
|
|
String countryCode, String account, String xWidth) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.checkSliderVerifyImg(countryCode, account, xWidth);
|
2023-07-29 18:33:48 +08:00
|
|
|
|
return CheckSafetyVerificationEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-16 17:35:43 +08:00
|
|
|
|
//登录
|
2023-08-07 10:32:24 +08:00
|
|
|
|
Future<LoginEntity> login(String loginType, String password,
|
|
|
|
|
|
String countryCode, String username) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.login(loginType, password, countryCode, username);
|
2023-08-02 09:22:39 +08:00
|
|
|
|
return LoginEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-07-27 15:29:37 +08:00
|
|
|
|
|
2023-08-07 10:32:24 +08:00
|
|
|
|
//重置密码
|
|
|
|
|
|
Future<LoginEntity> resetPassword(
|
|
|
|
|
|
String countryCode,
|
|
|
|
|
|
String account,
|
|
|
|
|
|
String date,
|
|
|
|
|
|
String newPassword,
|
|
|
|
|
|
String uniqueid,
|
|
|
|
|
|
String verificationCode) async {
|
|
|
|
|
|
final res = await apiProvider.resetPassword(
|
|
|
|
|
|
countryCode, account, date, newPassword, uniqueid, verificationCode);
|
|
|
|
|
|
return LoginEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-08-16 17:35:43 +08:00
|
|
|
|
|
|
|
|
|
|
//获取国家或地区 json文件
|
2023-08-23 14:27:50 +08:00
|
|
|
|
Future<CountryRegionEntity> getCountryRegion(String type) async {
|
2023-08-16 17:35:43 +08:00
|
|
|
|
final res = await apiProvider.getCountryRegion(type);
|
2023-08-23 14:27:50 +08:00
|
|
|
|
return CountryRegionEntity.fromJson(res.body);
|
2023-08-16 17:35:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//电子钥匙列表
|
|
|
|
|
|
Future<ElectronicKeyListEntity> electronicKeyList(
|
|
|
|
|
|
String endDate,
|
|
|
|
|
|
String keyId,
|
|
|
|
|
|
String keyStatus,
|
|
|
|
|
|
String lockId,
|
|
|
|
|
|
String operatorUid,
|
|
|
|
|
|
String pageNo,
|
|
|
|
|
|
String pageSize,
|
2023-08-23 14:27:50 +08:00
|
|
|
|
String startDate,
|
|
|
|
|
|
String keyRight) async {
|
2023-08-16 17:35:43 +08:00
|
|
|
|
final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus,
|
2023-08-23 14:27:50 +08:00
|
|
|
|
lockId, operatorUid, pageNo, pageSize, startDate, keyRight);
|
2023-08-16 17:35:43 +08:00
|
|
|
|
return ElectronicKeyListEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//发送电子钥匙
|
|
|
|
|
|
Future<ElectronicKeyListEntity> 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,
|
2023-08-17 18:54:19 +08:00
|
|
|
|
List weekDays) async {
|
2023-08-16 17:35:43 +08:00
|
|
|
|
final res = await apiProvider.sendElectronicKey(
|
|
|
|
|
|
createUser,
|
|
|
|
|
|
countryCode,
|
|
|
|
|
|
usernameType,
|
|
|
|
|
|
endDate,
|
|
|
|
|
|
faceAuthentication,
|
|
|
|
|
|
isCameraEnable,
|
|
|
|
|
|
isRemoteUnlock,
|
|
|
|
|
|
keyNameForAdmin,
|
|
|
|
|
|
keyRight,
|
|
|
|
|
|
keyType,
|
|
|
|
|
|
lockId,
|
|
|
|
|
|
operatorUid,
|
|
|
|
|
|
receiverUsername,
|
|
|
|
|
|
remarks,
|
|
|
|
|
|
startDate,
|
|
|
|
|
|
weekDays);
|
|
|
|
|
|
return ElectronicKeyListEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-08-17 18:54:19 +08:00
|
|
|
|
|
|
|
|
|
|
//重置电子钥匙
|
|
|
|
|
|
Future<ElectronicKeyListEntity> resetElectronicKey(
|
|
|
|
|
|
String lockId, String operatorUid) async {
|
|
|
|
|
|
final res = await apiProvider.resetElectronicKey(lockId, operatorUid);
|
|
|
|
|
|
return ElectronicKeyListEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//钥匙详情-操作记录
|
|
|
|
|
|
Future<KeyOperationRecordEntity> lockRecordList(
|
|
|
|
|
|
String endDate,
|
|
|
|
|
|
String keyId,
|
|
|
|
|
|
String keyStatus,
|
|
|
|
|
|
String lockId,
|
|
|
|
|
|
String operatorUid,
|
|
|
|
|
|
String pageNo,
|
|
|
|
|
|
String pageSize,
|
|
|
|
|
|
String startDate,
|
|
|
|
|
|
String recordType,
|
|
|
|
|
|
String searchStr,
|
|
|
|
|
|
String timezoneRawOffSet) async {
|
|
|
|
|
|
final res = await apiProvider.lockRecordList(
|
|
|
|
|
|
endDate,
|
|
|
|
|
|
keyId,
|
|
|
|
|
|
keyStatus,
|
|
|
|
|
|
lockId,
|
|
|
|
|
|
operatorUid,
|
|
|
|
|
|
pageNo,
|
|
|
|
|
|
pageSize,
|
|
|
|
|
|
startDate,
|
|
|
|
|
|
recordType,
|
|
|
|
|
|
searchStr,
|
|
|
|
|
|
timezoneRawOffSet);
|
|
|
|
|
|
return KeyOperationRecordEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-08-18 18:25:58 +08:00
|
|
|
|
|
|
|
|
|
|
//锁电量更新
|
|
|
|
|
|
Future<KeyOperationRecordEntity> uploadElectricQuantity(
|
|
|
|
|
|
String electricQuantity, String lockId) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.uploadElectricQuantity(electricQuantity, lockId);
|
|
|
|
|
|
return KeyOperationRecordEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//锁名称修改
|
|
|
|
|
|
Future<KeyOperationRecordEntity> modifyKeyName(
|
|
|
|
|
|
String keyId,
|
|
|
|
|
|
String lockId,
|
|
|
|
|
|
String keyName,
|
|
|
|
|
|
String operatorUid,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final res =
|
|
|
|
|
|
await apiProvider.modifyKeyName(keyId, lockId, keyName, operatorUid);
|
|
|
|
|
|
return KeyOperationRecordEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-08-23 14:27:50 +08:00
|
|
|
|
|
|
|
|
|
|
//编辑电子钥匙名字
|
|
|
|
|
|
Future<KeyOperationRecordEntity> modifyKeyNameForAdmin(
|
|
|
|
|
|
String keyId,
|
|
|
|
|
|
String keyNameForAdmin,
|
|
|
|
|
|
String operatorUid,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final res = await apiProvider.modifyKeyNameForAdmin(
|
|
|
|
|
|
keyId, keyNameForAdmin, operatorUid);
|
|
|
|
|
|
return KeyOperationRecordEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//编辑电子钥匙名字
|
|
|
|
|
|
Future<PasswordKeyListEntity> passwordKeyList(
|
|
|
|
|
|
String keyStatus,
|
|
|
|
|
|
String lockId,
|
|
|
|
|
|
String operatorUid,
|
|
|
|
|
|
String pageNo,
|
|
|
|
|
|
String pageSize,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final res = await apiProvider.passwordKeyList(
|
|
|
|
|
|
keyStatus, lockId, operatorUid, pageNo, pageSize);
|
|
|
|
|
|
return PasswordKeyListEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//重置密码钥匙
|
|
|
|
|
|
Future<PasswordKeyListEntity> resetPasswordKey(
|
|
|
|
|
|
String lockId, String operatorUid) async {
|
|
|
|
|
|
final res = await apiProvider.resetPasswordKey(lockId, operatorUid);
|
|
|
|
|
|
return PasswordKeyListEntity.fromJson(res.body);
|
|
|
|
|
|
}
|
2023-07-27 15:29:37 +08:00
|
|
|
|
}
|