top权限独立
This commit is contained in:
parent
ab4a25b524
commit
aaf2f719b4
|
|
@ -79,3 +79,11 @@ export function delTable(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
// 获取数据库表list
|
||||
export function listDbTable(data) {
|
||||
return request({
|
||||
url: '/tool/table/db/list',
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,10 @@ export default {
|
|||
codeUrl: "",
|
||||
cookiePassword: "",
|
||||
loginForm: {
|
||||
username: "admin",
|
||||
password: "HCY@2020",
|
||||
username: "clay",
|
||||
password: "926425",
|
||||
// username: "admin",
|
||||
// password: "HCY@2020",
|
||||
rememberMe: false,
|
||||
code: "",
|
||||
uuid: ""
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
<el-row>
|
||||
<el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间"></el-table-column>
|
||||
<!-- <el-table-column prop="updateTime" label="更新时间"></el-table-column>-->
|
||||
<el-table-column prop="table_name" label="表名称" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="table_comment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="create_time" label="创建时间"></el-table-column>
|
||||
<!-- <el-table-column prop="update_time" label="更新时间"></el-table-column>-->
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
|
|
@ -49,8 +49,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { listDbTable} from "@/api/tool/gen";
|
||||
import {importTopTable} from '../../../api/tool/table'
|
||||
import {importTopTable,listDbTable} from '../../../api/tool/table'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -83,7 +82,7 @@ export default {
|
|||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.tables = selection.map(item => item.tableName);
|
||||
this.tables = selection.map(item => item.table_name);
|
||||
},
|
||||
// 查询表数据
|
||||
getList() {
|
||||
|
|
|
|||
|
|
@ -42,16 +42,6 @@
|
|||
</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"
|
||||
v-hasPermi="['tool:table:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
|
|
@ -81,7 +71,6 @@
|
|||
icon="el-icon-upload"
|
||||
size="mini"
|
||||
@click="openImportTable"
|
||||
v-hasPermi="['tool:gen:import']"
|
||||
>导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@
|
|||
size="small"
|
||||
icon="el-icon-edit-outline"
|
||||
@click="handleEditTable(scope.row)"
|
||||
v-hasPermi="['tool:query:update']"
|
||||
v-hasPermi="['tool:query:edit']"
|
||||
>编辑</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -36,7 +36,6 @@ public class RealQueryController extends BaseController {
|
|||
* @param realUniQuery
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasAnyPermi('data:real:export')")
|
||||
@PutMapping("/real/export")
|
||||
public AjaxResult exportReal(@Validated @RequestBody RealUniQuery realUniQuery) {
|
||||
ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 1);
|
||||
|
|
@ -53,7 +52,6 @@ public class RealQueryController extends BaseController {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasPermi('data:real:data')")
|
||||
@GetMapping("/real/{id}")
|
||||
public AjaxResult RealInfo(@PathVariable("id") Long id) {
|
||||
if (id == null) {
|
||||
|
|
@ -74,7 +72,6 @@ public class RealQueryController extends BaseController {
|
|||
* @param realUniQuery
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasAnyPermi('data:real:list')")
|
||||
@PutMapping("/real")
|
||||
public Serializable RealData(@Validated @RequestBody RealUniQuery realUniQuery) {
|
||||
ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 2);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class QueryController extends BaseController {
|
|||
private QueryService queryService;
|
||||
|
||||
/**
|
||||
* 获取编辑sql的基本信息
|
||||
* todo 获取编辑sql的基本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ import java.util.Map;
|
|||
@RequestMapping("/top")
|
||||
public class TopQueryController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private TopSearchTableService topSearchTableService;
|
||||
|
||||
@Autowired
|
||||
private UniQueryService uniQueryService;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
package com.ebts.generator.controller;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import com.ebts.common.core.controller.EBTSController;
|
||||
import com.ebts.common.core.text.Convert;
|
||||
import com.ebts.common.utils.ServerResult;
|
||||
import com.ebts.generator.entity.GenTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
|
@ -122,6 +125,9 @@ public class TopSearchTableController extends EBTSController {
|
|||
@Log(title = "top万能查询主", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody TopSearchTable topSearchTable) {
|
||||
if (topSearchTable.getRoleIds().length==0){
|
||||
return AjaxResult.error("角色不能为空!");
|
||||
}
|
||||
ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable);
|
||||
if (genServerResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
|
|
@ -150,15 +156,29 @@ public class TopSearchTableController extends EBTSController {
|
|||
/**
|
||||
* 导入表结构(保存)
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasPermi('tool:gen:list')")
|
||||
@PreAuthorize("@ebts.hasPermi('tool:table:import')")
|
||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importTopTable")
|
||||
public AjaxResult importTableSave(String tables) {
|
||||
String[] tableNames = Convert.toStrArray(tables);
|
||||
// 查询表信息
|
||||
|
||||
List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames);
|
||||
topSearchTableService.importGenTable(tableList);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入表结构(获取)
|
||||
*/
|
||||
@PreAuthorize("@ebts.hasPermi('tool:table:db:list')")
|
||||
@PostMapping("/db/list")
|
||||
public Serializable dbList(@RequestBody Map<String,Object> params){
|
||||
startPage(params);
|
||||
List<Map<String,Object>> list = topSearchTableService.selectDbTableList(params);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public interface SearchTableRoleDao {
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteSearchTableRoleById(Long searchTableId);
|
||||
int deleteSearchTableRoleByIds(Long[] searchTableIds);
|
||||
|
||||
/**
|
||||
* 批量添加top万能查询角色关系
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.ebts.generator.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ebts.generator.entity.GenTable;
|
||||
import com.ebts.generator.entity.TopSearchTable;
|
||||
import com.ebts.generator.entity.TopSearchColumn;
|
||||
|
||||
|
|
@ -45,6 +48,14 @@ public interface TopSearchTableDao {
|
|||
*/
|
||||
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据库表信息
|
||||
*
|
||||
* @param params 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
|
||||
/**
|
||||
* 根据表名查询列
|
||||
* @param tableName
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* top万能查询主对象 gen_top_search_table
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ebts.generator.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ebts.common.utils.ServerResult;
|
||||
import com.ebts.generator.entity.TopSearchColumn;
|
||||
|
|
@ -54,6 +55,8 @@ public interface TopSearchTableService {
|
|||
|
||||
List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
|
||||
|
||||
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
|
||||
|
||||
void importGenTable(List<TopSearchTable> tableList);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ import java.util.List;
|
|||
import com.ebts.common.constant.ReturnConstants;
|
||||
import com.ebts.common.exception.EbtsException;
|
||||
import com.ebts.common.utils.SecurityUtils;
|
||||
import com.ebts.common.utils.DateUtils;
|
||||
import com.ebts.common.utils.SecurityUtils;
|
||||
import com.ebts.common.utils.DateUtils;
|
||||
import com.ebts.common.utils.ServerResult;
|
||||
import com.ebts.generator.dao.RelationalMapDao;
|
||||
import com.ebts.generator.dao.SearchTableRoleDao;
|
||||
|
|
@ -17,7 +14,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ebts.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ebts.generator.entity.TopSearchColumn;
|
||||
|
|
@ -155,13 +155,13 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
for (RelationalMap relationalMap : relationalMapList) {
|
||||
relationalMap.setMainId(topSearchTable.getId());
|
||||
}
|
||||
boolean renewalMap = insertRelationalMap(relationalMapList);
|
||||
insertRelationalMap(relationalMapList);
|
||||
|
||||
|
||||
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
|
||||
boolean renewalRole = inserTopTableRole(searchTableRoles);
|
||||
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
|
||||
if (renewal >0 && renewalRole && renewalMap){
|
||||
if (renewal > 0 && renewalRole) {
|
||||
return new ServerResult<>(true, renewal);
|
||||
} else {
|
||||
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
|
||||
|
|
@ -172,6 +172,13 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
||||
}
|
||||
}
|
||||
// void deleteSearchTableRoleById(Long id){
|
||||
// try {
|
||||
//
|
||||
// }catch (RuntimeException e){
|
||||
// logger.error("无数据");
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) {
|
||||
|
|
@ -183,6 +190,16 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> selectDbTableList(Map<String, Object> params) {
|
||||
try {
|
||||
return topSearchTableDao.selectDbTableList(params);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importGenTable(List<TopSearchTable> tableList) {
|
||||
|
|
@ -221,6 +238,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
try {
|
||||
//批量删除子表数据
|
||||
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
|
||||
searchTableRoleDao.deleteSearchTableRoleByIds(ids);
|
||||
Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids);
|
||||
if (renewal > 0) {
|
||||
return new ServerResult<>(true, renewal);
|
||||
|
|
@ -255,6 +273,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
throw new EbtsException(ReturnConstants.OP_ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inserTopTableRole(List<SearchTableRole> roleList) {
|
||||
if (StringUtils.isNotNull(roleList)) {
|
||||
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
|
||||
|
|
@ -264,8 +283,9 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean insertRelationalMap(List<RelationalMap> relationalMaps) {
|
||||
if (StringUtils.isNotNull(relationalMaps)){
|
||||
if (StringUtils.isNotNull(relationalMaps) && relationalMaps.size() > 0) {
|
||||
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
|
||||
if (renewal > 0) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'qrtz_%'
|
||||
|
||||
AND table_name NOT LIKE 'gen_%'
|
||||
AND table_name NOT IN (select table_name from gen_table)
|
||||
<if test="tableName != null and tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||
|
|
@ -105,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_name NOT LIKE 'qrtz_%'
|
||||
|
||||
AND table_name NOT LIKE 'gen_%'
|
||||
AND table_schema = (select database())
|
||||
AND table_name in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<result property="ucType" column="uc_type" />
|
||||
<result property="type" column="type" />
|
||||
</resultMap>
|
||||
<select id="UniQuery" resultType="java.util.HashMap">
|
||||
<select id="UniQuery" resultType="java.util.Map">
|
||||
${paramSQL}
|
||||
</select>
|
||||
<delete id="deleteMenu">
|
||||
|
|
|
|||
|
|
@ -39,12 +39,7 @@
|
|||
<result property="createBy" column="create_by"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<select id="tableInfos" resultType="java.util.HashMap">
|
||||
<select id="tableInfos" resultType="java.util.Map">
|
||||
select table_name, table_comment
|
||||
from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
|
|
|
|||
|
|
@ -87,9 +87,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join gen_relational_mapping grm on grm.main_id = gtst.id
|
||||
</select>
|
||||
|
||||
<!--AND table_name NOT LIKE 'gen_%'-->
|
||||
<select id="selectDbTableList" resultType="java.util.Map">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'qrtz_%'
|
||||
AND table_name NOT LIKE 'gen_%'
|
||||
AND table_name NOT IN (select table_name from gen_top_search_table)
|
||||
<if test="tableName != null and tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||
</if>
|
||||
<if test="tableComment != null and tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectDbTableListByNames" resultMap="TopSearchTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
|
||||
where table_name NOT LIKE 'qrtz_%'
|
||||
and table_name NOT LIKE 'gen_%'
|
||||
and table_schema = (select database())
|
||||
and table_name in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
|
|
|
|||
|
|
@ -527,10 +527,11 @@ export default {
|
|||
#foreach($column in $table.relColumns)
|
||||
#if($column.isQuery == '1' && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
||||
${column.javaField}: null#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
params:{},
|
||||
},
|
||||
#if($velocityCount != $relTables.size()),#end
|
||||
#end
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="realUniQuery" resultType="java.util.HashMap">
|
||||
<select id="realUniQuery" resultType="java.util.Map">
|
||||
${paramSQL}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue