import request from '@/utils/request'

/** 查询消息组列表 */
export function getUserKeyList(params) {
    return request({
      url: '/erp/msgGroup/list',
      method: 'GET',
      params
    })
}

/** 新增消息组 */
export function addUserKey(data) {
    return request({
        url: '/erp/msgGroup',
        method: 'POST',
        data
    })
}

/** 修改消息组 */
export function editUserKey(data) {
    let { id, ...parms } = data
    return request({
        url: `/erp/msgGroup/${id}`,
        method: 'PUT',
        data: parms
    })
}
/** 删除消息组 */
export function delUserKey(id) {
    return request({
        url: `/erp/msgGroup/${id}`,
        method: 'DELETE'
    })
}

/** 发送消息 */
export function sendMassage(id, message) {
    return request({
        url: `/erp/msgGroup/sendMsg/${id}`,
        method: 'POST',
        data: message
    })
}

/** 查看日志 */
export function lookLog(params) {
    return request({
        url: `/erp/msgGroup/sendLog`,
        method: 'GET',
        params
    })
}

/** 根据key的id获取到对应的人员信息列表 */
export function getBindUser(keyId) {
    return request({
        url: `/erp/sysUserkey/getBindUser/${keyId}`,
        method: 'GET'
    })
}

/** 绑定人员和key */
export function setBindUser(data) {
    let {keyId, userIds} = data
    return request({
        url: `/erp/sysUserkey/bindUserKey/${keyId}`,
        method: 'post',
        data: userIds
    })
}