Commit c8146d7f authored by 崔佳豪's avatar 崔佳豪

fix: GetUserInfo/GetEmqtConfig接口升级

parent 20cde650
Pipeline #59091 passed with stages
......@@ -19,8 +19,7 @@ export const API = {
GENERATE_TOKEN_CHANGE: '/cityinterface/rest/services.svc/generatetokenquick',
GET_WEB_SITE_CONFIG: '/PandaOMS/OMS/WebSite/GetWebSiteConfig',
// GET_WEB_SITE_CONFIG: '/CityInterface/rest/services.svc/GetWebSiteConfig',
GET_USER_INFO: '/CityInterface/rest/services.svc/getUserInfo',
GET_GATEWAY_USER_INFO: '/PandaCore/GCK/Basis/GetUserInfo',
GET_USER_INFO: 'PandaCore/GCK/Basis/GetUserInfo',
GET_OA: '/CityInterface/rest/services/OA.svc/getLoginInfo',
GET_LOGS: '/CityInterface/rest/services/portal.svc/OMMonitor/SaveLoginInfo',
GET_CITY:
......@@ -36,7 +35,6 @@ export const API = {
IOT_CHANGE_PASSWORD:
'CityInterface/rest/services/OMS.svc/U_UpdatePasswordQuickGCK',
FILE_DOWNLOAD: '/cityinterface/rest/services/filedownload.svc/download',
GET_VERSION: '/CityInterface/rest/services/OMs.svc/U_GetVersion',
UPDATE_AVATAR: '/CityInterface/rest/services/OMs.svc/U_EditUser',
UPLOAD_FILE_URL:
'/cityinterface/rest/services/filedownload.svc/uploadfile/个人信息/{path}/{filename}',
......@@ -90,10 +88,7 @@ const services = {
},
getUserInfo: {
url: () =>
window.globalConfig && window.globalConfig.hasGateWay
? API.GET_GATEWAY_USER_INFO
: API.GET_USER_INFO,
url: API.GET_USER_INFO,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
......@@ -143,11 +138,6 @@ const services = {
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
getVersion: {
url: API.GET_VERSION,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
updateAvatar: {
url: API.UPDATE_AVATAR,
method: constants.REQUEST_METHOD_GET,
......@@ -228,10 +218,7 @@ export const searchAutoCity = keywords => {
};
export const getUserInfo = params => {
const url =
window.globalConfig && window.globalConfig.hasGateWay
? API.GET_GATEWAY_USER_INFO
: API.GET_USER_INFO;
const url = API.GET_USER_INFO;
return request({
url,
method: constants.REQUEST_METHOD_GET,
......
......@@ -4,7 +4,7 @@ const API = {
GET_INFORMATION:
'/PandaCore/GCK/Message/GetInformationInfo',
GET_MQTT_SITE_CODE:
'/CityInterface/rest/services/CountyProduct.svc/SCADAOper/getMqttSitecode',
'/PandaOMS/OMS/HostManager/GetEmqtConfig',
GET_ALL_INFORMATION_INFO:
'/PandaCore/GCK/Message/GetAllInformationInfo',
POST_INFORMATION_STATUS:
......
......@@ -93,6 +93,39 @@ const appReducer = (state = initialState, action) => {
action.data && action.data.hasOwnProperty('messageVoice') && (window.globalConfig.messageVoice = action.data.messageVoice)
action.data && action.data.hasOwnProperty('topMenu') && (window.globalConfig.topMenu = action.data.topMenu)
window.globalConfig.transformUserInfo = (data) => {
return {
City: data.city,
DDid: data.dDid,
Email: data.email,
EnterprisesType: data.enterprisesType,
GisState: data.gisState,
Groups: data.groups,
IP: data.ip,
IsManager: data.isManager,
LocalSite: data.localSite,
Mark: data.mark,
OID: data.oid,
Phone: data.phone,
Port: data.port,
UserImge: data.userImge,
// UserLevel: data. // 老接口有,新接口没有
// UserType: // 老接口有,新接口没有
WXid: data.wXid,
WxImage: data.wxImage,
WxName: data.wxName,
cloudStationOID: data.cloudStationOID,
depart: data.depart, // 嵌套里面一层的大小写也不一样
exportCAD: data.exportCAD, // 嵌套里面一层的大小写也不一样
extraInfo: data.extraInfo,
fullName: data.fullName,
loginName: data.loginName,
roles: data.roles, // 嵌套里面一层的大小写也不一样
site: data.site,
token: data.token,
tokenexp: data.tokenexp,
}
},
// eslint-disable-next-line no-undef
createStoreage.set('globalConfig', window.globalConfig);
......
......@@ -40,7 +40,6 @@ class AvatarDropdown extends React.Component {
visible: false,
popVisible: false,
path: null,
version: null,
action: API.UPLOAD_FILE_URL,
};
}
......@@ -166,22 +165,6 @@ class AvatarDropdown extends React.Component {
console.log(data);
}
componentDidMount() {
appService
.getVersion({
ignoreSite: true,
})
.then((res) => {
if (res.success) {
this.setState({
version: res.message,
});
}
})
.catch((error) => {
message.error(useIntl().formatMessage({ id: 'component.getVersion.errorMessage' }));
});
}
customRequest = ({
action,
......@@ -252,7 +235,7 @@ class AvatarDropdown extends React.Component {
userID: props.config.get('userInfo.OID'),
loginName: props.config.get('userInfo.loginName'),
userName: props.config.get('userInfo.fullName'),
_version: self.state.version,
_version: '9999',
mark: props.config.get('userInfo.Mark'),
phone: props.config.get('userInfo.Phone'),
email: props.config.get('userInfo.Email'),
......
......@@ -2,7 +2,7 @@ import { request } from '@wisdom-utils/utils';
import * as constants from '@wisdom-utils/components/lib/AppLayout/helpers/constants';
const API = {
GET_INFORMATION: '/PandaCore/GCK/Message/GetInformationInfo',
GET_MQTT_SITE_CODE: '/CityInterface/rest/services/CountyProduct.svc/SCADAOper/getMqttSitecode',
GET_MQTT_SITE_CODE: '/PandaOMS/OMS/HostManager/GetEmqtConfig',
POST_INFORMATION_STATUS: '/PandaCore/GCK/Message/PostInformationStatus',
POST_ADD_OPTIONS: '/CityInterface/rest/services/WisdomUnion.svc/CustomerManage/AddOption',
};
......
......@@ -226,16 +226,16 @@ class Notifier {
async getMqttSiteCode() {
const self = this;
return api.getMqttSiteCode({ 'request.preventCache': Date.now() }).then(res => {
if (res && res.say.statusCode === ERR_OK) {
if (res && res.code === 0) {
let mqttConfig = {
mqtt_mess: {},
mqtt_path: self._siteConfig.mqtt_path,
nginxStart: self._siteConfig.NginxStart,
mqtt_IsSSL: true,
};
if (Array.isArray(res.getMe) && res.getMe.length > 0) {
if (res.getMe[0]) {
const data = res.getMe[0];
if (Array.isArray(res.data) && res.data.length > 0) {
if (res.data[0]) {
const data = res.data[0];
mqttConfig.mqtt_IsSSL = self._siteConfig.IsSSL = data.IsSSL ? data.IsSSL : false;
mqttConfig.mqtt_mess.site_code = self._siteConfig.site_code = data.SiteCode || self._siteConfig.site_code;
mqttConfig.mqtt_mess.TcpIP = self._siteConfig.TcpIP = data.TcpIP;
......
......@@ -406,7 +406,7 @@ class Site {
ignoreSite: true,
})
.then(res => {
if (res && !res.errMsg) {
if (res && res.code === 0) {
this.writeCookie(token, site, onChangeVisible, actionRef);
} else {
message.warning('企业切换失败,请联系管理员排查问题!');
......
......@@ -181,7 +181,7 @@ const BootPage = props => {
ignoreSite: true,
})
.then(res => {
const roles = res && !res.errMsg ? res.roles : null;
const roles = res?.data?.roles ?? [];
const _hasRole = roles && Array.isArray(roles) && roles.filter(r => r.name == '客户运维管理员').length;
setHasRole(!!_hasRole);
});
......
import React, { useState, useEffect, useRef } from 'react';
import { Carousel, Spin, notification } from 'antd';
import { Carousel, Spin, notification, message } from 'antd';
import { useDocumentTitle } from '@ant-design/pro-utils';
import { connect } from 'react-redux';
import { chunk } from 'lodash';
......@@ -74,12 +74,16 @@ const NewProducts = props => {
ignoreSite: true,
})
.then(res => {
if (res.code !== 0) {
setLoading(false);
message.error('获取用户信息失败');
}
// 重置一些环境配置
const config = { ...props.global };
config.uiwidgets = [];
config.widgets = [];
config.allWidgets = [];
config.userInfo = res;
config.userInfo = window?.globalConfig?.transformUserInfo?.(res.data) ?? res.data;
props.updateConfig && props.updateConfig(config);
// 默认有个上次记住的登入企业,存在印象。这里把cookie和localStorage中的都重新设置一下
......@@ -95,6 +99,9 @@ const NewProducts = props => {
const loginAction = new LoginAction({...props, global: config});
// props.instance && props.instance.updateConfig(config);
loginAction && loginAction.getUserInfoAndConfig('', true, '熊猫新产品');
}).catch(err => {
setLoading(false);
message.error('获取用户信息失败');
});
};
......
......@@ -113,32 +113,8 @@ class Login {
'request.preventCache': Date.now(),
ignoreSite: true,
}).then(response => {
if (response && !response.errMsg) {
self.globalConfig.userInfo = {};
if(response.hasOwnProperty('data')) {
self.globalConfig.userInfo = {
// ... self.globalConfig.userInfo,
...response.data,
OID: response.data.OID || response.data.oid,
}
} else {
if (
response.Groups &&
response.Groups instanceof Array &&
response.Groups.length
) {
self.globalConfig.userInfo.Groups = response.Groups;
}
self.globalConfig.userInfo = Object.assign(
{
OID: response.OID || response.oid,
},
response,
self.globalConfig.userInfo,
);
}
if (response && response.code === 0) {
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
self.updateConfig && self.updateConfig(self.globalConfig);
self.getUserInfoAndConfig();
......@@ -249,17 +225,17 @@ class Login {
}),
])
.then(results => {
const res = results[0] ?? {};
if (res && res.say.statusCode === '0000') {
const res = results[0] || {};
if (res && res.code === 0) {
const mqttConfig = {
mqtt_mess: {},
mqtt_path: DEFAULT_MQTT_PATH,
nginxStart: false,
mqtt_IsSSL: true,
};
if (Array.isArray(res.getMe) && res.getMe.length > 0) {
if (res.getMe[0]) {
const data = res.getMe[0];
if (Array.isArray(res.data) && res.data.length > 0) {
if (res.data[0]) {
const data = res.data[0];
mqttConfig.mqtt_IsSSL = data.IsSSL ? data.IsSSL : false;
mqttConfig.mqtt_mess.site_code =
data.SiteCode || self.globalConfig.userInfo.site;
......@@ -754,17 +730,9 @@ class Login {
// eslint-disable-next-line no-shadow
.then(response => {
try {
if (response && !response.errMsg) {
self.globalConfig.userInfo = Object.assign({
OID: response.OID || response.oid,
}, response);
if (response.hasOwnProperty('data')) {
self.globalConfig.userInfo = {
// ... self.globalConfig.userInfo,
...response.data,
OID: response.data.OID || response.data.oid,
};
}
if (response && response.code === 0) {
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......@@ -878,19 +846,9 @@ class Login {
)
.then(response => {
try {
if (response && !response.errMsg) {
self.globalConfig.userInfo = Object.assign(
{ OID: response.OID || response.oid },
response,
// self.globalConfig.userInfo,
);
if(response.hasOwnProperty('data')) {
self.globalConfig.userInfo = {
// ... self.globalConfig.userInfo,
...response.data,
OID: response.data.OID || response.data.oid,
}
}
if (response && response.code === 0) {
self.globalConfig.userInfo = window?.globalConfig?.transformUserInfo?.(response.data) ?? {};
const date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
// date = date.toGMTString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment