OutsourceCompanyApi.js 1.99 KB
import {axiosInstance} from '@/Request/PublicAxiosInstance'
import {filterEmptyValueInObject} from "@/PublicUtil/PublicUtil"

class OutsourceCompanyApi {
    getOutsourceCompanyList() {
        return axiosInstance.request(
            {
                method: 'GET',
                url: '/accounts',
            }
        )
    }

    addOutsourceCompany(data) {
        return axiosInstance.request(
            {
                method: 'POST',
                url: '/accounts',
                data: filterEmptyValueInObject(
                    {
                        name: data.name,
                        managerId: data.managerId,
                        description: data.description,
                        createUser: localStorage.getItem('currentUserId'),
                    }
                )
            }
        )
    }

    editOutsourceCompany(id, data) {
        return axiosInstance.request(
            {
                method: 'POST',
                url: `/accounts/${id}`,
                data: data
            }
        )
    }

    deleteOutsourceCompany(id) {
        return axiosInstance.request(
            {
                method: 'DELETE',
                url: `/accounts/${id}`,
            }
        )
    }

    prohibitOutsourceCompany(id) {
        return axiosInstance.request(
            {
                method: 'POST',
                url: `/accounts/${id}`,
                data: {
                    status: 0
                }
            }
        )
    }

    resumeOutsourceCompany(id) {
        return axiosInstance.request(
            {
                method: 'POST',
                url: `/accounts/${id}`,
                data: {
                    status: 1
                }
            }
        )
    }

    getUserList() {
        return axiosInstance.request(
            {
                method: 'GET',
                url: `/users`,
            }
        )
    }
}

const outsourceCompanyApi = new OutsourceCompanyApi()

export default outsourceCompanyApi