import { request } from '@/utils/request'


export interface Section{
    id?: number,
    sectionCode?: string,
    sectionName?: string,
    workshopId?: number,

    createTime?:string,
    updateTime?:string,
    status?:number,
    remark?:string
}


export const sectionApi = {

    page(params:{
        page:number,
        pageSize:number,
        sectionName:any,
        sectionCode:any
    }){
        return request({
            url:"biz/section/page",
            method:"get",
            params
        })
    },

    create(data:Section){
        return request({
            url:"biz/section/add",
            method:"post",
            data
        })
    },
    update(data:Section) {
        return request({
            url:"biz/section/update",
            method:"put",
            data
        })
    },

    delete(ids:any) {
        return request({
            url:`/biz/section/${ids.join(",")}`,
            method:"delete"            
        })
    },

    export(params?:{
        ids?: string[],
        sectionCode:any,
        sectionName:any
    }) {
        const p:Record<string,any> = {}
        if(params?.ids?.length) p.ids = params.ids.join(',')
        if(params?.sectionCode != undefined && params?.sectionCode !== null) p.sectionCode = params.sectionCode
        if(params?.sectionName != undefined && params?.sectionName !== null) p.sectionName = params.sectionName    
        return request({
            url:`/biz/section/export`,
            method:"get",
            params:p,
            responseType:'blob'
        })    
    },

    list(params:{sectionName:string}) {
        return request({
            url:"/biz/section/listBySectionName",
            method:"get",
            params
        })
    },
    listNoParam(){
        return request({
            url:"/biz/section/list",
            method:"get"
        })
    }

}