import request from './request';
import Axios from 'axios';
import JSONbig from 'json-bigint';

//const URL = '/api/';
const URL =process.env.VUE_APP_BASE_URL || '/wisdom-water/';
//******************************用户接口************************************//
export const loginRequest = objData => {
    return Axios.post(URL + "sys/login", objData);
};
export const registerUserRequest = objData => {
    return Axios.post(URL + "user/register", objData);
};
export const editUserRequest = objData => {
    return Axios.post(URL + "user/edit", objData);
};

export const getAllUserRequest = objData => {
    return Axios.post(URL + "user/get", objData, {
        headers: {
            'content-type': 'application/json',
            'token': objData.token
        }
    });

};
export const resetUserRequest = objData => {

    return Axios.post(URL + "/user/reset", objData, {
        headers: {
            'content-type': 'application/json',
            'token': objData.token
        }
    });
};


//******************************end****************************************//


//******************************公用接口************************************//

//根据场站编号，风机型号获取AI测点
export const fetchAIPointList = (stationId, modelId) => {
    return request({
        url: URL + 'info/testing_point_ai',
        method: 'get',
        params: {
            stationId: stationId,
            modelId: modelId
        }
    });
};
//根据场站编号，风机型号获取DI测点
export const fetchDIPointList = (stationId, modelId) => {
    return request({
        url: URL + 'info/testing_point_di',
        method: 'get',
        params: {
            stationId: stationId,
            modelId: modelId
        }
    });
};
//根据场站编号，获取电气DI测点
export const fetchElectricDIPointList = (stationId) => {
    return request({
        url: URL + 'info/electrical_point_di',
        method: 'get',
        params: {
            stationId: stationId
        }
    });
};
//根据电气测点，获取测点信息
export const fetchElectricDIPointByPointId = (pointId) => {
    return request({
        url: URL + 'info/electrical_point_di/byId',
        method: 'get',
        params: {
            pointId: pointId
        }
    });
};


//******************************end****************************************//


//******************************自定义报警API************************************//
export const alert_rule_fetchTableData = query => {
    let data =
        request({
            url: URL + 'rule/list',
            method: 'get',
            params: query,
            headers: {
                'content-type': 'application/json',
                'token': localStorage.getItem('token')
            },
            timeout: 3000,
        });
    return data;
};


export const alert_rule_postSave = form => {
    return Axios.post(URL + "alertrule2/save", form, {
        headers: {
            'content-type': 'application/json',
            'token': sessionStorage.getItem('token')
        }
    })
};


//******************************end*******************************************//
