const data = [
  {
    id: 1,
    date: '2020/7/1',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 200,
    failCount: 25,
    totalCount: 225,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 2,
    date: '2020/7/2',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 210,
    failCount: 30,
    totalCount: 240,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 3,
    date: '2020/7/3',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 270,
    failCount: 30,
    totalCount: 300,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 4,
    date: '2020/7/4',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 200,
    failCount: 15,
    totalCount: 215,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 5,
    date: '2020/7/5',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 120,
    failCount: 9,
    totalCount: 129,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 6,
    date: '2020/7/6',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 310,
    failCount: 27,
    totalCount: 337,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  },
  {
    id: 7,
    date: '2020/7/7',
    pv: 250,
    timeConsuming: 0.005,
    bytes: 159,
    successCount: 330,
    failCount: 33,
    totalCount: 363,
    statusCode: {
      twoHundred: 150,
      threeHundred: 30,
      fourHundred: 10,
      fiveHundred: 5,
      other: 5
    }
  }
]
export default [
  // 获取数据集列表
  {
    url: '/cc/linque/getMonitorData',
    type: 'post',
    response: (req, res) => {
      const { startTime, endTime } = req.body
      const arr = []
      if (startTime === endTime) {
        const item = data.find(v => v.date === startTime)
        arr.push(item)
      } else {
        let startIndex = data.findIndex(v => v.date === startTime)
        let endIndex = data.findIndex(v => v.date === endTime)
        startIndex = startIndex === -1 ? 0 : startIndex
        endIndex = endIndex === -1 ? data.length : endIndex
        for (let i = 0; i < data.length; i++) {
          if (i >= startIndex && i <= endIndex) arr.push(data[i])
        }
      }
      return {
        code: 200,
        message: 'success',
        responseTime: 1593321093655,
        data: arr
      }
    }
  }
]
