import { defHttp } from '/@/utils/http/axios';
import { session } from "/@/utils/Memory.js";

enum Api {
    GetSms = '/base-center/sms/getSms',
    EditSms = '/base-center/sms/updateSmsStatus'
}

/**
 * @description:查询当前用户消息
 * @param string keyStr:模糊查询关键字
 * @param number page:页数
 * @param number rows:行数
 */
export function getSmsByUserId(data) {
    let params = {
        keyStr: data.keyStr,
        page: data.page,
        rows: data.rows,
        userid:session.getItem('userId')
    }
    return new Promise<void>((resolve, reject) => {
        defHttp.post({ url: Api.GetSms, params })
            .then((r) => {
                resolve(r);
            }).
            catch((e) => {
                reject(e);
            })
    })
}

/**
 * @description:修改消息状态
 * @param string smid:消息的id
 */
export function editSmsById(data) {
    let params = {
        smid:data.smid
    }
    return new Promise<void>((resolve, reject) => {
        defHttp.post({ url: Api.EditSms, params })
            .then((r) => {
                resolve(r);
            }).
            catch((e) => {
                reject(e);
            })
    })
}