提交 cc936577 编写于 作者: doc_wei's avatar doc_wei

数据库数据字典

上级 9b328116
package com.skyeye.authority.dao;
import java.util.List;
import java.util.Map;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
public interface SysDataBaseDao {
public List<Map<String, Object>> querySysDataBaseList(Map<String, Object> map, PageBounds pageBounds) throws Exception;
public List<Map<String, Object>> querySysDataBaseSelectList(Map<String, Object> map) throws Exception;
public List<Map<String, Object>> querySysDataBaseDescSelectList(Map<String, Object> map) throws Exception;
}
package com.skyeye.authority.service;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
public interface SysDataBaseService {
public void querySysDataBaseList(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySysDataBaseSelectList(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySysDataBaseDescSelectList(InputObject inputObject, OutputObject outputObject) throws Exception;
}
package com.skyeye.authority.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.skyeye.authority.dao.SysDataBaseDao;
import com.skyeye.authority.service.SysDataBaseService;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
@Service
public class SysDataBaseServiceImpl implements SysDataBaseService{
@Autowired
private SysDataBaseDao sysDataBaseDao;
@Value("${jdbc.database.name}")
private String dbName;
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void querySysDataBaseList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
map.put("dbName", dbName);
List<Map<String, Object>> beans = sysDataBaseDao.querySysDataBaseList(map,
new PageBounds(Integer.parseInt(map.get("page").toString()), Integer.parseInt(map.get("limit").toString())));
PageList<Map<String, Object>> beansPageList = (PageList<Map<String, Object>>)beans;
int total = beansPageList.getPaginator().getTotalCount();
outputObject.setBeans(beans);
outputObject.settotal(total);
}
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库表名信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void querySysDataBaseSelectList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
map.put("dbName", dbName);
List<Map<String, Object>> beans = sysDataBaseDao.querySysDataBaseSelectList(map);
outputObject.setBeans(beans);
if(!beans.isEmpty()){
outputObject.settotal(beans.size());
}
}
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库表备注信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
public void querySysDataBaseDescSelectList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
map.put("dbName", dbName);
List<Map<String, Object>> beans = sysDataBaseDao.querySysDataBaseDescSelectList(map);
outputObject.setBeans(beans);
if(!beans.isEmpty()){
outputObject.settotal(beans.size());
}
}
}
package com.skyeye.authority.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.skyeye.authority.service.SysDataBaseService;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
@Controller
public class SysDataBaseController {
@Autowired
private SysDataBaseService sysDataBaseService;
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysDataBaseController/querySysDataBaseList")
@ResponseBody
public void querySysDataBaseList(InputObject inputObject, OutputObject outputObject) throws Exception{
sysDataBaseService.querySysDataBaseList(inputObject, outputObject);
}
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库表名信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysDataBaseController/querySysDataBaseSelectList")
@ResponseBody
public void querySysDataBaseSelectList(InputObject inputObject, OutputObject outputObject) throws Exception{
sysDataBaseService.querySysDataBaseSelectList(inputObject, outputObject);
}
/**
*
* @Title: querySysDataBaseList
* @Description: 获取数据库表备注信息
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/SysDataBaseController/querySysDataBaseDescSelectList")
@ResponseBody
public void querySysDataBaseDescSelectList(InputObject inputObject, OutputObject outputObject) throws Exception{
sysDataBaseService.querySysDataBaseDescSelectList(inputObject, outputObject);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.skyeye.authority.dao.SysDataBaseDao">
<select id="querySysDataBaseList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.TABLE_SCHEMA AS tableSchema,
a.TABLE_NAME AS tableName,
a.COLUMN_NAME AS columnName,
a.ORDINAL_POSITION AS ordinalPosition,
a.COLUMN_DEFAULT AS columnDefault,
a.IS_NULLABLE AS isNullable,
a.COLUMN_TYPE AS columnType,
a.COLUMN_COMMENT AS columnComment,
a.COLUMN_KEY AS columnKey,
a.EXTRA AS extra,
b.TABLE_COMMENT AS tableComment
FROM
information_schema.COLUMNS a
LEFT JOIN information_schema.TABLES b ON a.TABLE_NAME = b.TABLE_NAME
WHERE
a.TABLE_SCHEMA = #{dbName}
<if test="tableDesc != '' and tableDesc != null">
AND b.TABLE_COMMENT = #{tableDesc}
</if>
<if test="tableName != '' and tableName != null">
AND a.TABLE_NAME = #{tableName}
</if>
ORDER BY
b.TABLE_NAME
</select>
<select id="querySysDataBaseSelectList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.TABLE_NAME AS id,
a.TABLE_NAME AS name
FROM
information_schema.COLUMNS a
WHERE
a.TABLE_SCHEMA = #{dbName}
GROUP BY
a.TABLE_NAME
</select>
<select id="querySysDataBaseDescSelectList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
b.TABLE_COMMENT AS id,
b.TABLE_COMMENT AS name
FROM
information_schema. COLUMNS a
LEFT JOIN information_schema. TABLES b ON a.TABLE_NAME = b.TABLE_NAME
WHERE
a.TABLE_SCHEMA = #{dbName}
AND b.TABLE_COMMENT IS NOT NULL
AND b.TABLE_COMMENT != ''
GROUP BY b.TABLE_COMMENT
</select>
</mapper>
\ No newline at end of file
......@@ -106,4 +106,17 @@
<property id="roleIds" name="roleIds" ref="required" var="角色ID串" />
</url>
<url id="database001" path="/post/SysDataBaseController/querySysDataBaseList" val="获取数据库信息">
<property id="limit" name="limit" ref="required" var="分页参数,每页多少条数据" />
<property id="page" name="page" ref="required" var="分页参数,第几页"/>
<property id="tableName" name="tableName" ref="" var="表名"/>
<property id="tableDesc" name="tableDesc" ref="" var="表备注"/>
</url>
<url id="database002" path="/post/SysDataBaseController/querySysDataBaseSelectList" val="获取数据库表名信息">
</url>
<url id="database003" path="/post/SysDataBaseController/querySysDataBaseDescSelectList" val="获取数据库表备注信息">
</url>
</controller>
\ No newline at end of file
......@@ -8,4 +8,8 @@ jdbc.maxActive=10
jdbc.minIdle=5
jdbc.poolPreparedStatements=true
jdbc.maxWait=60000
jdbc.maxPoolPreparedStatementPerConnectionSize=33
\ No newline at end of file
jdbc.maxPoolPreparedStatementPerConnectionSize=33
#数据库名称
jdbc.database.name=eve
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['table', 'jquery', 'winui', 'form'], function (exports) {
winui.renderColor();
var $ = layui.$,
form = layui.form,
table = layui.table;
//搜索表单
form.render();
form.on('submit(formSearch)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
loadTable();
}
return false;
});
initLoadTable();
function initLoadTable(){
//表格渲染
table.render({
id: 'messageTable',
elem: '#messageTable',
method: 'post',
url: reqBasePath + 'database001',
where:{tableName:$("#tableName").val(), tableDesc:$("#tableDesc").val()},
even:true, //隔行变色
page: true,
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
cols: [[
{ title: '序号', type: 'numbers'},
{ field: 'tableName', title: '表名', width: 180 },
{ field: 'tableComment', title: '表备注', width: 180 },
{ field: 'columnName', title: '字段名', width: 180 },
{ field: 'ordinalPosition', title: '字段顺序', width: 120 },
{ field: 'columnType', title: '数据类型', width: 120 },
{ field: 'columnDefault', title: '字段默认值', width: 120 },
{ field: 'isNullable', title: '允许非空', width: 180 },
{ field: 'extra', title: '其他选项', width: 180 },
{ field: 'columnKey', title: '主键约束', width: 180 },
{ field: 'columnComment', title: '备注', width: 180 }
]]
});
showGrid({
id: "tableName",
url: reqBasePath + "database002",
params: {},
pagination: false,
template: getFileContent('tpl/template/select-option.tpl'),
ajaxSendLoadBefore: function(hdb){
},
ajaxSendAfter:function(json){
showGrid({
id: "tableDesc",
url: reqBasePath + "database003",
params: {},
pagination: false,
template: getFileContent('tpl/template/select-option.tpl'),
ajaxSendLoadBefore: function(hdb){
},
ajaxSendAfter:function(json){
form.render('select');
}
});
}
});
}
//刷新数据
$("body").on("click", "#reloadTable", function(){
loadTable();
});
function loadTable(){
table.reload("messageTable", {where:{tableName:$("#tableName").val(), tableDesc:$("#tableDesc").val()}});
}
exports('sysdatabaselist', {});
});
......@@ -71,7 +71,7 @@ layui.config({
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
cols: [[
{ field: 'id', type: 'checkbox' },
{ title: '序号', type: 'numbers'},
{ field: 'menuName', title: '菜单名称', width: 120 },
{ field: 'menuIcon', title: '图标码', width: 120 },
{ field: 'titleName', title: '标题名称', width: 120 },
......
......@@ -22,7 +22,7 @@ layui.config({
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
cols: [[
{ field: 'id', type: 'checkbox' },
{ title: '序号', type: 'numbers'},
{ field: 'roleName', title: '角色名称', width: 120 },
{ field: 'roleDesc', title: '角色描述', width: 520 },
{ field: 'parentName', title: '父角色', width: 150 },
......
......@@ -22,7 +22,7 @@ layui.config({
limits: [8, 16, 24, 32, 40, 48, 56],
limit: 8,
cols: [[
{ field: 'id', type: 'checkbox' },
{ title: '序号', type: 'numbers'},
{ field: 'userCode', title: '账号', width: 120 },
{ field: 'pwdNumEnc', title: '加密次数', width: 120 },
{ field: 'userName', title: '用户名', width: 120 },
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
<link href="../../assets/lib/layui/lay/modules/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
<link href="../../assets/lib/layui/lay/modules/contextMenu/jquery.contextMenu.min.css" rel="stylesheet" />
</head>
<body>
<div class="txtcenter" style="width:700px;margin:0 auto;padding-top:20px;">
<form class="layui-form layui-form-pane" action="" autocomplete="off">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">表名</label>
<div class="layui-input-inline">
<select id="tableName" name="tableName"></select>
</div>
<label class="layui-form-label">表备注</label>
<div class="layui-input-inline">
<select id="tableDesc" name="tableDesc"></select>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block" style="margin:0;">
<button class="layui-btn" lay-submit lay-filter="formSearch">搜索</button>
</div>
</div>
</form>
</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn"><i class="fa fa-refresh" aria-hidden="true"></i>刷新数据</button>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12">
<div style="margin:auto 10px;">
<table id="messageTable" lay-filter="messageTable"></table>
</div>
</div>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript" src="../../assets/lib/layui/lay/modules/jquery.min.js"></script>
<script type="text/javascript" src="../../assets/lib/layui/lay/modules/contextMenu/jquery.contextMenu.min.js"></script>
<script type="text/javascript" src="../../assets/lib/layui/lay/modules/ztree/js/jquery.ztree.all.min.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/sysdatabase/'}).use('sysdatabaselist');
</script>
</body>
</html>
\ No newline at end of file
<option value="">全部</option>
{{#each rows}}
<option value="{{id}}">{{name}}</option>
{{/each}}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册