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'
})
}
// 获取数据库表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: "",
cookiePassword: "",
loginForm: {
username: "admin",
password: "HCY@2020",
username: "clay",
password: "926425",
// username: "admin",
// password: "HCY@2020",
rememberMe: false,
code: "",
uuid: ""

View File

@ -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() {

View File

@ -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">

View File

@ -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

View File

@ -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);

View File

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

View File

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

View File

@ -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);
}
}

View File

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

View File

@ -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

View File

@ -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
*

View File

@ -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);
/**

View File

@ -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;
@ -52,20 +52,20 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
public ServerResult<TopSearchTable> selectTopSearchTableById(Long id) {
try {
TopSearchTable topSearchTable = topSearchTableDao.selectTopSearchTableById(id);
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole(id,null));
Long[] roles = new Long[roleList.size()] ;
List<SearchTableRole> roleList = searchTableRoleDao.selectSearchTableRoleList(new SearchTableRole(id, null));
Long[] roles = new Long[roleList.size()];
for (int i = 0; i < roleList.size(); i++) {
roles[i] = roleList.get(i).getRoleId();
}
topSearchTable.setRoleIds(roles);
if (topSearchTable != null){
return new ServerResult<>(true,topSearchTable);
}else {
if (topSearchTable != null) {
return new ServerResult<>(true, topSearchTable);
} else {
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@ -79,14 +79,14 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
public ServerResult<List<TopSearchTable>> selectTopSearchTableList(TopSearchTable topSearchTable) {
try {
List<TopSearchTable> topSearchTableList = topSearchTableDao.selectTopSearchTableList(topSearchTable);
if (topSearchTableList.size()>0){
return new ServerResult<>(true,topSearchTableList);
}else {
return new ServerResult<>(false,ReturnConstants.RESULT_EMPTY);
if (topSearchTableList.size() > 0) {
return new ServerResult<>(true, topSearchTableList);
} else {
return new ServerResult<>(false, ReturnConstants.RESULT_EMPTY);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@ -94,14 +94,14 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
public ServerResult<List<TopSearchTable>> selectTopSearchTableInfo() {
try {
List<TopSearchTable> tableList = topSearchTableDao.selectTopSearchTableInfo();
return new ServerResult<>(true,tableList);
}catch (RuntimeException e){
return new ServerResult<>(true, tableList);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
public List<TopSearchColumn> selectTableColumns(Long id){
public List<TopSearchColumn> selectTableColumns(Long id) {
return topSearchTableDao.selectTableColumns(id);
}
@ -117,17 +117,17 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
try {
topSearchTable.setCreateBy(SecurityUtils.getUserId());
int renewal = topSearchTableDao.insertTopSearchTable(topSearchTable);
if (insertTopSearchColumn(topSearchTable)){
return new ServerResult<>(false,ReturnConstants.DB_EX);
if (insertTopSearchColumn(topSearchTable)) {
return new ServerResult<>(false, ReturnConstants.DB_EX);
}
if (renewal >0){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@ -143,35 +143,42 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
try {
topSearchTable.setUpdateBy(SecurityUtils.getUserId());
topSearchTableDao.deleteTopSearchColumnBySearchTableId(topSearchTable.getId());
if (insertTopSearchColumn(topSearchTable)){
return new ServerResult<>(false,ReturnConstants.DB_EX);
if (insertTopSearchColumn(topSearchTable)) {
return new ServerResult<>(false, ReturnConstants.DB_EX);
}
List<SearchTableRole> searchTableRoles = new ArrayList<>();
for (Long roleId : topSearchTable.getRoleIds()) {
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(),roleId));
searchTableRoles.add(new SearchTableRole(topSearchTable.getId(), roleId));
}
relationalMapDao.deleteRelationalMapById(topSearchTable.getId());
List<RelationalMap> relationalMapList = topSearchTable.getRelationalMapList();
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){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.OP_ERROR);
if (renewal > 0 && renewalRole) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.OP_ERROR);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
e.printStackTrace();
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
public List<TopSearchTable> selectDbTableListByNames(String[] tableNames) {
@ -179,7 +186,17 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
return topSearchTableDao.selectDbTableListByNames(tableNames);
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@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);
}
}
@ -192,7 +209,7 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
String tableName = table.getTableName();
table.setCreateBy(createBy);
int row = topSearchTableDao.insertTopSearchTable(table);
if (row>0){
if (row > 0) {
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
for (TopSearchColumn searchColumn : searchColumns) {
searchColumn.setSearchTableId(table.getId());
@ -202,9 +219,9 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
}
}
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException("导入失败:" + e.getMessage(),e);
throw new EbtsException("导入失败:" + e.getMessage(), e);
}
}
@ -221,15 +238,16 @@ 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);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
@ -245,29 +263,31 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
//删除子表数据
topSearchTableDao.deleteTopSearchColumnBySearchTableId(id);
Integer renewal = topSearchTableDao.deleteTopSearchTableById(id);
if (renewal >0){
return new ServerResult<>(true,renewal);
}else {
return new ServerResult<>(false,ReturnConstants.SYS_FAILL);
if (renewal > 0) {
return new ServerResult<>(true, renewal);
} else {
return new ServerResult<>(false, ReturnConstants.SYS_FAILL);
}
}catch (RuntimeException e){
} catch (RuntimeException e) {
logger.error(e.getMessage());
throw new EbtsException(ReturnConstants.OP_ERROR,e);
throw new EbtsException(ReturnConstants.OP_ERROR, e);
}
}
public boolean inserTopTableRole(List<SearchTableRole> roleList){
if (StringUtils.isNotNull(roleList)){
public boolean inserTopTableRole(List<SearchTableRole> roleList) {
if (StringUtils.isNotNull(roleList)) {
Integer renewal = searchTableRoleDao.batchSearchTableRole(roleList);
if (renewal>0){
if (renewal > 0) {
return true;
}
}
return false;
}
public boolean insertRelationalMap(List<RelationalMap> relationalMaps){
if (StringUtils.isNotNull(relationalMaps)){
public boolean insertRelationalMap(List<RelationalMap> relationalMaps) {
if (StringUtils.isNotNull(relationalMaps) && relationalMaps.size() > 0) {
Integer renewal = relationalMapDao.batchRelationalMap(relationalMaps);
if (renewal>0){
if (renewal > 0) {
return true;
}
}
@ -284,13 +304,13 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
Long id = topSearchTable.getId();
if (StringUtils.isNotNull(topSearchColumnList)) {
List<TopSearchColumn> list = new ArrayList<TopSearchColumn>();
for (TopSearchColumn topSearchColumn : topSearchColumnList){
for (TopSearchColumn topSearchColumn : topSearchColumnList) {
topSearchColumn.setSearchTableId(id);
list.add(topSearchColumn);
}
if (list.size() > 0) {
Integer renewal = topSearchTableDao.batchTopSearchColumn(list);
if (renewal>0){
if (renewal > 0) {
return false;
}
}

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
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=")">

View File

@ -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">

View File

@ -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())

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
</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 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}

View File

@ -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

View File

@ -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>