import { TAffiliatedunitModel, TAffiliatedunitQueryParam } from '@/types'
import request from '@/until/request'

/**
 * 获取单位列表
 * @param data TAffiliatedunitQueryParam
 */
const QueryTAffiliatedunitList = (data: TAffiliatedunitQueryParam) =>
    request({
        url: '/TAffiliatedunitAction/list',
        method: 'post',
        data: data
    })

/**
* 新增单位
* @param data TAffiliatedunitModel
*/
const AddTAffiliatedunit = (data: TAffiliatedunitModel) =>
    request({
        url: '/TAffiliatedunitAction/saveTAffiliatedunit',
        method: 'post',
        data: data
    })

/**
* 编辑单位
* @param data TAffiliatedunitModel
*/
const EditTAffiliatedunit = (data: TAffiliatedunitModel) =>
    request({
        url: '/TAffiliatedunitAction/updateTAffiliatedunit',
        method: 'post',
        data: data
    })

/**
* 删除单位
* @param  id number
*/
const DeleteTAffiliatedunit = (id: number) =>
    request({
        url: '/TAffiliatedunitAction/deleteTAffiliatedunit/' + id,
        method: 'get',
    })

/**
* 根据站代码获取单位对象
* @param  unitCode string
*/
const FindTAffiliatedunit = (unitCode: string) =>
    request({
        url: '/TAffiliatedunitAction/findTAffiliatedunit/' + unitCode,
        method: 'get',
    })

/**
* 根据创建单位站代码获取可管理的单位列表(运维添加站点时使用)
* @param  unitCode string
*/
const FindAffiliatedunitByCreateUnitCode = (createUnitCode: string) =>
    request({
        url: '/TAffiliatedunitAction/findAffiliatedunitByCreateUnitCode/' + createUnitCode,
        method: 'get',
    })


export default {
    QueryTAffiliatedunitList,
    AddTAffiliatedunit,
    EditTAffiliatedunit,
    DeleteTAffiliatedunit,
    FindTAffiliatedunit,
    FindAffiliatedunitByCreateUnitCode
}