##判断是否包含排序号字段
#set( $hasSort = 0)
##循环编辑的字段进行判断
#foreach ($column in $editColumns)
#if($column.columnName == "sort")
#set( $hasSort = $hasSort + 1)
#break
#end
#end
import request from '@/utils/request'

// 查询${functionName}列表
export function list${BusinessName} (query) {
  return request({
    url: '/${moduleName}/${businessName}/list',
    method: 'get',
    params: query
  })
}

// 查询${functionName}详细
export function get${BusinessName} (${pkColumn.javaField}) {
  return request({
    url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
    method: 'get'
  })
}

// 新增${functionName}
export function add${BusinessName} (data) {
  return request({
    url: '/${moduleName}/${businessName}',
    method: 'post',
    data: data
  })
}

// 修改${functionName}
export function update${BusinessName} (data) {
  return request({
    url: '/${moduleName}/${businessName}',
    method: 'put',
    data: data
  })
}

#foreach($column in $columns)
#if($column.columnName == "status" && ${hasDisableEnable} == 'true')
// 状态修改
export function updateStatus (id, status) {
  const data = {
    id,
    status
  }
  return request({
    url: '/${moduleName}/${businessName}/updateStatus',
    method: 'put',
    data: data
  })
}

#break
#end
#end
// 删除${functionName}
export function del${BusinessName} (${pkColumn.javaField}) {
  return request({
    url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
    method: 'delete'
  })
}

#foreach($column in $columns)
#if($column.columnName == "sort")
// 查询最大编号
export function findMaxSort () {
  return request({
    url: '/${moduleName}/${businessName}/findMaxSort',
    method: 'get'
  })
}
#break
#end
#end
#foreach($column in $uniqueColumns)
#set($attrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
##循环标志为1和上面的排序号不存在，则预留空行
#if($velocityCount == 1 && $hasSort > 0)

#end
// 校验${column.columnComment}是否存在
export function check${attrName}Unique (id, ${column.javaField}) {
  if (id === undefined) {
    id = ''
  }
  return request({
    url: '/${moduleName}/${businessName}/check${attrName}Unique/' + ${column.javaField} + '/' + id,
    method: 'get'
  })
}
#if($foreach.hasNext)

#end
#end

// 导出${functionName}
export function export${BusinessName} (query) {
  return request({
    url: '/${moduleName}/${businessName}/export',
    method: 'get',
    params: query
  })
}

// 获取初始化数据
export function getInitData (dictTypes) {
  return request({
    url: '/${moduleName}/${businessName}/getInitData/' + dictTypes,
    method: 'get'
  })
}
