import {
    request
} from '@/untils/AxiosUtils.js';
import {
    getStore
} from '@/untils/store.js'

function getHeader() {
    const platformId = getStore({
        name: 'platformId'
    })
    if (platformId) {
        return {
            'Platform-Id': platformId
        }
    } else {
        return {}
    }
}

/*首页 最新任务(10条)*/
export const newMission = () => {
    return request({
        url: '/api/jobslink-api/missions/front/mission/guestList',
        method: 'get',
        headers: getHeader()
    })
}


/*首页 推荐任务(10条)*/
export const recMission = () => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/interestedList',
        method: 'get',
        headers: getHeader()
    })
}

/*抢任务-推荐岗位*/
export const nearMission = (current, size, isAll) => {
    return request({
        url: '/api/jobslink-api/user/userWork/getPushListByUserId',
        method: 'get',
        params: {
            current,
            size,
            // lat,
            // lon,
            // distance,
            isAll
        },
        headers: getHeader()
    })
}

/*抢任务-推荐任务*/
export const recommendMission = (current, size, seaStr) => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/recommendList',
        method: 'get',
        params: {
            current,
            size,
            seaStr
        },
        headers: getHeader()
    })
}

/*抢任务-最新任务*/
export const newMissionAll = (current, size, seaStr, isAll) => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/getPushList',
        method: 'get',
        params: {
            current,
            size,
            seaStr,
            isAll
        },
        headers: getHeader()
    })
}
/*抢任务-个体户招工*/
export const nearMissionSearch = (params) => {
    return request({
        url: '/api/jobslink-api/user/userWork/searchList',
        method: 'get',
        params,
        headers: getHeader()
    })
}

/*抢任务-推荐任务*/
export const recommendMissionSearch = (params) => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/searchList',
        method: 'get',
        params,
        headers: getHeader()
    })
}

/*抢任务-推荐岗位*/
export const newMissionAllSearch = (params) => {
    return request({
        url: '/api/jobslink-api/user/userWork/searchList',
        method: 'get',
        params,
        headers: getHeader()
    })
}

/*提交抢任务*/
export const submit = (missionNo, type) => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/missionApply',
        method: 'post',
        params: {
            missionNo,
            type
        }
    })
}



/*我的任务*/
export const myMission = (current, size, status) => {
    return request({
        url: '/api/jobslink-api/missions/user/mission/getUserMissionList',
        method: 'get',
        params: {
            current,
            size,
            status
        }
    })
}

// 消息中心：推荐岗位和推荐任务
export const tuiJianMission = (ids, type) => {
    return request({
        url: '/api/jobslink-api/user/userWork/getListByIDs',
        method: 'get',
        params: {
            ids,
            type
        }
    })
}

// 推送政策
export const getNewsPolicyList = (ids) => {
    return request({
        url: '/api/jobslink-api/policy/userList',
        method: 'get',
        params: {
            ids
        }
    })
}

/*我的收藏*/
export const myCollection = (current, size, status) => {
    return request({
        url: '/api/jobslink-api/jkWorks/jkWorks/getCollectListByUserId',
        method: 'get',
        params: {
            current,
            size,
            status
        }
    })
}

/*浏览记录*/
export const myBrowing = (current, size, status) => {
    return request({
        url: '/api/jobslink-api/user/useraction/getListByUserId',
        method: 'get',
        params: {
            current,
            size,
            status
        }
    })
}

/*招工消息通知列表*/
export const recruitmentNewsList = (current, size, status) => {
    return request({
        url: '/api/jobslink-api/user/userrecruit/getCollectList',
        method: 'get',
        params: {
            current,
            size,
            status
        }
    })
}

/*任务详情*/
export const missionDetail = (missionNo) => {
    return request({
        url: '/api/jobslink-api/missions/front/mission/detail',
        method: 'get',
        params: {
            missionNo
        }
    })
}
export const missionDetailById = (workId) => {
    return request({
        url: '/api/jobslink-api/missions/front/mission/detailById',
        method: 'get',
        params: {
            workId
        }
    })
}
/*任务详情*/
export const recruit_missionDetail = (missionNo, type) => {
    return request({
        url: '/api/jobslink-api/user/userrecruit/getCollectUserList',
        method: 'get',
        params: {
            id: missionNo,
            type
        }
    })
}

/*岗位详情*/
// workDetail
export const workDetail = (workId) => {
    return request({
        url: '/api/jobslink-api/user/userWork/getWorksInfoByWorkId',
        method: 'get',
        params: {
            workId
        }
    })
}

/*获取收藏状态*/
export const getCollectState = (workId, type) => {
    return request({
        url: '/api/jobslink-api/jkWorks/jkWorks/getCollectStatus',
        method: 'get',
        params: {
            workId,
            type
        }
    })
}

/*收藏和取消收藏接口*/
export const updateCollectStatus = (workId, status, type) => {
    return request({
        url: '/api/jobslink-api/jkWorks/jkWorks/updateCollectStatus',
        method: 'get',
        params: {
            workId,
            status,
            type
        }
    })
}


/*获取查询关键字列表*/
export const getSearchKeyWordsList = () => {
    return request({
        url: '/api/jobslink-api/user/userWork/getSearchAllKeyWords',
        method: 'get',
    })
}
/*清空搜索历史*/
export const clearSearchKeyWords = () => {
    return request({
        url: '/api/jobslink-api/user/userWork/delSearchAllKeyWords',
        method: 'get',
    })
}
/*通过关键字获取面板搜索结果*/
export const getListByKeyWords = (keywords) => {
    return request({
        url: '/api/jobslink-api/user/userWork/searchAll',
        method: 'get',
        params: {
            keywords
        }
    })
}

export const getMyInviteUserList = (params) => {
    return request({
        url: '/api/jobslink-api/user/userrecruit/getMyInviteUserList',
        method: 'get',
        params
    })
}
export const getPolicyContentList = (params) => request({
    url: '/api/jobslink-api/desk/article/getAllArticle',
    method: 'get',
    params
})

export const userWorkSearchListAll = (params) => request({
    url: '/api/jobslink-api/user/userWork/searchListAll',
    method: 'get',
    params
})