Kaynağa Gözat

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/online

wly 7 yıl önce
ebeveyn
işleme
37285d426a

+ 19 - 14
src/app/App.jsx

@@ -21,7 +21,7 @@ import Create from "./graphqlService/component/schema/Create";
 import WxCreate from "./wechatService/wxCreate/WxCreate";
 
 
-import {SHOW_ALL_SCHEMA, SHOW_CASE_SCHEMA,SHOW_PROJECT,CASE_SCHEMA_AND_PROJECT,SHOW_ALL_WXCONFIG} from "../gql";
+import {SHOW_ALL_SCHEMA, SHOW_CASE_SCHEMA,SHOW_PROJECT,CASE_SCHEMA_AND_PROJECT,CASE_WXCONFIG_AND_PROJECT} from "../gql";
 import axios from 'axios';
 import {getCookie, setCookie} from "../cookie";
 
@@ -361,9 +361,9 @@ class GraphqlSidebar extends Component {
             <Query query={gql(CASE_SCHEMA_AND_PROJECT)} variables={{projectType:'graphql',user_id: this.state.userID}}>
                 {
                     ({loading, error, data}) => {
-                        console.log('CASE_SCHEMA_AND_PROJECT data', data);
                         if (loading) return <Spin style={{marginLeft: 3}}/>;
                         if (error) return 'error!';
+                        // console.log('CASE_SCHEMA_AND_PROJECT data', data);
                         localStorage.setItem('ecommerce', data.caseSchema.find(obj => obj.schemaName === 'ecommerce').schemaData);
                         localStorage.setItem('subscribe', data.caseSchema.find(obj => obj.schemaName === 'subscribe').schemaData);
                         localStorage.setItem('bills', data.caseSchema.find(obj => obj.schemaName === 'bills').schemaData);
@@ -425,7 +425,7 @@ class GraphqlSidebar extends Component {
                                                     state: {
                                                         schemaName: project.projectName,
                                                         schemaID: project.schema_id.id,
-                                                        projectId: project.id
+                                                        projectID: project.id
                                                     }
                                                 }}>{project.projectName}</Link>
                                             </Menu.Item>)
@@ -459,7 +459,7 @@ class WxConfigSiderbar extends Component {
 
     render() {
         return (
-            <Query query={gql(CASE_SCHEMA_AND_PROJECT)} variables={{user_id: this.state.userID}}>
+            <Query query={gql(CASE_WXCONFIG_AND_PROJECT)} variables={{projectType:'wx',user_id: this.state.userID}}>
                 {
                     ({loading, error, data}) => {
                         if (loading) return <Spin style={{marginLeft: 3}}/>;
@@ -515,16 +515,21 @@ class WxConfigSiderbar extends Component {
                                     <span><FormattedMessage id="My Create"/></span>
                                 </span>}>
                                     {
-                                        data.userWxConfig.map((config) =>
-                                            <Menu.Item key={config.appName}>
-                                                <Link to={{
-                                                    pathname: `/wechat-service/my-create/${config.appName}`,
-                                                    state: {
-                                                        appName: config.appName,
-                                                        configID: config.id
-                                                    }
-                                                }}>{config.appName}</Link>
-                                            </Menu.Item>)
+                                        data.project.map((project) =>{
+                                            let appName = project.wxConfig_id.appName;
+                                            let configID = project.wxConfig_id.id;
+                                            return (
+                                                <Menu.Item key={appName}>
+                                                    <Link to={{
+                                                        pathname: `/wechat-service/my-create/${appName}`,
+                                                        state: {
+                                                            appName,
+                                                            configID
+                                                        }
+                                                    }}>{appName}</Link>
+                                                </Menu.Item>
+                                            )
+                                        })
                                     }
                                 </SubMenu>
 

+ 2 - 4
src/app/common/deploy/Deploy.jsx

@@ -29,9 +29,7 @@ class Deploy extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            cloud: 'tencent',
-            projectIDOK: 'project_by_mxy_already_deploy',
-            projectIDNULL: 'project_by_mxy_not_deploy'
+            cloud: 'tencent'
         };
     }
 
@@ -43,7 +41,7 @@ class Deploy extends Component {
 
     render() {
         const contentListNoTitle = {
-            tencent: <TencentConfig userID={this.props.userID} projectID={this.state.projectIDNULL} trialcase={this.props.trialcase}/>,
+            tencent: <TencentConfig userID={this.props.userID} projectID={this.props.projectID} trialcase={this.props.trialcase}/>,
             aliyun: <AliConfig/>,
             amazon: <AmazonConfig/>,
         };

+ 1 - 0
src/app/common/deploy/tencent/TencentConfig.js

@@ -97,6 +97,7 @@ class TencentConfig extends Component {
                             deploy = data.project_by_id.deploy_id;
                             cloudID = data.project_by_id.cloud_id.id;
                         }
+                        console.log('object',data);
                         let defaultName = data.project_by_id.projectName;
                         return (
                             <div>

+ 2 - 1
src/app/graphqlService/TrialCase.jsx

@@ -52,6 +52,7 @@ class TrialCase extends Component {
     render() {
         let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "ecommerce_schemaID";
         let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
+        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
         let _this = this;
         return (
             <div>
@@ -80,7 +81,7 @@ class TrialCase extends Component {
                                     case 'schema':
                                         return <Schema trialcase={true} userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
                                     case 'deploy':
-                                        return <Deploy trialcase={true} userID={this.state.userID} projectID={'need fill, test use state'}/>;
+                                        return <Deploy trialcase={true} userID={this.state.userID} projectID={projectID}/>;
                                     case 'manage':
                                         return <Manage/>;
                                     case 'graphiql':

+ 2 - 1
src/app/graphqlService/UserCreate.jsx

@@ -49,6 +49,7 @@ class UserCreate extends Component {
     render() {
         let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "ecommerce_schemaID";
         let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
+        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
         return (
             <div>
                 <Menu
@@ -75,7 +76,7 @@ class UserCreate extends Component {
                                     case 'schema':
                                         return <Schema trialcase={false} userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
                                     case 'deploy':
-                                        return <Deploy trialcase={false} userID={this.state.userID} projectID={'need fill, test use state'}/>;
+                                        return <Deploy trialcase={false} userID={this.state.userID} projectID={projectID}/>;
                                     case 'manage':
                                         return <Manage/>;
                                     case 'graphiql':

+ 5 - 5
src/app/graphqlService/component/schema/Create.js

@@ -35,7 +35,7 @@ class Create extends Component {
     }
 
 
-    handleOk = (userID, create_schema_and_project) => {
+    handleOk = (userID, create_project_and_schema) => {
         let schemaId = idGen('schema');
         let projectId= idGen('project');
         let schemaName = this.state.schemaName;
@@ -70,7 +70,7 @@ class Create extends Component {
             confirmLoading: true,
         });
 
-        create_schema_and_project({
+        create_project_and_schema({
             variables: {...schemaVarObj,...projectVarObj},
             refetchQueries:[{query: gql(SHOW_PROJECT), variables: {projectType:'graphql',user_id: userID}}]
         });
@@ -87,7 +87,7 @@ class Create extends Component {
             state: {
                 schemaName,
                 schemaID:schemaId,
-                projectId: projectId,
+                projectID: projectId,
                 create: true
             }
         });
@@ -102,7 +102,7 @@ class Create extends Component {
                 <Mutation
                     mutation={gql(ADD_PROJECT_AND_SCHEMA)}
                 >
-                    {(create_schema_and_project, {loading, error}) => {
+                    {(create_project_and_schema, {loading, error}) => {
                         if (loading)
                             return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
                         if (error)
@@ -113,7 +113,7 @@ class Create extends Component {
                                     <Modal title={msg}
                                            centered
                                            visible={visible}
-                                           onOk={() => this.handleOk(userID, create_schema_and_project)}
+                                           onOk={() => this.handleOk(userID, create_project_and_schema)}
                                            confirmLoading={confirmLoading}
                                            onCancel={() => {
                                                this.props.hideModal();

+ 1 - 0
src/app/wechatService/WxTrialCase.js

@@ -26,6 +26,7 @@ class WxTrialCase extends Component {
     render() {
         let configID = this.props.history.location.state ? this.props.history.location.state.configID : "ecommerce_wxConfigID";
         let appName = this.props.history.location.state ? this.props.history.location.state.appName : "ecommerce";
+        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
         return (
             <div>
                 <Menu

+ 1 - 0
src/app/wechatService/WxUserCreate.js

@@ -47,6 +47,7 @@ class WxUserCreate extends Component {
     render() {
         let configID = this.props.history.location.state ? this.props.history.location.state.configID : "ecommerce_wxConfigID";
         let appName = this.props.history.location.state ? this.props.history.location.state.appName : "ecommerce";
+        let projectID = this.props.history.location.state ? this.props.history.location.state.projectID : "";
         return (
             <div>
                 <Menu

+ 33 - 16
src/app/wechatService/wxCreate/WxCreate.js

@@ -5,7 +5,7 @@ import {Modal, Row, Col, Input, Icon, Button, Spin} from 'antd';
 import {Mutation, Query} from "react-apollo";
 import gql from "graphql-tag";
 
-import {ADD_WXCONFIG, SHOW_WXCONFIG} from '../../../gql'
+import {ADD_WXCONFIG,ADD_PROJECT_AND_WX, SHOW_WXCONFIG} from '../../../gql'
 import './index.css';
 import {getCookie} from "../../../cookie";
 import {idGen} from "../../../func";
@@ -44,13 +44,19 @@ class WxCreate extends Component {
         });
     };
 
-    handleOk = (userID, create_wxConfig) => {
+    handleOk = (userID, create_project_and_wxConfig) => {
         let {mch_id, notify_url, appSecret, appID, token, spbill_create_ip, enter_url, pay_api_key, body, welcome_words, attach} = this.state;
-        let varobj = {
-            id: idGen('wxConfig'),
+        let wxConfigId = idGen('wxConfig');
+        let projectId= idGen('project');
+        let appName = this.state.appName;
+        let createdAt = new Date().getTime();
+
+        let wxConfigVarObj = {
+            wxConfigId,
+            appName,
             user_id: userID,
-            createdAt: new Date().getTime(),
-            updatedAt: '',
+            wxCreatedAt: createdAt,
+            wxUpdatedAt: '',
             mch_id,
             notify_url,
             appSecret,
@@ -63,16 +69,29 @@ class WxCreate extends Component {
             welcome_words,
             attach
         };
-        let appName = this.state.appName;
+        let projectVarObj = {
+            projectCreatedAt: createdAt,
+            projectUpdatedAt: '',
+            database_id: '',
+            apiGWGroup_id: '',
+            projectName: appName,
+            deploy_id: '',
+            projectId,
+            projectType: 'wx',
+            cloud_id: '',
+            user_id: userID,
+            wxConfig_id: wxConfigId,
+            schema_id: ''
+        };
 
         this.setState({
             confirmLoading: true,
         });
 
-        create_wxConfig({
+        create_project_and_wxConfig({
             variables: {
-                ...varobj,
-                appName
+                ...wxConfigVarObj,
+                ...projectVarObj
             }
         });
 
@@ -89,7 +108,7 @@ class WxCreate extends Component {
             pathname: `/wechat-service/my-create/${appName}`,
             state: {
                 appName,
-                configID: varobj.id,
+                configID: wxConfigId,
                 create: true
             }
         });
@@ -102,11 +121,9 @@ class WxCreate extends Component {
         return (
             <div>
                 <Mutation
-                    mutation={gql(ADD_WXCONFIG)}
-                    refetchQueries={[{query: gql(SHOW_WXCONFIG), variables: {user_id: userID}}]}
+                    mutation={gql(ADD_PROJECT_AND_WX)}
                 >
-
-                    {(create_wxConfig, {loading, error}) => {
+                    {(create_project_and_wxConfig, {loading, error}) => {
                         if (loading)
                             return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
                         if (error)
@@ -115,7 +132,7 @@ class WxCreate extends Component {
                             <Modal title="Create Wechat Service"
                                    centered
                                    visible={visible}
-                                   onOk={() => this.handleOk(userID, create_wxConfig)}
+                                   onOk={() => this.handleOk(userID, create_project_and_wxConfig)}
                                    confirmLoading={confirmLoading}
                                    onCancel={() => {
                                        this.props.hideModal();

+ 117 - 0
src/gql.js

@@ -269,6 +269,79 @@ const ADD_PROJECT_AND_SCHEMA = `
                  }
              `;
 
+const ADD_PROJECT_AND_WX = `
+             mutation ADD_PROJECT_AND_WX($wxUpdatedAt: String, $mch_id: String, $appName: String, $notify_url: String, $appSecret: String, $wxCreatedAt: String, $appID: String, $token: String, $spbill_create_ip: String, $enter_url: String, $wxConfigId: ID!, $pay_api_key: String, $user_id: ID, $body: String, $welcome_words: String, $attach: String
+                 $projectCreatedAt: String, $projectUpdatedAt: String, $database_id: ID, $apiGWGroup_id: ID, $projectName: String, $deploy_id: ID, $projectId: ID!, $projectType: String, $cloud_id: ID, $user_id: ID, $wxConfig_id: ID, $schema_id: ID) {
+                     create_wxConfig(
+                         createdAt: $wxCreatedAt 
+                         updatedAt: $wxUpdatedAt
+                         mch_id: $mch_id 
+                         appName: $appName 
+                         notify_url: $notify_url 
+                         appSecret: $appSecret 
+                         appID: $appID 
+                         token: $token 
+                         spbill_create_ip: $spbill_create_ip 
+                         enter_url: $enter_url 
+                         id: $wxConfigId
+                         pay_api_key: $pay_api_key 
+                         user_id: $user_id 
+                         body: $body 
+                         welcome_words: $welcome_words 
+                         attach: $attach
+                     ) {
+                         mch_id
+                         appName
+                         notify_url
+                         appSecret
+                         appID
+                         token
+                         spbill_create_ip
+                         enter_url
+                         id
+                         pay_api_key
+                         body
+                         welcome_words
+                         attach
+                     }
+             
+                     create_project(
+                         createdAt: $projectCreatedAt,
+                         updatedAt: $projectUpdatedAt,
+                         database_id: $database_id,
+                         apiGWGroup_id: $apiGWGroup_id,
+                         projectName: $projectName,
+                         deploy_id: $deploy_id,
+                         id: $projectId,
+                         projectType: $projectType,
+                         cloud_id: $cloud_id,
+                         user_id: $user_id,
+                         wxConfig_id: $wxConfig_id,
+                         schema_id: $schema_id
+                     ) {
+                         updatedAt
+                         createdAt   
+                         projectName
+                         id
+                         projectType
+                         schema_id {
+                             updatedAt
+                             schemaState
+                             authWrite
+                             authReadObjects
+                             createdAt
+                             authRead
+                             schemaName
+                             reference
+                             id
+                             schemaData
+                             authReadWrite
+                             authWriteObjects
+                         }
+                     }  
+                 }
+             `;
+
 const CASE_SCHEMA_AND_PROJECT = `
             query CASE_SCHEMA_AND_PROJECT($user_id: ID, $projectType: String ) {
                 caseSchema:schema_by_props(user_id: "ioobot") {
@@ -293,6 +366,48 @@ const CASE_SCHEMA_AND_PROJECT = `
                     projectType
                     wxConfig_id {
                         id
+                        appName
+                    }
+                    schema_id {
+                        id
+                    }
+                }
+            }
+         `;
+
+const CASE_WXCONFIG_AND_PROJECT = `
+            query CASE_WXCONFIG_AND_PROJECT($user_id: ID, $projectType: String ) {
+                caseWxConfig:wxConfig_by_props(user_id: "ioobot") {
+                    appID
+                    appName
+                    appSecret
+                    attach
+                    body
+                    enter_url
+                    id
+                    mch_id
+                    notify_url
+                    pay_api_key
+                    spbill_create_ip
+                    token
+                    welcome_words
+                }
+                
+                project:project_by_props(
+                    projectType: $projectType,
+                    user_id: $user_id
+                ) {
+                    updatedAt
+                    apiGWGroup_id {
+                        id
+                    }
+                    createdAt
+                    projectName
+                    id
+                    projectType
+                    wxConfig_id {
+                        id
+                        appName
                     }
                     schema_id {
                         id
@@ -834,6 +949,7 @@ export {
     SHOW_TABLE,
     ADD_PROJECT_AND_SCHEMA,
     CASE_SCHEMA_AND_PROJECT,
+    CASE_WXCONFIG_AND_PROJECT,
     SHOW_PROJECT,
     ADD_CLOUD,
     SHOW_CLOUD,
@@ -849,6 +965,7 @@ export {
     UPDATE_APIGWPATH,
     SHOW_FC_SCHEMA,
     SHOW_FC_CONFIG,
+    ADD_PROJECT_AND_WX,
     SHOW_ALL_WXCONFIG,
     SHOW_WXCONFIG,
     ADD_WXCONFIG,