// 查询巡检记录返回数据
import 'package:dio/dio.dart';

class InspectionData {
  int size;
  List datas;
  InspectionData.fromJson(Map<String, dynamic> json)
      : size = json['total'],
        datas = json['rows'];
}

// 查询事件记录返回数据
class TaskData {
  int size;
  List datas;
  TaskData.fromJson(Map<String, dynamic> json)
      : size = json['total'],
        datas = json['rows'];
}

// 获取巡检记录的请求
class InspectionListReq {
  String startTime;
  String endTime;
  String keywords;
  int offset;
  int limit;

  InspectionListReq(
      this.startTime, this.endTime, this.keywords, this.offset, this.limit);

  InspectionListReq.fromJson(Map<String, dynamic> json)
      : startTime = json['startTime'],
        endTime = json['endTime'],
        keywords = json['keywords'],
        offset = json['offset'],
        limit = json['limit'];

  Map<String, dynamic> toJson() => {
        'startTime': startTime == '' ? startTime : startTime + ' 00:00:00',
        'endTime': endTime == '' ? endTime : endTime + ' 23:59:59',
        'keywords': keywords,
        'offset': offset,
        'limit': limit
      };

  FormData toFormData() {
    return FormData.from(toJson());
  }

  @override
  String toString() {
    return '{' +
        " \"startTime\":\"" +
        startTime +
        "\"," +
        " \"endTime\":\"" +
        endTime +
        "\"" +
        " \"keywords\":\"" +
        keywords +
        "\"" +
        " \"offset\":\"" +
        offset.toString() +
        "\"" +
        " \"limit\":\"" +
        limit.toString() +
        "\"" +
        '}';
  }
}

// 获取事件记录的请求
class TaskListReq {
  String startTime;
  String endTime;
  String keywords;
  int offset;
  int limit;

  TaskListReq(
      this.startTime, this.endTime, this.keywords, this.offset, this.limit);

  TaskListReq.fromJson(Map<String, dynamic> json)
      : startTime = json['startTime'],
        endTime = json['endTime'],
        keywords = json['keywords'],
        offset = json['offset'],
        limit = json['limit'];

  Map<String, dynamic> toJson() => {
        'startTime': startTime == '' ? startTime : startTime + ' 00:00:00',
        'endTime': endTime == '' ? endTime : endTime + ' 23:59:59',
        'keywords': keywords,
        'offset': offset,
        'limit': limit
      };

  FormData toFormData() {
    return FormData.from(toJson());
  }

  @override
  String toString() {
    return '{' +
        " \"startTime\":\"" +
        startTime +
        "\"," +
        " \"endTime\":\"" +
        endTime +
        "\"" +
        " \"keywords\":\"" +
        keywords +
        "\"" +
        " \"offset\":\"" +
        offset.toString() +
        "\"" +
        " \"limit\":\"" +
        limit.toString() +
        "\"" +
        '}';
  }
}

class ArticleListReq {
  final int offset;
  final int limit;
  final String order;
  final String sort;

  ArticleListReq(this.offset, this.limit, {this.order, this.sort});

  ArticleListReq.fromJson(Map<String, dynamic> json)
      : offset = json['offset'],
        limit = json['limit'],
        order = json['order'],
        sort = json['sort'];

  Map<String, dynamic> toJson() => {
        'offset': offset,
      };
  FormData toFormData() {
    return FormData.from(toJson());
  }
}

class ArticleListResp<T> {
  int size;
  List<T> datas;
  ArticleListResp.fromJson(Map<String, dynamic> json)
      : size = json['total'],
        datas = json['rows'];
}
