Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

Csy817 7 rokov pred
rodič
commit
f52d1314c3
1 zmenil súbory, kde vykonal 105 pridanie a 100 odobranie
  1. 105 100
      src/app/basicVersion/exampleShow/DeployCloudChoose.js

+ 105 - 100
src/app/basicVersion/exampleShow/DeployCloudChoose.js

@@ -17,7 +17,7 @@ class DeployCloudChoose extends Component {
         super();
         this.state = {
             userID: 'demo',
-            dbKind: 'fc-db', // fc-db
+            dbKind: 'mongodb', // mongodb fc-db
             cloudID: 'tencent_CloudID',
             secretID: '',
             secretKey: '',
@@ -101,11 +101,11 @@ class DeployCloudChoose extends Component {
             }
 
 
-            console.log(now, functionName, serviceName, resources);
+            console.log('now', now, 'functionName', functionName, 'serviceName', serviceName, 'resources', resources);
             axios.post(deployAll,
                 {
                     'fc-name': functionName,
-                    'bucket': 'native-fc',
+                    'bucket': dbKind === 'mongodb'? 'native-fc' : 'fcdb-deploy',
                     'object-file': 'fc-only.zip',
                     'res-bucket': 'case',
                     'resources': resources,
@@ -114,114 +114,119 @@ class DeployCloudChoose extends Component {
                 })
                 .then(function (response) {
                     console.log(response);
-                    // 处理数据
-                    let result = response['data']['apigw-result'];
-                    let apiData = result['api-info'];
-                    let serviceData = result['service-info'];
+                    if(response['data']['apigw-result'] && response['data']['fc-result']) {
+                        // 处理数据
+                        let result = response['data']['apigw-result'];
+                        let apiData = result['api-info'];
+                        let serviceData = result['service-info'];
 
-                    // 存数据
-                    let pathID = idGen('path'),
-                        groupID = idGen('group'),
-                        deployID = idGen('deploy'),
-                        projectID = idGen('project');
+                        // 存数据
+                        let pathID = idGen('path'),
+                            groupID = idGen('group'),
+                            deployID = idGen('deploy'),
+                            projectID = idGen('project');
 
-                    let {apiId, path, method} = apiData;
-                    let {serviceName, serviceId, subDomain} = serviceData;
+                        let {apiId, path, method} = apiData;
+                        let {serviceName, serviceId, subDomain} = serviceData;
 
-                    let {userID, cloudID} = _this.state;
+                        let {userID, cloudID} = _this.state;
 
-                    let pathVarObj = {
-                        id: idGen('path'),
-                        user_id: userID,
-                        apiGWGroup_id: pathID,
-                        deploy_id: deployID,
-                        apiGWName: functionName,
-                        requestMethod: method,
-                        apiGWPath: path,
-                        apiId: apiId,
-                        apiGWDesc: '',
-                        serviceType: 'SCF',
-                        timeout: 300,
-                        createdAt: now,
-                        updatedAt: ''
-                    };
+                        let pathVarObj = {
+                            id: idGen('path'),
+                            user_id: userID,
+                            apiGWGroup_id: pathID,
+                            deploy_id: deployID,
+                            apiGWName: functionName,
+                            requestMethod: method,
+                            apiGWPath: path,
+                            apiId: apiId,
+                            apiGWDesc: '',
+                            serviceType: 'SCF',
+                            timeout: 300,
+                            createdAt: now,
+                            updatedAt: ''
+                        };
 
-                    let projectVarObj = {
-                        id: projectID,
-                        projectType: 'case',
-                        cloud_id: cloudID,
-                        user_id: userID,
-                        projectName: functionName,
-                        database_id: '',
-                        apiGWGroup_id: '',
-                        deploy_id: '',
-                        case_id: '',
-                        wxConfig_id: '',
-                        schema_id: '',
-                        createdAt: now,
-                        updatedAt: '',
-                        projectStatus: 'deployed'
-                    };
+                        let projectVarObj = {
+                            id: projectID,
+                            projectType: 'case',
+                            cloud_id: cloudID,
+                            user_id: userID,
+                            projectName: functionName,
+                            database_id: '',
+                            apiGWGroup_id: '',
+                            deploy_id: '',
+                            case_id: '',
+                            wxConfig_id: '',
+                            schema_id: '',
+                            createdAt: now,
+                            updatedAt: '',
+                            projectStatus: 'deployed'
+                        };
 
-                    let groupVarObj = {
-                        id: groupID,
-                        cloud_id: cloudID,
-                        user_id: userID,
-                        userStatus: '',
-                        userDomain: '',
-                        groupName: serviceName,
-                        frontType: '',
-                        region: '',
-                        environmentName: '',
-                        defaultDomain: subDomain,
-                        status: '',
-                        serviceId: serviceId,
-                        createdAt: now,
-                        updatedAt: ''
-                    };
+                        let groupVarObj = {
+                            id: groupID,
+                            cloud_id: cloudID,
+                            user_id: userID,
+                            userStatus: '',
+                            userDomain: '',
+                            groupName: serviceName,
+                            frontType: '',
+                            region: '',
+                            environmentName: '',
+                            defaultDomain: subDomain,
+                            status: '',
+                            serviceId: serviceId,
+                            createdAt: now,
+                            updatedAt: ''
+                        };
 
-                    let deployVarObj = {
-                        id: deployID,
-                        cloud_id: cloudID,
-                        functionName,
-                        cosObjectName: '',
-                        region: '',
-                        cosBucketRegion: '',
-                        description: '',
-                        cosBucketName: '',
-                        vpcId: '',
-                        subnetId: '',
-                        memorySize: 512,
-                        timeout: 300,
-                        handler: '',
-                        serviceName: "",
-                        fc_id: '',
-                        createdAt: now,
-                        updatedAt: ''
-                    };
+                        let deployVarObj = {
+                            id: deployID,
+                            cloud_id: cloudID,
+                            functionName,
+                            cosObjectName: '',
+                            region: '',
+                            cosBucketRegion: '',
+                            description: '',
+                            cosBucketName: '',
+                            vpcId: '',
+                            subnetId: '',
+                            memorySize: 512,
+                            timeout: 300,
+                            handler: '',
+                            serviceName: "",
+                            fc_id: '',
+                            createdAt: now,
+                            updatedAt: ''
+                        };
 
-                    let add_apigwpath = request(graphqlUrl, ADD_APIGWPATH, pathVarObj),
-                        add_project = request(graphqlUrl, ADD_PROJECT, projectVarObj),
-                        add_apigroup = request(graphqlUrl, ADD_APIGROUP, groupVarObj),
-                        add_deploy = request(graphqlUrl, ADD_DEPLOY, deployVarObj);
+                        let add_apigwpath = request(graphqlUrl, ADD_APIGWPATH, pathVarObj),
+                            add_project = request(graphqlUrl, ADD_PROJECT, projectVarObj),
+                            add_apigroup = request(graphqlUrl, ADD_APIGROUP, groupVarObj),
+                            add_deploy = request(graphqlUrl, ADD_DEPLOY, deployVarObj);
 
-                    Promise.all([add_apigwpath, add_project, add_apigroup, add_deploy])
-                        .then(value => {
-                            console.log(value);
+                        Promise.all([add_apigwpath, add_project, add_apigroup, add_deploy])
+                            .then(value => {
+                                console.log(value);
 
-                            // 展示数据
-                            _this.setState({
-                                disabled: false
-                            });
-                            _this.props.changeTabBar('my-deploy');
-                            _this.props.history.push({
-                                pathname: `/common/deploy`,
-                                state: {}
+                                // 展示数据
+                                _this.setState({
+                                    disabled: false
+                                });
+                                _this.props.changeTabBar('my-deploy');
+                                _this.props.history.push({
+                                    pathname: `/common/deploy`,
+                                    state: {}
+                                });
+                            })
+                            .catch(err => {
+                                console.log(err);
                             });
-                        })
-                        .catch(err => {
-                            console.log(err);
-                        });
+                    } else {
+                        console.log('deployAll 失败');
+                    }
+
                 })
                 .catch(function (error) {
                     console.log('axios error', error);