import Mock, { Random } from 'mockjs'

enum Type {
  Video = 'video',
  Image = 'image'
}

interface Resource {
  type: Type,
  href: string
}

interface Records {
  name: string,
  time: string,
  content: string,
  resource?: Array<Resource>
}

const length = Mock.mock({
  'number|1-10': 1
}).number

const records: Array<Records> = []

for (let i = 0; i <= length; i++) {
  const obj: Records = {
    name: Mock.mock('@cname'),
    content: Mock.mock('@cparagraph(1, 4)'),
    time: Mock.mock('@datetime("yyyy-MM-dd HH:mm:ss")')
  }
  const resource = Mock.mock({
    'array|1-10': [
      {
        'type': 'image',
        'href': Random.image('300x300', Mock.mock('@color'), '#FFF', 'png', 'image')
      }
    ]
  }).array
  obj.resource = resource.length > 4 ? resource : []
  records.push(obj)
}

export {
  Records,
  Resource,
  records
}

