import request from '@/utils/request'

// 查询项目列表
export function listProject(query) {
  return request({
    url: '/generator/project/list',
    method: 'get',
    params: query
  })
}

// 查询项目详细
export function getProject(projectId) {
  return request({
    url: '/generator/project/' + projectId,
    method: 'get'
  })
}

// 获取项目结构
export function getProjectStructure(projectId, type) {
  return request({
    url: '/generator/project/structure/' + projectId + '/' + type,
    method: 'get'
  })
}

// 预览生成代码
export function previewTableNew(projectId, tableId, keyword, type ) {
  return request({
    url: '/generator/project/preview/' + projectId + '/' + tableId + '/' + keyword + '/' + type,
    method: 'get'
  })
}

// 新增项目
export function addProject(data) {
  return request({
    url: '/generator/project',
    method: 'post',
    data: data
  })
}

// 修改项目
export function updateProject(data) {
  return request({
    url: '/generator/project',
    method: 'put',
    data: data
  })
}

// 删除项目
export function delProject(projectId) {
  return request({
    url: '/generator/project/' + projectId,
    method: 'delete'
  })
}

// 导出项目
export function exportProject(query) {
  return request({
    url: '/generator/project/export',
    method: 'post',
    params: query
  })
}

// 查询项目关联的功能模块列表
export function listProjectModules(projectId, query) {
  return request({
    url: '/generator/project/module/list',
    method: 'get',
    params: { ...query, projectId }
  })
}

// 新增项目与功能模块关系
export function addProjectModule(data) {
  return request({
    url: '/generator/project/module/',
    method: 'post',
    data: data
  })
}

// 删除项目与功能模块关系
export function delProjectModule(ids) {
  return request({
    url: '/generator/project/module/' + ids,
    method: 'delete'
  })
}

// 查询项目关联的功能模块列表
export function listProjectTables(projectId, query) {
  return request({
    url: '/generator/project/table/list',
    method: 'get',
    params: { ...query, projectId }
  })
}

// 新增项目与功能模块关系
export function addProjectTable(data) {
  return request({
    url: '/generator/project/table',
    method: 'post',
    data: data
  })
}

// 删除项目与功能模块关系
export function delProjectTable(ids) {
  return request({
    url: '/generator/project/table/' + ids,
    method: 'delete'
  })
}

// 查询项目关联的功能模块列表
export function listProjectTemplates(projectId, query) {
  return request({
    url: '/generator/project/template/list',
    method: 'get',
    params: { ...query, projectId }
  })
}

// 新增项目与功能模块关系
export function addProjectTemplate(data) {
  return request({
    url: '/generator/project/template',
    method: 'post',
    data: data
  })
}

// 删除项目与功能模块关系
export function delProjectTemplate(ids) {
  return request({
    url: '/generator/project/template/' + ids,
    method: 'delete'
  })
}

// 根据项目ID查询项目模板配置列表
export function listProjectTemplatesByProjectId(projectId) {
  return request({
    url: '/generator/project/template/list/' + projectId,
    method: 'get'
  })
}

// 根据项目ID删除项目模板配置
export function delProjectTemplateByProjectId(projectId) {
  return request({
    url: '/generator/project/template/del/' + projectId,
    method: 'delete'
  })
}
