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

fix: GetUserInfo/GetEmqtConfig接口升级

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