| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import 'package:chicken_farm/core/api/api_service.dart';
- import 'package:chicken_farm/modes/api/result_model.dart';
- import 'package:chicken_farm/modes/device/inspection_rule/checkin_log.dart';
- import 'package:chicken_farm/modes/device/inspection_rule/inspection_rule.dart';
- class InspectionRuleApi {
- static final InspectionRuleApi _instance = InspectionRuleApi._internal();
- factory InspectionRuleApi() => _instance;
- InspectionRuleApi._internal();
- Future<InspectionRuleModel?> queryRule(String id) async {
- final result = await ApiService().get('/device/inspectionRule/$id');
- if (result.success && result.data != null) {
- return InspectionRuleModel.fromJson(result.data);
- } else {
- return null;
- }
- }
- Future<List<CheckinLogModel>> queryCheckinList(String id) async {
- final result = await ApiService().get(
- '/device/inspectionRule/queryCheckinList/$id',
- );
- if (result.success && result.data != null) {
- return result.data
- .map<CheckinLogModel>((e) => CheckinLogModel.fromJson(e))
- .toList();
- } else {
- return [];
- }
- }
- Future<ResultModel> checkIn(String id) async {
- return await ApiService().post('/device/inspectionRule/checkIn/$id');
- }
- Future<ResultModel> checkInWithPhoto(String id, dynamic data) async {
- return await ApiService().post(
- '/device/inspectionRule/checkInWithPhoto/$id',
- data: data,
- );
- }
- }
|