// 产品商品类API
import service from '@/service'

export const searchProduct = (code) => {
    return service({
        method: 'post',
        url: '/product/searchproductbycode/' + code
    })
}

export const partsGoodsById = (id) => {
    return service({
        method: 'get',
        url: '/product/goodsById',
        params: {
            id
        }
    })
}

export const hasProduct = (brand,code) => {
    return service({
        method: 'post',
        url: '/product/hasproduct',
        data: {
            code,
            brand
        }
    })
}

export const hasFocusBatch = (data) => {
    return service({
        method: 'post',
        url: '/store/hasfocusbatch',
        data
    })
}

export const hasBrandProduct = (brand,code) => {
    return service({
        method: 'post',
        url: '/product/hasbrandproduct',
        data: {
            code: code,
            brand: brand
        }
    })
}

export const partsGoodsByCode = (code,brand=0) => {
    return service({
        method: 'get',
        url: '/product/goodsByCode',
        params: {
            code,
            brand
        }
    })
}

export const onlyGoodsByCode = (code,brand=0) => {
    return service({
        method: 'get',
        url: '/product/onlyGoodsByCode?code=' + code + (brand ? '&brand=' + brand : ''),
    })
}

export const productInfo = (id) => {
    return service({
        method: 'post',
        url: '/product/product?id=' + id
    })
}

export const hasFocus = (brand,code) => {
    return service({
        method: 'get',
        url: `/store/hasfocus?brand=${brand}&code=${code}`,
    })
}

export const focusItem = (id) => {
    return service({
        method: 'get',
        url: '/store/focus_item/' + id,
    })
}

export const updateFocus = (data) => {
    return service({
        method: 'post',
        url: '/store/updatefocus',
        data
    })
}

export const addFocusLog = (id,user_id,note) => {
    return service({
        method: 'post',
        url: '/store/addfocuslog?id=' + id,
        data: {
            note,
            operator: user_id,
        }
    })
}
