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')
    }
    var obj = {
        "datas": {
            "records": [
                {
                    "id": "32b28674-2f0e-4694-b75d-7532b5d4326e",
                    "message": "您申请的【组件资源上传】业务,未通过审核！",
                    "userid": "27AF004A-8BDN-885T-30FU-89DE3388762B",
                    "smslx": 1,
                    "createtime": "2023-11-27 16:18:18",
                    "bussid": "f78ddf0a-7d0b-4752-bd94-81fe65c7b10e",
                    "status": 0
                },
                {
                    "id": "c84d238a-3856-4f58-b65d-4ee083c8c936",
                    "message": "您有一个业务名称为【组件资源授权】的业务件未处理，请及时处理！",
                    "userid": "27AF004A-8BDN-885T-30FU-89DE3388762B",
                    "smslx": 0,
                    "createtime": "2023-10-23 17:15:42",
                    "bussid": "38aabe11-169a-492f-9a08-d21967bde86a",
                    "status": 0
                },
            ],
            "total": 142,
            "size": 1000000,
            "current": 1,
            "searchCount": true,
            "pages": 1
        },
        "resp_code": 0,
        "resp_msg": "获取成功"
    }
    return new Promise<void>((resolve, reject) => {
        resolve(obj);
    })
    // 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);
            })
    })
}