import apiRequest from '@/network/http/apiRequest'

/**
 * 获取Entity分页
 * @param data
 * @returns
 */
export function getEntityByPage(data: any) {
  return apiRequest({
    url: '/model/entity/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 获取Entity列表
 * @param data
 * @returns
 */
export function getEntityByList(data: any) {
  return apiRequest({
    url: '/model/entity',
    method: 'GET',
    params: data,
  })
}

/**
 * 根据Id获取Entity
 * @param modelId
 * @param entityId
 * @returns
 */
export function getEntityById(modelId: number, entityId: number) {
  return apiRequest({
    url: `/model/entity/${modelId}/${entityId}`,
    method: 'GET',
  })
}

/**
 * 添加Entity
 * @param data
 * @returns
 */
export function createEntity(data: any) {
  return apiRequest({
    url: '/model/entity/add',
    method: 'POST',
    data,
  })
}

/**
 * 更新Entity
 * @param data
 * @returns
 */
export function updateEntity(data: any) {
  return apiRequest({
    url: '/model/entity/update',
    method: 'PUT',
    data,
  })
}

/**
 * 更新Entity
 * @param modelId
 * @param entityId
 * @param status
 * @returns
 */
export function updateEntityStatus(modelId: number, entityId: number, status: number) {
  return apiRequest({
    url: `/model/entity/updateStatus/${modelId}/${entityId}/${status}`,
    method: 'PUT',
  })
}

/**
 * 删除Entity
 * @param modelId
 * @param entityId
 * @returns
 */
export function deleteEntityById(modelId: number, entityId: number) {
  return apiRequest({
    url: `/model/entity/${modelId}/${entityId}`,
    method: 'DELETE',
  })
}
