import request from '@/config/axios'

export interface ConfigVO {
  sysAttrId?: number
  sysAttrName: string
  sysAttrKey: string
  sysAttrType?: string
  sysAttrValue: string
  remark?: string
  createTime?: Date
}

export interface PageParam {
  current: number
  size: number
  sysAttrName?: string
  sysAttrValue?: string
  sysAttrKey?: string
}

// 查询基础数据-全局配置列表
export const getIsSystemAttributePage = async (params: PageParam) => {
  return await request.get({ url: '/iscs/attribute/getAttributePage', params })
}

// 查询基础数据-全局配置详细
export const selectIsSystemAttributeById = async (id: number) => {
  return await request.get({ url: '/iscs/attribute/selectAttributeById', params: { id } })
}

// 新增基础数据-全局配置
export const insertIsSystemAttribute = async (data: ConfigVO) => {
  return await request.post({ url: '/iscs/attribute/insertAttribute', data })
}

// 修改基础数据-全局配置
export const updateIsSystemAttribute = async (data: ConfigVO) => {
  return await request.put({ url: '/iscs/attribute/updateAttribute', data })
}

// 删除基础数据-全局配置
export const deleteIsSystemAttributeByIds = async (id: number) => {
  return await request.delete({
    url: '/iscs/attribute/deleteAttributeList',
    params: { ids: id }
  })
}

// 根据键名查询配置
export const getIsSystemAttributeByKey = async (sysAttrKey: string) => {
  return await request.get({
    url: '/iscs/attribute/getSystemAttributeByKey',
    params: { sysAttrKey }
  })
}

// 刷新缓存
export const refreshAttrCache = async () => {
  return await request.get({ url: '/iscs/attribute/refreshAttrCache' })
}
