Browse Source

fix: BI-51508 修改次级管理员下,数据库连接重名无提示的bug

qufenxi
alan 5 years ago
parent
commit
f7a8849a21
  1. 12
      src/modules/crud/api.ts
  2. 4
      src/modules/crud/crud.service.ts
  3. 6
      src/modules/crud/crud.typings.d.ts
  4. 10
      src/modules/crud/decision.api.ts
  5. 9
      src/modules/pages/maintain/forms/form.model.ts

12
src/modules/crud/api.ts

@ -1,4 +1,4 @@
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ResultType } from './crud.typings';
export interface Api {
/**
@ -9,24 +9,24 @@ export interface Api {
/**
*
*/
getConnectionlist(): Promise<{data: Connection[]}>;
getConnectionlist(): Promise<{data?: Connection[]}>;
/**
*
* @param connectionName
*/
deleteConnection(connectionName: string): Promise<{data: string}>;
deleteConnection(connectionName: string): Promise<ResultType>;
/**
*
* @param data
*/
addConnection(data: Connection): Promise<{data: string}>;
addConnection(data: Connection): Promise<ResultType>;
/**
*
*/
updateConnection(data: Connection): Promise<{data: string}>;
updateConnection(data: Connection): Promise<ResultType>;
/**
*
@ -38,7 +38,7 @@ export interface Api {
*
* @param name
*/
getConnectionPool(name: string): Promise<{data: ConnectionPoolType}>;
getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}>;
/**
*

4
src/modules/crud/crud.service.ts

@ -1,6 +1,6 @@
import 'es6-promise/auto';
import axios, { AxiosResponse, AxiosError } from 'axios';
import { CrudReqOpts, CrudParams } from './crud.typings.d';
import { CrudReqOpts, CrudParams, ResultType } from './crud.typings.d';
import { ReqPrefix } from '../constants/env';
const defaultHeaders = {
'Content-Type': 'application/json',
@ -39,7 +39,7 @@ function getCookieByName(name: string):string {
return value;
}
export async function request(reqOptions: CrudReqOpts = {}) {
export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType> {
const { url, type, headers, data, params } = reqOptions;
return axios

6
src/modules/crud/crud.typings.d.ts vendored

@ -210,3 +210,9 @@ export interface SocketResult {
errorCode?: string;
errorMsg?: string;
}
export interface ResultType {
data?: any;
errorCode?: string;
errorMsg?: string;
}

10
src/modules/crud/decision.api.ts

@ -6,17 +6,17 @@ import { editStatusEvent } from '@constants/env';
export class DecisionApi implements Api {
isDec = true;
getConnectionlist(): Promise<{data: Connection[]}> {
getConnectionlist(): Promise<{data?: Connection[]}> {
return requestGet('list');
}
deleteConnection(connectionName: string): Promise<{data: string}> {
deleteConnection(connectionName: string) {
return requestDelete('', {
connectionName,
});
}
addConnection(data: Connection): Promise<{data: string}> {
addConnection(data: Connection) {
const form = {
...data,
connectionId: data.connectionName,
@ -26,7 +26,7 @@ export class DecisionApi implements Api {
return requestPost('', form);
}
updateConnection(data: Connection): Promise<{data: string}> {
updateConnection(data: Connection) {
const form = {
...data,
connectionData : JSON.stringify(data.connectionData),
@ -44,7 +44,7 @@ export class DecisionApi implements Api {
return requestPost('test', form);
}
getConnectionPool(name: string): Promise<{data: ConnectionPoolType}> {
getConnectionPool(name: string): Promise<{data?: ConnectionPoolType}> {
return requestGet(`pool/info?connectionName=${name}`);
}

9
src/modules/pages/maintain/forms/form.model.ts

@ -22,7 +22,14 @@ export class MaintainFormModel extends Model<{
actions = {
addConnection: (data: Connection) => {
api.addConnection(data).then(() => {
api.addConnection(data).then(result => {
if (result.errorCode) {
BI.Msg.toast(BI.i18nText(result.errorMsg), {
level: 'error',
});
return;
}
this.model.pageIndex = PAGE_INDEX.CONNECTION;
});
},

Loading…
Cancel
Save