xuezizhuo 1 anno fa
parent
commit
aa0eaa4a9d

+ 4 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DataSourceController.java

@@ -21,10 +21,10 @@ public class DataSourceController extends BaseController {
     /**
      * 数据源信息列表
      */
-    @GetMapping("/list")
-    public AjaxResult dataSourceList(){
-        return AjaxResult.success(dataSourceService.list());
-    }
+//    @GetMapping("/list")
+//    public AjaxResult dataSourceList(){
+//        return AjaxResult.success(dataSourceService.list());
+//    }
 
     /**
      * 新增数据源

+ 9 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@@ -3,12 +3,15 @@ package com.ruoyi.web.controller.system;
 import java.util.List;
 import java.util.Set;
 
+import com.alibaba.fastjson2.JSON;
+import com.ruoyi.common.constant.IpConstants;
 import com.ruoyi.common.core.domain.entity.DataSource;
 import com.ruoyi.common.core.domain.entity.SysTenant;
 import com.ruoyi.common.utils.http.HttpUtils;
 import com.ruoyi.system.service.IDataSourceService;
 import com.ruoyi.system.service.impl.SysTenantServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -22,6 +25,7 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.framework.web.service.SysLoginService;
 import com.ruoyi.framework.web.service.SysPermissionService;
 import com.ruoyi.system.service.ISysMenuService;
+import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 
@@ -48,6 +52,8 @@ public class SysLoginController
     @Resource
     private IDataSourceService dataSourceService;
 
+    RestTemplate restTemplate = new RestTemplate();
+
 
 
     /**
@@ -93,9 +99,9 @@ public class SysLoginController
             DataSource dataSource = dataSourceService.selectById(sysTenant.getDatasourceId());
             ajax.put("dataSource",dataSource);
             //调用数据引擎服务切换数据源接口
-            String param = "id="+sysTenant.getDatasourceId();
-            String data = HttpUtils.sendGet("http://localhost:8081/dataSource/changeDataSource",param);
-            System.err.println(data);
+            restTemplate.postForEntity(IpConstants.DATA_ENGINE_IP, dataSource, DataSource.class);
+            //调用表单引擎服务切换数据源接口
+            restTemplate.postForEntity(IpConstants.DRAG_FORM_IP, dataSource, DataSource.class);
         }
         return ajax;
     }

+ 2 - 2
ruoyi-common/src/main/java/com/ruoyi/common/constant/IpConstants.java

@@ -10,12 +10,12 @@ public class IpConstants {
     /**
      * 数据引擎切换数据源接口地址
      */
-    public static final String DATA_ENGINE_IP = "http://localhost:8081/dataSource/changeDataSource";
+    public static final String DATA_ENGINE_IP = "http://192.168.110.52:8099/dataSource/changeDataSource";
 
     /**
      * 动态表单切换数据源接口地址
      */
-    public static final String DRAG_FORM_IP = "http://localhost:8081/dataSource/changeDataSource";
+    public static final String DRAG_FORM_IP = "http://192.168.110.59:8088/dataSource/changeDataSource";
 
 
 }

+ 3 - 2
ruoyi-ui/.env.development

@@ -10,7 +10,8 @@ VUE_APP_BASE_API = '/dev-api'
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true
 
-VUE_APP_BASE_API2 = 'http://192.168.110.59:8081/'
-
+#数据引擎模块IP
+VUE_APP_BASE_API2 = 'http://192.168.110.52:8099/'
 
+#表单引擎模块IP
 VUE_APP_BASE_API3 = 'http://192.168.110.59:8088/'

+ 24 - 6
ruoyi-ui/src/api/dataEngine/index.js

@@ -10,18 +10,36 @@ export function tableInfoList(data) {
 }
 
 
-export function removeTable(tableName) {
+// export function removeTable(tableName) {
+//   return request({
+//     url: '/tableInfo/removeTable/' + tableName,
+//     method: 'delete',
+//     baseURL:process.env.VUE_APP_BASE_API2
+//   })
+// }
+
+export function removeTable(data) {
   return request({
-    url: '/tableInfo/removeTable/' + tableName,
-    method: 'delete',
+    url: '/tableInfo/removeTable',
+    method: 'post',
+    data: data,
     baseURL:process.env.VUE_APP_BASE_API2
   })
 }
 
-export function tableInfo(tableName) {
+// export function tableInfo(tableName) {
+//   return request({
+//     url: '/tableInfo/tableFieldInfo?tableName=' + tableName,
+//     method: 'get',
+//     baseURL:process.env.VUE_APP_BASE_API2
+//   })
+// }
+
+export function tableInfo(data) {
   return request({
-    url: '/tableInfo/tableFieldInfo?tableName=' + tableName,
-    method: 'get',
+    url: '/tableInfo/tableFieldInfo',
+    method: 'post',
+    data: data,
     baseURL:process.env.VUE_APP_BASE_API2
   })
 }

+ 14 - 5
ruoyi-ui/src/views/dataEngine/datamodeling/editTable.vue

@@ -132,7 +132,7 @@
 </template>
 
 <script>
-import { tableInfo,editTable } from '@/api/dataEngine/index'
+import { tableInfo, editTable } from '@/api/dataEngine/index'
 export default {
     name: "Datasheet",
     data() {
@@ -140,7 +140,7 @@ export default {
             form: {
                 dataBaseName: '',
                 tableName: '',
-                tableComment:'',
+                tableComment: '',
             },
             experienceData: [],
             dataBase: {}
@@ -156,8 +156,8 @@ export default {
                 if (index != ind) {
                     item.isPrimary = false;
                 }
-                if(index==ind){
-                    item.isNull=true
+                if (index == ind) {
+                    item.isNull = true
                 }
 
             })
@@ -192,7 +192,14 @@ export default {
         info() {
             const tableName = this.$route.query.tableName
             const tableComment = this.$route.query.tableComment
-            tableInfo(tableName).then(response => {
+
+            let data = {
+                tableName: this.$route.query.tableName,
+                databaseType: this.$store.state.user.dataSource.databaseType,
+                databaseName: this.$store.state.user.dataSource.databaseName,
+            }
+
+            tableInfo(data).then(response => {
                 console.log(response);
                 this.experienceData = response.data
                 this.form.tableName = tableName
@@ -206,6 +213,8 @@ export default {
                 }
             })
             let query = {
+                databaseType: this.$store.state.user.dataSource.databaseType,
+                databaseName: this.$store.state.user.dataSource.databaseName,
                 tableName: this.form.tableName,
                 tableComment: this.form.tableComment,
                 field: this.experienceData

+ 23 - 73
ruoyi-ui/src/views/dataEngine/datamodeling/index.vue

@@ -1,92 +1,40 @@
 <template>
   <div class="app-container">
-    <el-form
-      :model="queryParams"
-      ref="queryForm"
-      size="small"
-      :inline="true"
-      v-show="showSearch"
-      label-width="68px"
-    >
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="表名称" prop="tableName">
-        <el-input
-          v-model="queryParams.tableName"
-          placeholder="请输入表名称"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item label="表描述" prop="tableComment">
-        <el-input
-          v-model="queryParams.tableComment"
-          placeholder="请输入表描述"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item>
-        <el-button
-          type="primary"
-          icon="el-icon-search"
-          size="mini"
-          @click="handleQuery"
-          >搜索</el-button
-        >
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
-          >重置</el-button
-        >
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
       </el-form-item>
     </el-form>
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          >新增</el-button
-        >
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
       </el-col>
-      <right-toolbar
-        :showSearch.sync="showSearch"
-        @queryTable="getList"
-      ></right-toolbar>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
     <el-table v-loading="loading" :data="aaaList">
       <el-table-column label="表名称" align="center" prop="tableName" />
       <el-table-column label="表描述" align="center" prop="tableComment" />
       <el-table-column label="创建时间" align="center" prop="createTime" />
-      <el-table-column
-        label="操作"
-        align="center"
-        class-name="small-padding fixed-width"
-      >
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-dropdown>
             <el-button type="warning" plain size="small">
               处理<i class="el-icon-arrow-down el-icon--right"></i>
             </el-button>
             <el-dropdown-menu slot="dropdown">
-              <el-dropdown-item
-                ><el-button
-                  size="mini"
-                  type="text"
-                  icon="el-icon-delete"
-                  @click="handleDelete(scope.row)"
-                  >删除</el-button
-                ></el-dropdown-item
-              >
-              <el-dropdown-item
-                ><el-button
-                  size="mini"
-                  type="text"
-                  icon="el-icon-edit"
-                  @click="handleUpdate(scope.row)"
-                  >修改</el-button
-                >
+              <el-dropdown-item><el-button size="mini" type="text" icon="el-icon-delete"
+                  @click="handleDelete(scope.row)">删除</el-button></el-dropdown-item>
+              <el-dropdown-item><el-button size="mini" type="text" icon="el-icon-edit"
+                  @click="handleUpdate(scope.row)">修改</el-button>
               </el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
@@ -97,13 +45,8 @@
       </el-table-column>
     </el-table>
 
-    <pagination
-      v-show="total > 0"
-      :total="total"
-      :page.sync="queryParams.pageNum"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
+    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
+      @pagination="getList" />
   </div>
 </template>
 
@@ -123,6 +66,8 @@ export default {
         pageSize: 10,
         tableName: null,
         tableComment: null,
+        databaseType: this.$store.state.user.dataSource.databaseType,
+        databaseName: this.$store.state.user.dataSource.databaseName,
       },
     };
   },
@@ -155,16 +100,21 @@ export default {
     /** 删除按钮操作 */
     handleDelete(row) {
       const tableNames = row.tableName;
+      let data = {
+        tableName: row.tableName,
+        databaseType: this.$store.state.user.dataSource.databaseType,
+        databaseName: this.$store.state.user.dataSource.databaseName,
+      }
       this.$modal
         .confirm('是否确认删除"' + tableNames + '"表?')
         .then(function () {
-          return removeTable(tableNames);
+          return removeTable(data);
         })
         .then(() => {
           this.getList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => {});
+        .catch(() => { });
     },
     handleUpdate(row) {
       this.$router.push({

+ 10 - 9
ruoyi-ui/src/views/tool/datasheet/index.vue

@@ -2,9 +2,9 @@
     <div class="app-container">
         <el-card style="margin-bottom: 15px;">
             <el-form ref="form" :model="form" label-width="100px" :rules="rules">
-                <el-form-item label="数据库名称" prop="dataBaseName">
+                <!-- <el-form-item label="数据库名称" prop="dataBaseName">
                     <el-input v-model="form.dataBaseName" style="width: 600px;"></el-input>
-                </el-form-item>
+                </el-form-item> -->
                 <el-form-item label="数据表名称" prop="tableName">
                     <el-input v-model="form.tableName" style="width: 600px;"></el-input>
                 </el-form-item>
@@ -32,7 +32,7 @@
                         <template slot-scope="scope">
                             <el-form-item :prop="'fieldType' + scope.$index" :name="'fieldType' + scope.$index"
                                 style="margin: 0px;padding: 0px;">
-                                <el-select v-model="scope.row.fieldType" filterable  @blur="selectBlur(scope.row)">
+                                <el-select v-model="scope.row.fieldType" filterable @blur="selectBlur(scope.row)">
                                     <!-- <el-option v-for="item in list" :key="item" :label="item" :value="item">
                                     </el-option> -->
                                     <!-- 
@@ -53,7 +53,7 @@
                             <el-form-item :prop="'fieldLength' + scope.$index" :name="'fieldLength' + scope.$index"
                                 style="margin: 0px;padding: 0px;">
                                 <el-input v-model="scope.row.fieldLength"
-                                    :disabled="testasd(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType),scope)"></el-input>
+                                    :disabled="testasd(dict.type.mysql_data_type.find(item => item.label === scope.row.fieldType), scope)"></el-input>
                             </el-form-item>
                         </template>
                     </el-table-column>
@@ -166,13 +166,13 @@ export default {
         }
     },
     methods: {
-        testasd(tem,scope) {  
+        testasd(tem, scope) {
             if (tem == undefined) return;
             console.log(tem.raw.listClass)
-            if (tem.raw.listClass === 'success'){
-                this.$delete(this.tableform,scope.column.property+''+scope.$index);
+            if (tem.raw.listClass === 'success') {
+                this.$delete(this.tableform, scope.column.property + '' + scope.$index);
                 return true;
-            } 
+            }
             return false;
         },
         // handleSelectChange(selectedValue) {
@@ -279,7 +279,8 @@ export default {
                 })
 
                 let query = {
-                    dataBaseName: this.form.dataBaseName,
+                    databaseType: this.$store.state.user.dataSource.databaseType,
+                    databaseName: this.$store.state.user.dataSource.databaseName,
                     tableName: this.form.tableName,
                     tableComment: this.form.tableComment,
                     field: this.experienceData