Просмотр исходного кода

测试挂接后端 schema验证 deploy

Csy817 7 лет назад
Родитель
Сommit
b9d3b3b2a9

+ 28 - 2
src/app/common/deploy/tencent/TencentConfig.js

@@ -1,5 +1,6 @@
 import React, {Component} from 'react';
 import {Row, Col, Card, Button} from 'antd';
+import axios from 'axios';
 import APIGroupCard from './APIGroupCard';
 import APIPathCard from './APIPathCard';
 import DeployCard from './DeployCard';
@@ -7,9 +8,10 @@ import NotificationCard from './NotificationCard';
 
 import {SHOW_DEPLOY, SHOW_APIGWGROUP, SHOW_APIGWPATH} from "../../../../gql";
 import {request} from 'graphql-request'
-import {graphqlUrl} from "../../../../config";
+import {graphqlUrl,deployUrl} from "../../../../config";
 import {FormattedMessage} from 'react-intl';
 
+
 class TencentConfig extends Component {
     constructor(props) {
         super(props);
@@ -94,6 +96,30 @@ class TencentConfig extends Component {
         });
     };
 
+    deployFC = () => {
+        let _this = this;
+
+        // axios.get(`${deployUrl}`,
+        axios.get(`http://localhost:8999/graphql/deployall`,
+            {
+                params: {
+                    'cloud-name': 'tencent',
+                    schema:"ecommerce_schemaID",
+                    deploy:"deploy_98765_43210",
+                    api:"apiPath_12345_67890",
+                    group:"apiGrpup_98765_43210"
+                }
+            })
+            .then((res) => {
+                console.log('deploy res', res);
+            })
+            .catch((err) => {
+                console.log('err',err);
+                console.log('err.response',err.response);
+                console.log('err.response.data',err.response.data);
+            });
+    };
+
     render() {
         return (
             <div>
@@ -108,7 +134,7 @@ class TencentConfig extends Component {
 
                         </Col>
                         <Col offset={2} span={6}>
-                            <Button type='primary'><FormattedMessage id="deploy"/>!</Button>
+                            <Button type='primary' onClick={()=>this.deployFC()}><FormattedMessage id="deploy"/>!</Button>
                         </Col>
                     </Row>
                 </div>

+ 3 - 3
src/app/graphqlService/component/generateJs/GenerateJs.jsx

@@ -4,7 +4,7 @@ import axios from 'axios';
 import {BackTop, Tabs, Button, Spin} from 'antd';
 import saveAs from 'file-saver';
 import beautify from 'js-beautify';
-import {requestUrl} from '../../../../config';
+import {genJsUrl} from '../../../../config';
 
 import './index.css';
 
@@ -26,7 +26,7 @@ class GenerateJs extends Component {
         this._isMounted = true;
         let _this = this;
         let {schemaID} = this.state;
-        axios.get(`${requestUrl}?schema=${schemaID}`)
+        axios.get(`${genJsUrl}?schema=${schemaID}`)
             .then((res) => {
                 if(this._isMounted){
                     if (res.data !== '') {
@@ -59,7 +59,7 @@ class GenerateJs extends Component {
         this._isMounted = true;
         let _this = this;
         let {schemaID} = this.state;
-        axios.get(`${requestUrl}?schema=${schemaID}`)
+        axios.get(`${genJsUrl}?schema=${schemaID}`)
             .then((res) => {
                 if(this._isMounted){
                     if (res.data !== '') {

+ 31 - 8
src/app/graphqlService/component/schema/Table.js

@@ -1,4 +1,5 @@
 import React, {Component} from 'react';
+import axios from 'axios';
 
 import {Layout, Select, Input, Icon, Button, notification, Spin, Modal} from 'antd';
 import {UPDATE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE} from "../../../../gql";
@@ -8,6 +9,7 @@ import {FormattedMessage} from 'react-intl';
 import {Mutation, Query} from "react-apollo";
 import {getCookie} from "../../../../cookie";
 import {manageUsers} from "../../../../config";
+import {checkSchemaUrl} from '../../../../config';
 
 const Option = Select.Option;
 const {Content} = Layout;
@@ -285,7 +287,8 @@ class UpdateTableButton extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            originTableName: props.currentTable
+            originTableName: props.currentTable,
+            schemaCheck:false
         }
 
     }
@@ -321,6 +324,31 @@ class UpdateTableButton extends Component {
         }
     };
 
+    checkSchema = (update_schema,schemaID,varobj,schemaCols) => {
+        update_schema({
+            variables: {
+                ...varobj,
+                schemaData: JSON.stringify(schemaCols)
+            }
+        });
+        let _this = this;
+
+        axios.get(`${checkSchemaUrl}?schema=${schemaID}`)
+            .then((res) => {
+                console.log('check schema res', res);
+                if (res.data !== '') {
+                    _this.setState({
+                        schemaCheck:"checked-success",
+                    });
+                }
+            })
+            .catch((err) => {
+                console.log('err',err);
+                console.log('err.response',err.response);
+                console.log('err.response.data',err.response.data);
+            });
+    };
+
     render() {
         let schemaID = this.props.schemaID;
         let schemaName = this.props.schemaName;
@@ -406,15 +434,10 @@ class UpdateTableButton extends Component {
                                     return (
                                         <div style={{display: 'inline-block'}}>
                                             <Button type="primary" onClick={() => {
-                                                update_schema({
-                                                    variables: {
-                                                        ...varobj,
-                                                        schemaData: JSON.stringify(schemaCols)
-                                                    }
-                                                });
+                                                this.checkSchema(update_schema,schemaID,varobj,schemaCols);
                                                 this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
                                             }}>
-                                                save
+                                                <FormattedMessage id="save"/>
                                             </Button>
                                         </div>
                                     )

+ 4 - 2
src/config.js

@@ -8,7 +8,9 @@ const backend = serverIP + ':' + backendPort;
 const graphqlUrl = serverIP + ':' + graphqlPort + '/graphql';
 
 // api 配置
-const requestUrl = backend + '/graphql/genjs';
+const genJsUrl = backend + '/graphql/genjs';
+const checkSchemaUrl = backend + '/graphql/compile';
+const deployUrl = backend + '/graphql/deployall';
 const getIdUrl = backend + '/getuserid';
 const loginUrl = backend +  '/login';
 const registerUrl = backend + '/resetpassword';
@@ -16,4 +18,4 @@ const registerUrl = backend + '/resetpassword';
 // 管理员配置
 const manageUsers = ['xy_1_je9{d\'\'_32sD+'];
 
-export {requestUrl, getIdUrl, loginUrl, registerUrl, graphqlUrl, manageUsers}
+export {genJsUrl, getIdUrl, loginUrl, registerUrl,checkSchemaUrl,deployUrl, graphqlUrl, manageUsers}