top权限独立

This commit is contained in:
clay 2021-07-29 22:07:30 +08:00
parent ab4a25b524
commit aaf2f719b4
21 changed files with 189 additions and 129 deletions

View File

@ -79,3 +79,11 @@ export function delTable(id) {
method: 'delete' method: 'delete'
}) })
} }
// 获取数据库表list
export function listDbTable(data) {
return request({
url: '/tool/table/db/list',
method: 'post',
data:data
})
}

View File

@ -66,8 +66,10 @@ export default {
codeUrl: "", codeUrl: "",
cookiePassword: "", cookiePassword: "",
loginForm: { loginForm: {
username: "admin", username: "clay",
password: "HCY@2020", password: "926425",
// username: "admin",
// password: "HCY@2020",
rememberMe: false, rememberMe: false,
code: "", code: "",
uuid: "" uuid: ""

View File

@ -28,10 +28,10 @@
<el-row> <el-row>
<el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px"> <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 type="selection" width="55"></el-table-column>
<el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column> <el-table-column prop="table_name" 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="table_comment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="createTime" label="创建时间"></el-table-column> <el-table-column prop="create_time" label="创建时间"></el-table-column>
<!-- <el-table-column prop="updateTime" label="更新时间"></el-table-column>--> <!-- <el-table-column prop="update_time" label="更新时间"></el-table-column>-->
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
@ -49,8 +49,7 @@
</template> </template>
<script> <script>
import { listDbTable} from "@/api/tool/gen"; import {importTopTable,listDbTable} from '../../../api/tool/table'
import {importTopTable} from '../../../api/tool/table'
export default { export default {
data() { data() {
@ -83,7 +82,7 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.tables = selection.map(item => item.tableName); this.tables = selection.map(item => item.table_name);
}, },
// //
getList() { getList() {

View File

@ -42,16 +42,6 @@
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <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-col :span="1.5">
<el-button <el-button
type="success" type="success"
@ -81,7 +71,6 @@
icon="el-icon-upload" icon="el-icon-upload"
size="mini" size="mini"
@click="openImportTable" @click="openImportTable"
v-hasPermi="['tool:gen:import']"
>导入</el-button> >导入</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">

View File

@ -112,7 +112,7 @@
size="small" size="small"
icon="el-icon-edit-outline" icon="el-icon-edit-outline"
@click="handleEditTable(scope.row)" @click="handleEditTable(scope.row)"
v-hasPermi="['tool:query:update']" v-hasPermi="['tool:query:edit']"
>编辑</el-button> >编辑</el-button>
<el-button <el-button
size="mini" size="mini"

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,6 @@ public class RealQueryController extends BaseController {
* @param realUniQuery * @param realUniQuery
* @return * @return
*/ */
@PreAuthorize("@ebts.hasAnyPermi('data:real:export')")
@PutMapping("/real/export") @PutMapping("/real/export")
public AjaxResult exportReal(@Validated @RequestBody RealUniQuery realUniQuery) { public AjaxResult exportReal(@Validated @RequestBody RealUniQuery realUniQuery) {
ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 1); ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 1);
@ -53,7 +52,6 @@ public class RealQueryController extends BaseController {
* @param id * @param id
* @return * @return
*/ */
@PreAuthorize("@ebts.hasPermi('data:real:data')")
@GetMapping("/real/{id}") @GetMapping("/real/{id}")
public AjaxResult RealInfo(@PathVariable("id") Long id) { public AjaxResult RealInfo(@PathVariable("id") Long id) {
if (id == null) { if (id == null) {
@ -74,7 +72,6 @@ public class RealQueryController extends BaseController {
* @param realUniQuery * @param realUniQuery
* @return * @return
*/ */
@PreAuthorize("@ebts.hasAnyPermi('data:real:list')")
@PutMapping("/real") @PutMapping("/real")
public Serializable RealData(@Validated @RequestBody RealUniQuery realUniQuery) { public Serializable RealData(@Validated @RequestBody RealUniQuery realUniQuery) {
ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 2); ServerResult<List<Map<String, Object>>> serverResult = realQueryService.RealData(realUniQuery, 2);

View File

@ -39,7 +39,7 @@ public class QueryController extends BaseController {
private QueryService queryService; private QueryService queryService;
/** /**
* 获取编辑sql的基本信息 * todo 获取编辑sql的基本信息
* *
* @param id * @param id
* @return * @return

View File

@ -31,9 +31,6 @@ import java.util.Map;
@RequestMapping("/top") @RequestMapping("/top")
public class TopQueryController extends BaseController { public class TopQueryController extends BaseController {
@Autowired
private TopSearchTableService topSearchTableService;
@Autowired @Autowired
private UniQueryService uniQueryService; private UniQueryService uniQueryService;

View File

@ -1,12 +1,15 @@
package com.ebts.generator.controller; package com.ebts.generator.controller;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ebts.common.core.controller.EBTSController; import com.ebts.common.core.controller.EBTSController;
import com.ebts.common.core.text.Convert; import com.ebts.common.core.text.Convert;
import com.ebts.common.utils.ServerResult; import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.GenTable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -122,6 +125,9 @@ public class TopSearchTableController extends EBTSController {
@Log(title = "top万能查询主", businessType = BusinessType.UPDATE) @Log(title = "top万能查询主", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody TopSearchTable topSearchTable) { public AjaxResult edit(@Validated @RequestBody TopSearchTable topSearchTable) {
if (topSearchTable.getRoleIds().length==0){
return AjaxResult.error("角色不能为空!");
}
ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable); ServerResult<Integer> genServerResult = topSearchTableService.updateTopSearchTable(topSearchTable);
if (genServerResult.isStart()) { if (genServerResult.isStart()) {
return AjaxResult.success(); 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) @Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTopTable") @PostMapping("/importTopTable")
public AjaxResult importTableSave(String tables) { public AjaxResult importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables); String[] tableNames = Convert.toStrArray(tables);
// 查询表信息 // 查询表信息
List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames); List<TopSearchTable> tableList = topSearchTableService.selectDbTableListByNames(tableNames);
topSearchTableService.importGenTable(tableList); topSearchTableService.importGenTable(tableList);
return AjaxResult.success(); 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);
}
} }

View File

@ -25,6 +25,7 @@ public interface SearchTableRoleDao {
* @return 结果 * @return 结果
*/ */
int deleteSearchTableRoleById(Long searchTableId); int deleteSearchTableRoleById(Long searchTableId);
int deleteSearchTableRoleByIds(Long[] searchTableIds);
/** /**
* 批量添加top万能查询角色关系 * 批量添加top万能查询角色关系

View File

@ -1,6 +1,9 @@
package com.ebts.generator.dao; package com.ebts.generator.dao;
import java.util.List; 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.TopSearchTable;
import com.ebts.generator.entity.TopSearchColumn; import com.ebts.generator.entity.TopSearchColumn;
@ -45,6 +48,14 @@ public interface TopSearchTableDao {
*/ */
List<TopSearchTable> selectDbTableListByNames(String[] tableNames); List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
/**
* 获取数据库表信息
*
* @param params 表名称组
* @return 数据库表集合
*/
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
/** /**
* 根据表名查询列 * 根据表名查询列
* @param tableName * @param tableName

View File

@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
/** /**
* top万能查询主对象 gen_top_search_table * top万能查询主对象 gen_top_search_table
* *

View File

@ -1,6 +1,7 @@
package com.ebts.generator.service; package com.ebts.generator.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ebts.common.utils.ServerResult; import com.ebts.common.utils.ServerResult;
import com.ebts.generator.entity.TopSearchColumn; import com.ebts.generator.entity.TopSearchColumn;
@ -54,6 +55,8 @@ public interface TopSearchTableService {
List<TopSearchTable> selectDbTableListByNames(String[] tableNames); List<TopSearchTable> selectDbTableListByNames(String[] tableNames);
List<Map<String,Object>> selectDbTableList(Map<String,Object> params);
void importGenTable(List<TopSearchTable> tableList); void importGenTable(List<TopSearchTable> tableList);
/** /**

View File

@ -5,9 +5,6 @@ import java.util.List;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.exception.EbtsException; import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.SecurityUtils; 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.common.utils.ServerResult;
import com.ebts.generator.dao.RelationalMapDao; import com.ebts.generator.dao.RelationalMapDao;
import com.ebts.generator.dao.SearchTableRoleDao; import com.ebts.generator.dao.SearchTableRoleDao;
@ -17,7 +14,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import com.ebts.common.utils.StringUtils; import com.ebts.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.ebts.generator.entity.TopSearchColumn; import com.ebts.generator.entity.TopSearchColumn;
@ -155,13 +155,13 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
for (RelationalMap relationalMap : relationalMapList) { for (RelationalMap relationalMap : relationalMapList) {
relationalMap.setMainId(topSearchTable.getId()); relationalMap.setMainId(topSearchTable.getId());
} }
boolean renewalMap = insertRelationalMap(relationalMapList); insertRelationalMap(relationalMapList);
searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId()); searchTableRoleDao.deleteSearchTableRoleById(topSearchTable.getId());
boolean renewalRole = inserTopTableRole(searchTableRoles); boolean renewalRole = inserTopTableRole(searchTableRoles);
Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable); Integer renewal = topSearchTableDao.updateTopSearchTable(topSearchTable);
if (renewal >0 && renewalRole && renewalMap){ if (renewal > 0 && renewalRole) {
return new ServerResult<>(true, renewal); return new ServerResult<>(true, renewal);
} else { } else {
return new ServerResult<>(false, ReturnConstants.OP_ERROR); return new ServerResult<>(false, ReturnConstants.OP_ERROR);
@ -172,6 +172,13 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
throw new EbtsException(ReturnConstants.OP_ERROR, e); throw new EbtsException(ReturnConstants.OP_ERROR, e);
} }
} }
// void deleteSearchTableRoleById(Long id){
// try {
//
// }catch (RuntimeException e){
// logger.error("无数据");
// }
// }
@Override @Override
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) { 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void importGenTable(List<TopSearchTable> tableList) { public void importGenTable(List<TopSearchTable> tableList) {
@ -221,6 +238,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
try { try {
//批量删除子表数据 //批量删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids); topSearchTableDao.deleteTopSearchColumnBySearchTableIds(ids);
searchTableRoleDao.deleteSearchTableRoleByIds(ids);
Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids); Integer renewal = topSearchTableDao.deleteTopSearchTableByIds(ids);
if (renewal > 0) { if (renewal > 0) {
return new ServerResult<>(true, renewal); return new ServerResult<>(true, renewal);
@ -255,6 +273,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
throw new EbtsException(ReturnConstants.OP_ERROR, e); throw new EbtsException(ReturnConstants.OP_ERROR, e);
} }
} }
public boolean inserTopTableRole(List<SearchTableRole> roleList) { public boolean inserTopTableRole(List<SearchTableRole> roleList) {
if (StringUtils.isNotNull(roleList)) { if (StringUtils.isNotNull(roleList)) {
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList); Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
@ -264,8 +283,9 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
} }
return false; return false;
} }
public boolean insertRelationalMap(List<RelationalMap> relationalMaps) { public boolean insertRelationalMap(List<RelationalMap> relationalMaps) {
if (StringUtils.isNotNull(relationalMaps)){ if (StringUtils.isNotNull(relationalMaps) && relationalMaps.size() > 0) {
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps); Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
if (renewal > 0) { if (renewal > 0) {
return true; return true;

View File

@ -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 select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database()) where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'qrtz_%'
AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table) AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''"> <if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{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 id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' where table_name NOT LIKE 'qrtz_%'
AND table_name NOT LIKE 'gen_%'
AND table_schema = (select database()) AND table_schema = (select database())
AND table_name in AND table_name in
<foreach collection="array" item="name" open="(" separator="," close=")"> <foreach collection="array" item="name" open="(" separator="," close=")">

View File

@ -27,7 +27,7 @@
<result property="ucType" column="uc_type" /> <result property="ucType" column="uc_type" />
<result property="type" column="type" /> <result property="type" column="type" />
</resultMap> </resultMap>
<select id="UniQuery" resultType="java.util.HashMap"> <select id="UniQuery" resultType="java.util.Map">
${paramSQL} ${paramSQL}
</select> </select>
<delete id="deleteMenu"> <delete id="deleteMenu">

View File

@ -39,12 +39,7 @@
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
</resultMap> </resultMap>
<select id="tableInfos" resultType="java.util.Map">
<select id="tableInfos" resultType="java.util.HashMap">
select table_name, table_comment select table_name, table_comment
from information_schema.tables from information_schema.tables
where table_schema = (select database()) where table_schema = (select database())

View File

@ -87,9 +87,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join gen_relational_mapping grm on grm.main_id = gtst.id left join gen_relational_mapping grm on grm.main_id = gtst.id
</select> </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') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
</select>
<select id="selectDbTableListByNames" resultMap="TopSearchTableResult"> <select id="selectDbTableListByNames" resultMap="TopSearchTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables 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 and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")"> <foreach collection="array" item="name" open="(" separator="," close=")">
#{name} #{name}

View File

@ -527,10 +527,11 @@ export default {
#foreach($column in $table.relColumns) #foreach($column in $table.relColumns)
#if($column.isQuery == '1' && $column.htmlType != "datetime" && $column.queryType != "BETWEEN") #if($column.isQuery == '1' && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
${column.javaField}: null#if($velocityCount != $columns.size()),#end ${column.javaField}: null#if($velocityCount != $columns.size()),#end
#end
#end
#end
#end
params:{}, params:{},
},
#if($velocityCount != $relTables.size()),#end #if($velocityCount != $relTables.size()),#end
#end #end
#end #end

View File

@ -40,7 +40,7 @@
where id = #{id} where id = #{id}
</select> </select>
<select id="realUniQuery" resultType="java.util.HashMap"> <select id="realUniQuery" resultType="java.util.Map">
${paramSQL} ${paramSQL}
</select> </select>
</mapper> </mapper>