import request from "../request";
import { praseStrEmpty } from "@/util/util";

// 查询我的工具列表
export function listMyTools() {
  return request({
    url: '/my/tools',
    method: 'get'
  })
}

// 查询我的某工具
export function getMyTool(toolId) {
  return request({
    url: '/my/tool/'+ toolId,
    method: 'get'
  })
}


// 查询我的测试任务列表
export function listMyTasks(queryParam) {
  return request({
    url: '/my/task/list',
    method: 'get',
    params:queryParam
  })
}

//查询价格列表
export function getPrice(toolId) {
  return request({
    url: '/business/tool/price/' + praseStrEmpty(toolId),
    method: 'get'
  })
}
//查询功能列表
export function getFunction(toolId) {
  return request({
    url: '/business/tool/function/' + praseStrEmpty(toolId),
    method: 'get'
  })
}
//加入购物车
export function addShoppingCart(toolId, amount) {
  let count = 1;
  if (amount)
      count = amount;
  return request({
    url: '/my/addShoppingCart/' + praseStrEmpty(toolId) + '/' + count,
    method: 'get'
  })
}
//查询我的购物车列表
export function getMyShoppingCart() {
  return request({
    url: '/my/shoppingCart',
    method: 'get'
  })
}
//从购物车移除某款工具
export function removeShoppingCart(toolId) {
  return request({
    url: '/my/shoppingCart/' + toolId,
    method: 'delete'
  })
}
//批量移除
export function multipleRemove(toolIds) {
  return request({
    url: '/my/multipleRemove/',
    data: {toolIds: toolIds.join(",")},
    method: 'delete'
  })
}
//清空购物车
export function clearCart() {
  return request({
    url: '/my/clearCart',
    method: 'delete'
  })
}
//我的订单列表
export function getMyOrder(param) {
  return request({
    url: '/my/order',
    method: 'get',
    params:param
  })
}
//我的本周测试任务
export function getMyWeekTask(param) {
  return request({
    url: '/my/week/task',
    method: 'get',
    params:param
  })
}

// 根据机器码获取注册码
export function getCodeByCode(param) {
  return request({
    url: '/license/generLicense',
    method: 'post',
    data: param
  })
}


