import request from './request'

export const authAPI = {
  login(data) {
    return request.post('/auth/login', data)
  },
  register(data) {
    return request.post('/auth/register', data)
  }
}

export const bookAPI = {
  list(params = {}) {
    return request.get('/books', { params })
  },
  get(id) {
    return request.get(`/books/${id}`)
  },
  create(data) {
    return request.post('/books', data)
  },
  update(id, data) {
    return request.put(`/books/${id}`, data)
  },
  delete(id) {
    return request.delete(`/books/${id}`)
  }
}

export const readingAPI = {
  saveRecord(data) {
    return request.post('/reading/record', data)
  },
  getHistory() {
    return request.get('/reading/history')
  }
}
