import { CustomeGroupQueryModel, CustomizeGroupModel, CustomizeGroupQueryParam } from '@/types'
import request from '@/until/request'

/**
 * 获取自定义分组列表
 * @param data CustomizeGroupQueryParam
 */
const QueryCustomizeGroupList = (data: CustomizeGroupQueryParam) =>
    request({
        url: '/CustomizeGroupAction/list',
        method: 'post',
        data: data
    })

/**
* 新增自定义分组
* @param data CustomizeGroupModel
*/
const AddCustomizeGroup = (data: CustomizeGroupModel) =>
    request({
        url: '/CustomizeGroupAction/saveCustomizeGroup',
        method: 'post',
        data: data
    })

/**
* 编辑自定义分组
* @param data CustomizeGroupModel
*/
const EditCustomizeGroup = (data: CustomizeGroupModel) =>
    request({
        url: '/CustomizeGroupAction/updateCustomizeGroup',
        method: 'post',
        data: data
    })

/**
* 删除自定义分组
* @param  id number
*/
const DeleteCustomizeGroup = (id: number) =>
    request({
        url: '/CustomizeGroupAction/deleteCustomizeGroup/' + id,
        method: 'get',
    })

/**
 * 获取自定义分组树
 * @param unitCode 
 * @param userId 
 * @returns 
 */
const FindCustomizeGroupTree = (data: CustomizeGroupModel) =>
    request({
        url: '/CustomizeGroupAction/findCustomizeGroupTree',
        method: 'post',
        data: data
    })

const DeleteStationByGroupId = (groupId: string, stationCode: string, userId: string) =>
    request({
        url: '/CustomizeGroupAction/deleteStationByGroupId/' + groupId + "/" + stationCode + "/" + userId,
        method: 'get'
    })

/**
 * 根据CustomeGroupQueryModel对象更新分组
 * @param data CustomizeGroupQueryParam
 */
const updateCustomizeGroupByCustomeGroupQueryModel = (data: CustomeGroupQueryModel) =>
request({
    url: '/CustomizeGroupAction/updateCustomizeGroupByCustomeGroupQueryModel',
    method: 'post',
    data: data
})

export default {
    QueryCustomizeGroupList,
    AddCustomizeGroup,
    EditCustomizeGroup,
    DeleteCustomizeGroup,
    FindCustomizeGroupTree,
    DeleteStationByGroupId,
    updateCustomizeGroupByCustomeGroupQueryModel
}