数据库问文档重构

This commit is contained in:
暮光:城中城
2019-07-04 21:52:39 +08:00
parent e3ed105f49
commit 6c1f4e123a
49 changed files with 13653 additions and 198 deletions

View File

@@ -0,0 +1,144 @@
package com.zyplayer.doc.data.repository.manage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author 暮光:城中城
* @since 2019-07-04
*/
public class DbDatasource implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键自增ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 数据源驱动类
*/
private String driverClassName;
/**
* 数据源地址
*/
private String sourceUrl;
/**
* 数据源用户名
*/
private String sourceName;
/**
* 数据源密码
*/
private String sourcePassword;
/**
* 创建人ID
*/
private Long createUserId;
/**
* 创建人名字
*/
private String createUserName;
/**
* 创建时间
*/
private Date createTime;
/**
* 是否有效 0=无效 1=有效
*/
private Integer yn;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public String getSourceUrl() {
return sourceUrl;
}
public void setSourceUrl(String sourceUrl) {
this.sourceUrl = sourceUrl;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public String getSourcePassword() {
return sourcePassword;
}
public void setSourcePassword(String sourcePassword) {
this.sourcePassword = sourcePassword;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getYn() {
return yn;
}
public void setYn(Integer yn) {
this.yn = yn;
}
@Override
public String toString() {
return "DbDatasource{" +
"id=" + id +
", driverClassName=" + driverClassName +
", sourceUrl=" + sourceUrl +
", sourceName=" + sourceName +
", sourcePassword=" + sourcePassword +
", createUserId=" + createUserId +
", createUserName=" + createUserName +
", createTime=" + createTime +
", yn=" + yn +
"}";
}
}

View File

@@ -0,0 +1,16 @@
package com.zyplayer.doc.data.repository.manage.mapper;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author 暮光:城中城
* @since 2019-07-04
*/
public interface DbDatasourceMapper extends BaseMapper<DbDatasource> {
}

View File

@@ -17,9 +17,9 @@ public class CodeGenerator {
public static void main(String[] args) {
final String moduleName = "manage";
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info" };
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info", "db_datasource" };
// final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
final String[] tableName = { "wiki_page" };
final String[] tableName = { "db_datasource" };
// 代码生成器
AutoGenerator mpg = new AutoGenerator();

View File

@@ -0,0 +1,16 @@
package com.zyplayer.doc.data.service.manage;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author 暮光:城中城
* @since 2019-07-04
*/
public interface DbDatasourceService extends IService<DbDatasource> {
}

View File

@@ -0,0 +1,20 @@
package com.zyplayer.doc.data.service.manage.impl;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.zyplayer.doc.data.repository.manage.mapper.DbDatasourceMapper;
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author 暮光:城中城
* @since 2019-07-04
*/
@Service
public class DbDatasourceServiceImpl extends ServiceImpl<DbDatasourceMapper, DbDatasource> implements DbDatasourceService {
}

View File

@@ -0,0 +1,20 @@
package com.zyplayer.doc.data.web.generator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author 暮光:城中城
* @since 2019-07-04
*/
@RestController
@RequestMapping("/db-datasource")
public class GeneratorDbDatasourceController {
}

View File

@@ -0,0 +1,5 @@
<?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.zyplayer.doc.data.repository.manage.mapper.DbDatasourceMapper">
</mapper>

View File

@@ -71,6 +71,16 @@
<artifactId>zyplayer-doc-core</artifactId>
<version>${zyplayer.doc.version}</version>
</dependency>
<dependency>
<groupId>com.zyplayer</groupId>
<artifactId>zyplayer-doc-data</artifactId>
<version>${zyplayer.doc.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
</dependencies>
<properties>

View File

@@ -0,0 +1,95 @@
package com.zyplayer.doc.db.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zyplayer.doc.core.annotation.AuthMan;
import com.zyplayer.doc.data.config.security.DocUserDetails;
import com.zyplayer.doc.data.config.security.DocUserUtil;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
import com.zyplayer.doc.db.framework.configuration.DatasourceUtil;
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
import com.zyplayer.doc.db.framework.json.DocDbResponseJson;
import com.zyplayer.doc.db.framework.json.ResponseJson;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
/**
* 数据源控制器
*
* @author 暮光:城中城
* @since 2019年6月29日
*/
@AuthMan
@RestController
@RequestMapping("/zyplayer-doc-db/datasource")
public class DbDatasourceController {
@Resource
DatabaseRegistrationBean databaseRegistrationBean;
@Resource
DbDatasourceService dbDatasourceService;
@PostMapping(value = "/list")
public ResponseJson list() {
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
wrapper.eq("yn", 1);
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
return DocDbResponseJson.ok(datasourceList);
}
@PostMapping(value = "/update")
public ResponseJson update(DbDatasource dbDatasource) {
if (StringUtils.isBlank(dbDatasource.getDriverClassName())) {
return DocDbResponseJson.warn("驱动类必选");
} else if (StringUtils.isBlank(dbDatasource.getSourceUrl())) {
return DocDbResponseJson.warn("地址必填");
} else if (StringUtils.isBlank(dbDatasource.getSourceName())) {
return DocDbResponseJson.warn("用户名必填");
} else if (StringUtils.isBlank(dbDatasource.getSourcePassword())) {
return DocDbResponseJson.warn("密码必填");
}
Long sourceId = Optional.ofNullable(dbDatasource.getId()).orElse(0L);
if (sourceId > 0) {
dbDatasourceService.updateById(dbDatasource);
} else {
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
dbDatasource.setCreateTime(new Date());
dbDatasource.setCreateUserId(currentUser.getUserId());
dbDatasource.setYn(1);
dbDatasourceService.save(dbDatasource);
}
List<DatabaseFactoryBean> newFactoryBeanList = new LinkedList<>();
List<DatabaseFactoryBean> databaseFactoryBeanList = databaseRegistrationBean.getDatabaseFactoryBeanList();
for (DatabaseFactoryBean factoryBean : databaseFactoryBeanList) {
if (Objects.equals(factoryBean.getId(), sourceId)) {
try {
// 关闭旧的数据源
factoryBean.getDataSource().close();
factoryBean.getDataSource().destroy();
} catch (Exception e) {
e.printStackTrace();
}
} else {
newFactoryBeanList.add(factoryBean);
}
}
// 创建新的数据源
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource);
if (databaseFactoryBean != null) {
newFactoryBeanList.add(databaseFactoryBean);
}
databaseRegistrationBean.setDatabaseFactoryBeanList(newFactoryBeanList);
if (databaseFactoryBean == null) {
return DocDbResponseJson.warn("创建数据源失败,请检查配置是否正确");
}
return DocDbResponseJson.ok();
}
}

View File

@@ -1,36 +1,24 @@
package com.zyplayer.doc.db.framework.configuration;
import java.sql.DatabaseMetaData;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import javax.sql.DataSource;
import com.zyplayer.doc.db.framework.db.bean.DbConfigBean;
import com.zyplayer.doc.db.framework.db.interceptor.SqlLogInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.zyplayer.doc.data.service.manage.DbDatasourceService;
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
import org.springframework.context.ApplicationListener;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Component;
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean.DatabaseProduct;
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
import java.util.LinkedList;
import java.util.List;
@Component
public class ApplicationListenerBean implements ApplicationListener<ContextRefreshedEvent> {
@Autowired
@javax.annotation.Resource
DatabaseRegistrationBean databaseRegistrationBean;
@javax.annotation.Resource
DbDatasourceService dbDatasourceService;
private volatile static boolean IS_INIT = false;
@@ -41,76 +29,15 @@ public class ApplicationListenerBean implements ApplicationListener<ContextRefre
}
// 会被调用两次
IS_INIT = true;
Integer dataSourceIndex = 0;
SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
List<DatabaseFactoryBean> databaseFactoryBeanList = new LinkedList<>();
for (DbConfigBean dbConfigBean : databaseRegistrationBean.getDbConfigList()) {
try {
// 数据源配置
Properties xaProperties = new Properties();
xaProperties.setProperty("driverClassName", dbConfigBean.getDriverClassName());
xaProperties.setProperty("url", dbConfigBean.getUrl());
xaProperties.setProperty("username", dbConfigBean.getUsername());
xaProperties.setProperty("password", dbConfigBean.getPassword());
xaProperties.setProperty("maxActive", "500");
xaProperties.setProperty("testOnBorrow", "true");
xaProperties.setProperty("testWhileIdle", "true");
xaProperties.setProperty("validationQuery", "select 'x'");
// 数据源
AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
dataSource.setXaProperties(xaProperties);
dataSource.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
dataSource.setUniqueResourceName("zyplayer-doc-db" + (dataSourceIndex++));
dataSource.setMaxPoolSize(500);
dataSource.setMinPoolSize(1);
dataSource.setMaxLifetime(60);
// 描述连接信息的对象
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
DatabaseMetaData metaData = dataSource.getConnection().getMetaData();
String productName = metaData.getDatabaseProductName().toLowerCase();
Resource[] resources = null;
String dbUrl = metaData.getURL();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
if (productName.indexOf("mysql") >= 0) {
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
String[] urlParamArr = dbUrl.split("\\?");
String[] urlDbNameArr = urlParamArr[0].split("/");
if (urlDbNameArr.length >= 2) {
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
}
databaseFactoryBean.setDatabaseProduct(DatabaseProduct.MYSQL);
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/mysql/*.xml");
} else if (productName.indexOf("sql server") >= 0) {
// jdbc:jtds:sqlserver://192.168.0.1:33434;socketTimeout=60;DatabaseName=user_info;
String[] urlParamArr = dbUrl.split(";");
String[] urlDbNameArr = urlParamArr[0].split("/");
databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 1]);
for (String urlParam : urlParamArr) {
String[] keyValArr = urlParam.split("=");
if (keyValArr.length >= 2 && keyValArr[0].equalsIgnoreCase("DatabaseName")) {
databaseFactoryBean.setDbName(keyValArr[1]);
}
}
databaseFactoryBean.setDatabaseProduct(DatabaseProduct.SQLSERVER);
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/sqlserver/*.xml");
}
if (resources == null) {
continue;
}
// 创建sqlSessionTemplate
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(resources);
sqlSessionFactoryBean.setPlugins(new Interceptor[]{sqlLogInterceptor});
SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactoryBean.getObject());
// 组装自定义的bean
databaseFactoryBean.setDataSource(dataSource);
databaseFactoryBean.setSqlSessionTemplate(sqlSessionTemplate);
databaseFactoryBean.setUrl(dbUrl);
QueryWrapper<DbDatasource> wrapper = new QueryWrapper<>();
wrapper.eq("yn", 1);
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
for (DbDatasource dbDatasource : datasourceList) {
DatabaseFactoryBean databaseFactoryBean = DatasourceUtil.createDatabaseFactoryBean(dbDatasource);
if (databaseFactoryBean != null) {
databaseFactoryBeanList.add(databaseFactoryBean);
} catch (Exception e) {
e.printStackTrace();
}
}
databaseRegistrationBean.setDatabaseFactoryBeanList(databaseFactoryBeanList);

View File

@@ -0,0 +1,91 @@
package com.zyplayer.doc.db.framework.configuration;
import com.zyplayer.doc.data.repository.manage.entity.DbDatasource;
import com.zyplayer.doc.db.framework.db.bean.DatabaseFactoryBean;
import com.zyplayer.doc.db.framework.db.interceptor.SqlLogInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import java.sql.DatabaseMetaData;
import java.util.Properties;
public class DatasourceUtil {
private static SqlLogInterceptor sqlLogInterceptor = new SqlLogInterceptor();
public static DatabaseFactoryBean createDatabaseFactoryBean(DbDatasource dbDatasource){
try {
// 数据源配置
Properties xaProperties = new Properties();
xaProperties.setProperty("driverClassName", dbDatasource.getDriverClassName());
xaProperties.setProperty("url", dbDatasource.getSourceUrl());
xaProperties.setProperty("username", dbDatasource.getSourceName());
xaProperties.setProperty("password", dbDatasource.getSourcePassword());
xaProperties.setProperty("maxActive", "500");
xaProperties.setProperty("breakAfterAcquireFailure", "true");
xaProperties.setProperty("testOnBorrow", "true");
xaProperties.setProperty("testWhileIdle", "true");
xaProperties.setProperty("validationQuery", "select 'x'");
// 数据源
AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
dataSource.setXaProperties(xaProperties);
dataSource.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
dataSource.setUniqueResourceName("zyplayer-doc-db" + dbDatasource.getId());
dataSource.setMaxPoolSize(500);
dataSource.setMinPoolSize(1);
dataSource.setMaxLifetime(60);
// 描述连接信息的对象
DatabaseFactoryBean databaseFactoryBean = new DatabaseFactoryBean();
DatabaseMetaData metaData = dataSource.getConnection().getMetaData();
String productName = metaData.getDatabaseProductName().toLowerCase();
Resource[] resources = null;
String dbUrl = metaData.getURL();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
if (productName.indexOf("mysql") >= 0) {
// jdbc:mysql://192.168.0.1:3306/user_info?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
String[] urlParamArr = dbUrl.split("\\?");
String[] urlDbNameArr = urlParamArr[0].split("/");
if (urlDbNameArr.length >= 2) {
databaseFactoryBean.setDbName(urlDbNameArr[urlDbNameArr.length - 1]);
databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 2]);
}
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.MYSQL);
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/mysql/*.xml");
} else if (productName.indexOf("sql server") >= 0) {
// jdbc:jtds:sqlserver://192.168.0.1:33434;socketTimeout=60;DatabaseName=user_info;
String[] urlParamArr = dbUrl.split(";");
String[] urlDbNameArr = urlParamArr[0].split("/");
databaseFactoryBean.setHost(urlDbNameArr[urlDbNameArr.length - 1]);
for (String urlParam : urlParamArr) {
String[] keyValArr = urlParam.split("=");
if (keyValArr.length >= 2 && keyValArr[0].equalsIgnoreCase("DatabaseName")) {
databaseFactoryBean.setDbName(keyValArr[1]);
}
}
databaseFactoryBean.setDatabaseProduct(DatabaseFactoryBean.DatabaseProduct.SQLSERVER);
resources = resolver.getResources("classpath:com/zyplayer/doc/db/framework/db/mapper/sqlserver/*.xml");
}
if (resources == null) {
return null;
}
// 创建sqlSessionTemplate
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(resources);
sqlSessionFactoryBean.setPlugins(new Interceptor[]{sqlLogInterceptor});
SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactoryBean.getObject());
// 组装自定义的bean
databaseFactoryBean.setId(dbDatasource.getId());
databaseFactoryBean.setDataSource(dataSource);
databaseFactoryBean.setSqlSessionTemplate(sqlSessionTemplate);
databaseFactoryBean.setUrl(dbUrl);
return databaseFactoryBean;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -1,72 +1,80 @@
package com.zyplayer.doc.db.framework.db.bean;
import javax.sql.DataSource;
import org.mybatis.spring.SqlSessionTemplate;
/**
* 描述连接信息的对象
* @author 暮光:城中城
* @since 2018年8月8日
*/
public class DatabaseFactoryBean {
private DataSource dataSource;
private SqlSessionTemplate sqlSessionTemplate;
private String url;
private String host;
private String dbName;
private DatabaseProduct databaseProduct;
public static enum DatabaseProduct {
MYSQL, SQLSERVER
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public DatabaseProduct getDatabaseProduct() {
return databaseProduct;
}
public void setDatabaseProduct(DatabaseProduct databaseProduct) {
this.databaseProduct = databaseProduct;
}
public SqlSessionTemplate getSqlSessionTemplate() {
return sqlSessionTemplate;
}
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
}
}
package com.zyplayer.doc.db.framework.db.bean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
/**
* 描述连接信息的对象
* @author 暮光:城中城
* @since 2018年8月8日
*/
public class DatabaseFactoryBean {
private Long id;
private AtomikosDataSourceBean dataSource;
private SqlSessionTemplate sqlSessionTemplate;
private String url;
private String host;
private String dbName;
private DatabaseProduct databaseProduct;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public static enum DatabaseProduct {
MYSQL, SQLSERVER
}
public AtomikosDataSourceBean getDataSource() {
return dataSource;
}
public void setDataSource(AtomikosDataSourceBean dataSource) {
this.dataSource = dataSource;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public DatabaseProduct getDatabaseProduct() {
return databaseProduct;
}
public void setDatabaseProduct(DatabaseProduct databaseProduct) {
this.databaseProduct = databaseProduct;
}
public SqlSessionTemplate getSqlSessionTemplate() {
return sqlSessionTemplate;
}
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
this.sqlSessionTemplate = sqlSessionTemplate;
}
}

View File

@@ -0,0 +1,23 @@
--
-- !!重要说明!!
-- 1、本sql文件分为从1.0.2版本升级 和 全新的库,即增量和全量的区分,请选择性执行
-- 2、建议数据库版本5.7.25
--
-- 从1.0.2版本升级:
CREATE TABLE `db_datasource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
`driver_class_name` varchar(50) DEFAULT NULL COMMENT '数据源驱动类',
`source_url` varchar(512) DEFAULT NULL COMMENT '数据源地址',
`source_name` varchar(50) DEFAULT NULL COMMENT '数据源用户名',
`source_password` varchar(50) DEFAULT NULL COMMENT '数据源密码',
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
-- ------------------------全新的库:------------------------

View File

@@ -22,9 +22,9 @@ export default {
if (!!res.message) {
global.vue.$message('请求错误:' + res.message);
} else if (res.data.errCode == 400) {
global.vue.$message('请先登录');
var href = encodeURIComponent(window.location.href);
if (global.vue.$router.currentRoute.path != '/user/login') {
global.vue.$message('请先登录');
global.vue.$router.push({path: '/user/login', query: {redirect: href}});
}
} else if (res.data.errCode == 402) {

View File

@@ -1,5 +1,5 @@
<template>
<div style="padding-top: 50px;">
<div style="padding-top: 50px;" @keyup.enter="loginSubmit">
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
class="demo-ruleForm login-container">
<h3 class="title">系统登录</h3>

View File

@@ -0,0 +1,3 @@
{
"presets": ["vue-app"]
}

5
zyplayer-doc-ui/db-ui/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
.DS_Store
node_modules/
dist/
npm-debug.log
.idea

View File

@@ -0,0 +1,9 @@
.PHONY: dist build
install:
@npm install
dev: install
@npm run dev
build:
@npm run build

View File

@@ -0,0 +1,50 @@
# zyplayer-doc-manage项目的UI
## 常见问题
1、命令行要进入这个文件夹才能执行命令
zyplayer-doc/zyplayer-doc-ui/manage-ui
2、增加host否则run不起来
在文件 C:\Windows\System32\drivers\etc\hosts 末尾增加:
127.0.0.1 local.zyplayer.com
## 配置文件
1、这里可以配置接口请求的域名可使用本地、线上测试通过后就会打包到zyplayer-doc-wiki项目里面使用
zyplayer-doc-ui/manage-ui/src/common/config/apimix.js
2、这里可以配置启动后访问的地址建议不改
zyplayer-doc-ui/manage-ui/webpack.config.js
## 环境要求
`Node >= 6`
## 开始
``` bash
# 执行下面的命令初始化
yarn
```
## 开发环境
``` bash
# 执行下面的命令后即可到 localhost:8010 看到页面
npm run dev
```
## 打包
``` bash
# 开发完成后执行打包命令然后复制dist目录里的文件到zyplayer-doc-manage项目的webjars目录下即可
# 打包前记得修改zyplayer-doc-ui/manage-ui/src/common/config/apimix.js里的HOST接口地址
npm run build
```

7697
zyplayer-doc-ui/db-ui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
{
"name": "console-ui",
"description": "console-ui",
"author": "yi.shyang@ele.me",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --hot --env.dev",
"build": "rimraf dist && webpack -p --progress --hide-modules"
},
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.10.0",
"vue": "^2.5.16",
"vue-axios": "^2.1.4",
"vue-router": "^3.0.6",
"wangeditor": "^3.1.1"
},
"engines": {
"node": ">=6"
},
"devDependencies": {
"autoprefixer": "^6.6.0",
"babel-core": "^6.24.1",
"babel-loader": "^6.4.0",
"babel-preset-vue-app": "^1.2.0",
"css-loader": "^0.27.0",
"file-loader": "^0.10.1",
"html-webpack-plugin": "^2.24.1",
"postcss-loader": "^1.3.3",
"rimraf": "^2.6.3",
"style-loader": "^0.13.2",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^2.4.1",
"webpack-dev-server": "^2.4.2",
"axios": "^0.18.0",
"vue-axios": "^2.1.4"
}
}

View File

@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require('autoprefixer')()
]
}

View File

@@ -0,0 +1,250 @@
<template>
<div id="app">
<template v-if="global.fullscreen">
<router-view></router-view>
</template>
<el-container v-else>
<el-aside>
<div style="padding: 10px;height: 100%;box-sizing: border-box;background: #fafafa;">
<div style="margin-bottom: 10px;">
<el-select v-model="choiceDatasource" @change="datasourceChangeEvents" filterable placeholder="选择数据源" style="width: 100%;">
<el-option v-for="item in datasourceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</div>
<el-menu :router="true" class="el-menu-vertical" style="height: auto;">
<el-menu-item index="/"><i class="el-icon-s-home"></i>数据源管理</el-menu-item>
</el-menu>
<el-tree :props="defaultProps" :data="databaseList" @node-click="handleNodeClick"
ref="databaseTree" highlight-current draggable
:default-expanded-keys="databaseExpandedKeys"
node-key="id" @node-expand="handleNodeExpand"
style="background-color: #fafafa;">
<span slot-scope="{node, data}">
<span v-if="data.needLoad"><i class="el-icon-loading"></i></span>
<span v-else>{{node.label}}</span>
</span>
</el-tree>
</div>
</el-aside>
<el-container>
<el-header>
<span class="header-right-user-name">{{userSelfInfo.userName}}</span>
<el-dropdown @command="userSettingDropdown" trigger="click">
<i class="el-icon-setting" style="margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;"> </i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="console">控制台</el-dropdown-item>
<el-dropdown-item command="aboutDoc" divided>关于</el-dropdown-item>
<el-dropdown-item command="myInfo">我的资料</el-dropdown-item>
<el-dropdown-item command="userSignOut">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-header>
<el-main style="padding: 0;">
<router-view></router-view>
</el-main>
</el-container>
</el-container>
<!--关于弹窗-->
<el-dialog title="关于zyplayer-doc" :visible.sync="aboutDialogVisible" width="600px">
<el-form>
<el-form-item label="项目地址:">
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
</el-form-item>
<el-form-item label="开发人员:">
<a target="_blank" href="http://zyplayer.com">暮光城中城</a>
</el-form-item>
<template v-if="upgradeInfo.lastVersion">
<el-form-item label="当前版本:">{{upgradeInfo.nowVersion}}</el-form-item>
<el-form-item label="最新版本:">{{upgradeInfo.lastVersion}}</el-form-item>
<el-form-item label="升级地址:">
<a target="_blank" :href="upgradeInfo.upgradeUrl">{{upgradeInfo.upgradeUrl}}</a>
</el-form-item>
<el-form-item label="升级内容:">{{upgradeInfo.upgradeContent}}</el-form-item>
</template>
<el-form-item label="">
欢迎加群讨论QQ群号466363173欢迎提交需求欢迎使用和加入开发
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import global from './common/config/global'
import toast from './common/lib/common/toast'
var app;
export default {
data() {
return {
isCollapse: false,
aboutDialogVisible: false,
userSelfInfo: {},
// 数据源相关
datasourceOptions: [],
datasourceList: [],
choiceDatasource: "",
defaultProps: {children: 'children', label: 'name'},
// 页面展示相关
nowDatasourceShow: {},
databaseList: [],
databaseExpandedKeys: [],
// 升级信息
upgradeInfo: {},
}
},
mounted: function () {
app = this;
global.vue.$app = this;
this.getSelfUserInfo();
this.checkSystemUpgrade();
this.loadDatasourceList();
},
methods: {
userSettingDropdown(command) {
console.log("command:" + command);
if (command == 'userSignOut') {
this.userSignOut();
} else if (command == 'aboutDoc') {
app.aboutDialogVisible = true;
} else if (command == 'myInfo') {
this.$router.push({path: '/user/myInfo'});
} else if (command == 'console') {
window.location = this.apilist1.HOST;
} else {
toast.notOpen();
}
},
userSignOut() {
this.common.post(this.apilist1.userLogout, {}, function (json) {
location.reload();
});
},
getSelfUserInfo() {
this.common.post(this.apilist1.getSelfUserInfo, {}, function (json) {
app.userSelfInfo = json.data;
});
},
datasourceChangeEvents() {
app.nowDatasourceShow = this.choiceDatasource;
app.loadDatabaseList(this.choiceDatasource);
},
handleNodeClick(node) {
console.log("点击节点:", node);
if (node.type == 1) {
this.nowClickPath = {host: node.host, dbName: node.dbName, tableName: node.tableName};
this.$router.push({path: '/table/database', query: this.nowClickPath});
} else if (node.type == 2) {
this.nowClickPath = {host: node.host, dbName: node.dbName, tableName: node.tableName};
this.$router.push({path: '/table/info', query: this.nowClickPath});
}
},
handleNodeExpand(node) {
if (node.children.length > 0 && node.children[0].needLoad) {
console.log("加载节点:", node);
if (node.type == 1) {
app.loadGetTableList(node);
}
}
},
loadGetTableList(node, callback) {
this.common.post(this.apilist1.tableList, {host: node.host, dbName: node.dbName}, function (json) {
var pathIndex = [];
var result = json.data || [];
for (var i = 0; i < result.length; i++) {
var item = {
id: node.host + "_" + node.dbName + "_" + result[i].tableName, host: node.host,
dbName: node.dbName, tableName: result[i].tableName, name: result[i].tableName, type: 2
};
// item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
pathIndex.push(item);
}
node.children = pathIndex;
if (typeof callback == 'function') {
callback(pathIndex);
}
});
},
loadDatasourceList() {
this.common.post(this.apilist1.datasourceList, {}, function (json) {
app.datasourceList = json.data || [];
var datasourceOptions = [];
for (var i = 0; i < app.datasourceList.length; i++) {
datasourceOptions.push({
label: app.datasourceList[i], value: app.datasourceList[i]
});
}
app.datasourceOptions = datasourceOptions;
});
},
loadDatabaseList(host, callback) {
this.common.post(this.apilist1.databaseList, {host: host}, function (json) {
var result = json.data || [];
var pathIndex = [];
var children = [];
for (var i = 0; i < result.length; i++) {
var item = {
id: host + "_" + result[i].dbName, host: host, dbName: result[i].dbName,
name: result[i].dbName, type: 1
};
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
children.push(item);
}
pathIndex.push({id: host, host: host, name: host, children: children});
app.databaseList = pathIndex;
if (typeof callback == 'function') {
callback();
}
});
},
initLoadDataList(host, dbName) {
if (app.databaseList.length > 0) {
return;
}
this.loadDatabaseList(host, function () {
app.databaseExpandedKeys = [host];
// 展不开、、
// setTimeout(()=> {
// var node = app.$refs.databaseTree.getNode(host + "_" + dbName);
// if (!!node) {
// app.loadGetTableList(node.data, function (children) {
// var node = app.$refs.databaseTree.getNode(host + "_" + dbName);
// node.childNodes = children;
// app.$refs.databaseTree.updateKeyChildren(host + "_" + dbName);
// // node.setChildren(node.data);
// });
// }
// }, 500);
});
},
checkSystemUpgrade() {
this.common.post(this.apilist1.systemUpgradeInfo, {}, function (json) {
if (!!json.data) {
app.upgradeInfo = json.data;
console.log("zyplayer-doc发现新版本"
+ "\n升级地址" + json.data.upgradeUrl
+ "\n当前版本" + json.data.nowVersion
+ "\n最新版本" + json.data.lastVersion
+ "\n升级内容" + json.data.upgradeContent
);
}
});
},
}
}
</script>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
#app, .el-container, .el-menu {
height: 100%;
}
.header-right-user-name{color: #fff;padding-right: 5px;}
.el-menu-vertical{border-right: 0;background: #fafafa;}
.el-menu-vertical .el-menu{background: #fafafa;}
.el-header {background-color: #409EFF; color: #333; line-height: 40px; text-align: right;height: 40px !important;}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,28 @@
var URL = {
userLogin: '/login',
userLogout: '/logout',
getSelfUserInfo: '/user/info/selfInfo',
datasourceList: '/zyplayer-doc-db/doc-db/getDataSourceList',
databaseList: '/zyplayer-doc-db/doc-db/getDatabaseList',
tableList: '/zyplayer-doc-db/doc-db/getTableList',
tableColumnList: '/zyplayer-doc-db/doc-db/getTableColumnList',
tableAndColumnBySearch: '/zyplayer-doc-db/doc-db/getTableAndColumnBySearch',
updateTableDesc: '/zyplayer-doc-db/doc-db/updateTableDesc',
updateTableColumnDesc: '/zyplayer-doc-db/doc-db/updateTableColumnDesc',
manageDatasourceList: '/zyplayer-doc-db/datasource/list',
manageUpdateDatasource: '/zyplayer-doc-db/datasource/update',
systemUpgradeInfo: '/system/info/upgrade',
};
var URL1 = {};
export default {
URL, URL1
};

View File

@@ -0,0 +1,52 @@
import apilist from './apilist'
var href = window.location.href;
var _fn = {
href: href,
// 本地启动时使用本地接口调试
HOST: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
HOST1: 'http://local.zyplayer.com:8083/zyplayer-doc-manage',
// 也可以直接使用线上的服务调试
// HOST: 'http://doc.zyplayer.com/zyplayer-doc-manage',
// HOST1: 'http://doc.zyplayer.com/zyplayer-doc-manage',
// 打包时使用下面这两行,文件就放在根目录下,所以当前路劲就好
// HOST: './',
// HOST1: './',
mixUrl: function (host, url) {
var p;
if (!host || !url || _fn.isEmptyObject(url)) {
return;
}
url.HOST = host;
for (p in url) {
if (url[p].indexOf('http') == -1) {
url[p] = host + url[p];
}
}
return url;
},
//判断是否空对象
isEmptyObject: function (obj) { //判断空对象
if (typeof obj === "object" && !(obj instanceof Array)) {
var hasProp = false;
for (var prop in obj) {
hasProp = true;
break;
}
if (hasProp) {
return false;
}
return true;
}
}
};
var apilist1 = _fn.mixUrl(_fn.HOST, apilist.URL);
var apilist2 = _fn.mixUrl(_fn.HOST1, apilist.URL1);
export default {
apilist1, apilist2
};

View File

@@ -0,0 +1,12 @@
const user = {
isLogin: true,
};
const vue = {};
const fullscreen = false;
export default {
vue,
user,
fullscreen,
}

View File

@@ -0,0 +1,113 @@
import Qs from 'qs'
import global from '../../config/global'
import apimix from '../../config/apimix'
export default {
data: {
accessToken: '',
},
setAccessToken: function (token) {
this.data.accessToken = token;
},
getAccessToken: function () {
if (!this.data.accessToken) {
var arr, reg = new RegExp("(^| )accessToken=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) {
this.data.accessToken = unescape(arr[2]);
}
}
return this.data.accessToken;
},
validateResult: function (res, callback) {
if (!!res.message) {
global.vue.$message('请求错误:' + res.message);
} else if (res.data.errCode == 400) {
global.vue.$message('请先登录');
var href = encodeURIComponent(window.location.href);
// if (global.vue.$router.currentRoute.path != '/user/login') {
// global.vue.$router.push({path: '/user/login', query: {redirect: href}});
// }
window.location = apimix.apilist1.HOST + "#/user/login?redirect=" + href;
} else if (res.data.errCode == 402) {
global.vue.$router.push("/common/noAuth");
} else if (res.data.errCode !== 200) {
global.vue.$message(res.data.errMsg || "未知错误");
} else {
if (typeof callback == 'function') {
callback(res.data);
}
}
},
post: function (url, param, callback) {
param = param || {};
param.accessToken = this.getAccessToken();
global.vue.axios({
method: "post",
url: url,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: Qs.stringify(param),
withCredentials: true,
}).then((res) => {
console.log("ok", res);
this.validateResult(res, callback);
}).catch((res) => {
console.log("error", res);
this.validateResult(res);
});
},
postNonCheck: function (url, param, callback) {
param = param || {};
param.accessToken = this.getAccessToken();
global.vue.axios({
method: "post",
url: url,
headers: {'Content-type': 'application/x-www-form-urlencoded'},
data: Qs.stringify(param),
withCredentials: true,
}).then((res) => {
console.log("ok", res);
if (typeof callback == 'function') {
callback(res.data);
}
}).catch((res) => {
console.log("error", res);
if (typeof callback == 'function') {
callback(res.data);
}
});
},
/**
* 返回不为空的字符串为空返回def
*/
getNotEmptyStr(str, def) {
if (isEmpty(str)) {
return isEmpty(def) ? "" : def;
}
return str;
},
/**
* 是否是空对象
* @param obj
* @returns
*/
isEmptyObject(obj) {
return isEmpty(obj) || $.isEmptyObject(obj);
},
/**
* 是否是空字符串
* @param str
* @returns
*/
isEmpty(str) {
return (str == "" || str == null || str == undefined);
},
/**
* 是否不是空字符串
* @param str
* @returns
*/
isNotEmpty(str) {
return !isEmpty(str);
},
}

View File

@@ -0,0 +1,40 @@
import global from '../../config/global'
/**
* 提示工具类
* @author
* @since 2017年5月7日
*/
export default {
notOpen: function () {
global.vue.$message({
message: '该功能暂未开放,敬请期待!',
type: 'warning',
showClose: true
});
},
success: function (msg, time) {
global.vue.$message({
message: msg,
duration: time || 3000,
type: 'success',
showClose: true
});
},
warn: function (msg, time) {
global.vue.$message({
message: msg,
duration: time || 3000,
type: 'warning',
showClose: true
});
},
error: function (msg, time) {
global.vue.$message({
message: msg,
duration: time || 3000,
type: 'error',
showClose: true
});
},
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>数据库文档管理</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>数据库文档管理</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@@ -0,0 +1,59 @@
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import global from './common/config/global'
import apimix from './common/config/apimix'
import common from './common/lib/common/common'
import toast from './common/lib/common/toast'
import VueRouter from 'vue-router'
import routes from './routes'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(ElementUI);
Vue.use(VueRouter);
Vue.use(VueAxios, axios);
// 全局参数
Vue.prototype.global = global;
// 接口列表
Vue.prototype.apilist1 = apimix.apilist1;
Vue.prototype.apilist2 = apimix.apilist1;
// 公用方法
Vue.prototype.common = common;
Vue.prototype.toast = toast;
const router = new VueRouter({routes});
// 路由跳转时判断处理
router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title
}
global.fullscreen = !!to.meta.fullscreen;
/* 判断该路由是否需要登录权限 */
if (to.matched.some(record => record.meta.requireAuth)) {
if (global.user.isLogin) {
next();
} else {
next({path: '/login'});
}
} else {
next();
}
});
new Vue({
el: '#app',
router,
render(h) {
var app = h(App);
global.vue = app.context;
return app;
}
});

View File

@@ -0,0 +1,50 @@
import Home from './views/home/Home.vue'
import UserLogin from './views/user/Login.vue'
import UserMyInfo from './views/user/MyInfo.vue'
import UserRouterView from './views/user/RouterView.vue'
import TableInfo from './views/table/Info.vue'
import TableDatabase from './views/table/Database.vue'
import TableRouterView from './views/table/RouterView.vue'
import CommonNoAuth from './views/common/NoAuth.vue'
let routes = [
{
path: '/home',
component: Home,
name: '主页',
meta: {
requireAuth: true,
}
}, {
path: '/user',
name: '用户管理',
component: UserRouterView,
children: [
{path: 'login', name: '系统登录',component: UserLogin, meta: {fullscreen: true}},
{path: 'myInfo', name: '我的信息',component: UserMyInfo},
]
}, {
path: '/table',
name: '表信息',
component: TableRouterView,
children: [
{path: 'info', name: '表信息',component: TableInfo},
{path: 'database', name: '库信息',component: TableDatabase},
]
}, {
path: '/common',
name: '',
component: UserRouterView,
children: [
{path: 'noAuth', name: '没有权限',component: CommonNoAuth},
]
}, {
path: '/',
redirect: '/home'
}
];
export default routes;

View File

@@ -0,0 +1,2 @@
import Vue from 'vue'
import ElementUI from 'element-ui'

View File

@@ -0,0 +1,18 @@
<template>
<div>没有权限访问该模块</div>
</template>
<script>
export default {
data() {
return {};
},
mounted: function () {
},
methods: {}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,111 @@
<template>
<div style="padding: 10px;">
<div style="max-width: 1200px;margin: 20px auto;">
<div style="text-align: center;">欢迎使用ヾ()"</div>
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">
<span>数据源管理</span>
<el-button style="float: right;" v-on:click="addDatasource" type="primary" icon="el-icon-circle-plus-outline" size="small">新增</el-button>
</div>
<el-table :data="datasourceList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="driverClassName" label="驱动类" width="200"></el-table-column>
<el-table-column prop="sourceUrl" label="数据源URL"></el-table-column>
<el-table-column prop="sourceName" label="账号"></el-table-column>
<el-table-column prop="sourcePassword" label="密码"></el-table-column>
<el-table-column label="操作" width="150">
<template slot-scope="scope">
<el-button v-on:click="editDatasource(scope.row)" type="primary" size="small">修改</el-button>
<el-button v-on:click="deleteDatasource(scope.row)" type="danger" size="small">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
<!--增加数据源弹窗-->
<el-dialog :inline="true" :title="newDatasource.id>0?'编辑数据源':'新增数据源'" :visible.sync="datasourceDialogVisible" width="600px">
<el-form label-width="120px">
<el-form-item label="驱动类">
<el-select v-model="newDatasource.driverClassName" placeholder="驱动类" style="width: 100%">
<el-option label="com.mysql.jdbc.Driver" value="com.mysql.jdbc.Driver"></el-option>
<el-option label="net.sourceforge.jtds.jdbc.Driver" value="net.sourceforge.jtds.jdbc.Driver"></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据源URL">
<el-input v-model="newDatasource.sourceUrl" placeholder="数据源URL"></el-input>
</el-form-item>
<el-form-item label="账号">
<el-input v-model="newDatasource.sourceName" placeholder="账号"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input v-model="newDatasource.sourcePassword" placeholder="密码"></el-input>
</el-form-item>
</el-form>
<div slot="footer" style="text-align: center;">
<el-button v-on:click="saveDatasource" type="primary">保存</el-button>
<el-button v-on:click="datasourceDialogVisible=false" plain>取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import toast from '../../common/lib/common/toast'
import global from '../../common/config/global'
var app;
export default {
data() {
return {
datasourceDialogVisible: false,
datasourceList: [],
newDatasource: {},
};
},
mounted: function () {
app = this;
this.getDatasourceList();
},
methods: {
addDatasource() {
this.datasourceDialogVisible = true;
},
editDatasource(row) {
this.newDatasource = row;
this.datasourceDialogVisible = true;
},
deleteDatasource(row) {
this.$confirm('确定要删除此数据源吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var datasourceList = [];
for (var i = 0; i < this.datasourceList.length; i++) {
if (this.datasourceList[i].id != row.id) {
datasourceList.push(this.datasourceList[i]);
}
}
this.datasourceList = datasourceList;
this.$message.success("删除成功");
}).catch(()=>{});
},
saveDatasource() {
this.datasourceDialogVisible = false;
this.common.post(this.apilist1.manageUpdateDatasource, this.newDatasource, function (json) {
app.$message.success("保存成功");
app.getDatasourceList();
});
},
getDatasourceList() {
this.common.post(this.apilist1.manageDatasourceList, {}, function (json) {
app.datasourceList = json.data || [];
});
},
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,74 @@
<template>
<div>
<el-card style="margin: 10px;" shadow="never">
<div slot="header" class="clearfix">库信息</div>
<el-form label-width="100px">
<el-form-item label="数据源:">{{vueQueryParam.host}}</el-form-item>
<el-form-item label="数据库:">{{vueQueryParam.dbName}}</el-form-item>
</el-form>
<el-form :inline="true" label-width="100px">
<el-form-item label="关键字:">
<el-input v-model="keyword" placeholder="输入字段名或注释搜索相关的表或字段信息" style="width: 500px;"></el-input>
</el-form-item>
<el-form-item>
<el-button class="search-submit" type="primary" icon="el-icon-search" @click="searchSubmit">模糊搜索</el-button>
</el-form-item>
</el-form>
</el-card>
<div style="padding: 10px;" v-loading="columnListLoading">
<el-table :data="columnList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="tableName" label="表名" width="200"></el-table-column>
<el-table-column prop="columnName" label="字段名" width="200"></el-table-column>
<el-table-column prop="description" label="注释"></el-table-column>
</el-table>
</div>
</div>
</template>
<script>
import global from '../../common/config/global'
var app;
export default {
data() {
return {
columnListLoading: false,
vueQueryParam: {},
columnList: [],
tableInfo: [],
keyword: '',
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
global.vue.$app.initLoadDataList(app.vueQueryParam.host, app.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
this.vueQueryParam = to.query;
},
searchSubmit() {
this.columnListLoading = true;
this.vueQueryParam.searchText = this.keyword;
this.common.post(this.apilist1.tableAndColumnBySearch, this.vueQueryParam, function (json) {
app.columnList = json.data || [];
app.columnListLoading = false;
});
},
}
}
</script>
<style>
.search-form-box{padding: 10px;}
.page-info-box{text-align: right;margin: 20px 0 50px 0;}
</style>

View File

@@ -0,0 +1,127 @@
<template>
<div class="table-info-vue">
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">表信息</div>
<el-form label-width="100px">
<el-form-item label="数据源:">{{vueQueryParam.host}}</el-form-item>
<el-form-item label="数据库:">{{vueQueryParam.dbName}}</el-form-item>
<el-form-item label="数据表:">{{vueQueryParam.tableName}}</el-form-item>
<el-form-item label="表注释:">
<span v-if="tableInfo.inEdit == 1" @keyup.enter="saveTableDescription">
<el-input v-model="tableInfo.newDesc" placeholder="输入表注释" v-on:blur="saveTableDescription" style="width: 500px;"></el-input>
</span>
<span v-else>{{tableInfo.description || '暂无注释'}} <i class="el-icon-edit edit-table-desc" v-on:click="tableInfo.inEdit = 1"></i></span>
</el-form-item>
</el-form>
</el-card>
<el-card style="margin: 10px;">
<div slot="header" class="clearfix">字段信息</div>
<div style="padding: 10px;" v-loading="columnListLoading">
<el-table :data="columnList" stripe border style="width: 100%; margin-bottom: 5px;">
<el-table-column prop="name" label="字段名" width="200"></el-table-column>
<el-table-column label="自增" width="50">
<template slot-scope="scope">{{scope.row.isidentity ? '是' : '否'}}</template>
</el-table-column>
<el-table-column prop="type" label="类型" width="150"></el-table-column>
<el-table-column prop="length" label="长度" width="80"></el-table-column>
<el-table-column label="NULL" width="60">
<template slot-scope="scope">{{scope.row.nullable ? '允许' : '不允许'}}</template>
</el-table-column>
<el-table-column label="主键" width="50">
<template slot-scope="scope">{{scope.row.ispramary ? '是' : '否'}}</template>
</el-table-column>
<el-table-column label="注释">
<template slot-scope="scope">
<div v-if="scope.row.inEdit == 1" @keyup.enter="saveColumnDescription(scope.row)">
<el-input v-model="scope.row.newDesc" placeholder="输入字段注释" v-on:blur="saveColumnDescription(scope.row)"></el-input>
</div>
<div v-else class="description" v-on:click="descBoxClick(scope.row)">{{scope.row.description}}</div>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</div>
</template>
<script>
import global from '../../common/config/global'
var app;
export default {
data() {
return {
columnListLoading: false,
vueQueryParam: {},
columnList: [],
tableInfo: [],
};
},
beforeRouteUpdate(to, from, next) {
this.initQueryParam(to);
next();
},
mounted: function () {
app = this;
this.initQueryParam(this.$route);
// 延迟设置展开的目录edit比app先初始化
setTimeout(function () {
global.vue.$app.initLoadDataList(app.vueQueryParam.host, app.vueQueryParam.dbName);
}, 500);
},
methods: {
initQueryParam(to) {
this.columnListLoading = true;
this.vueQueryParam = to.query;
this.common.post(this.apilist1.tableColumnList, this.vueQueryParam, function (json) {
var columnList = json.data.columnList || [];
for (var i = 0; i < columnList.length; i++) {
columnList[i].inEdit = 0;
columnList[i].newDesc = columnList[i].description;
}
app.columnList = columnList;
var tableInfo = json.data.tableInfo || {};
tableInfo.inEdit = 0;
tableInfo.newDesc = tableInfo.description;
app.tableInfo = tableInfo;
app.columnListLoading = false;
});
},
descBoxClick(row) {
// row.newDesc = row.description;
row.inEdit = 1;
},
saveColumnDescription(row) {
if (row.inEdit == 0 || row.description == row.newDesc) {
row.inEdit = 0;
return;
}
row.inEdit = 0;
this.vueQueryParam.columnName = row.name;
this.vueQueryParam.newDesc = row.newDesc;
this.common.post(this.apilist1.updateTableColumnDesc, this.vueQueryParam, function (json) {
row.description = row.newDesc;
app.$message.success("修改成功");
});
},
saveTableDescription() {
if (this.tableInfo.inEdit == 0 || this.tableInfo.description == this.tableInfo.newDesc) {
this.tableInfo.inEdit = 0;
return;
}
this.tableInfo.inEdit = 0;
this.vueQueryParam.newDesc = this.tableInfo.newDesc;
this.common.post(this.apilist1.updateTableDesc, this.vueQueryParam, function (json) {
app.tableInfo.description = app.tableInfo.newDesc;
app.$message.success("修改成功");
});
},
}
}
</script>
<style>
.table-info-vue .el-form-item{margin-bottom: 5px;}
.table-info-vue .edit-table-desc{cursor: pointer; color: #409EFF;}
.table-info-vue .description{cursor: pointer;}
</style>

View File

@@ -0,0 +1,4 @@
<template>
<router-view></router-view>
</template>

View File

@@ -0,0 +1,88 @@
<template>
<div style="padding-top: 50px;" @keyup.enter="loginSubmit">
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
class="demo-ruleForm login-container">
<h3 class="title">系统登录</h3>
<el-form-item prop="username">
<el-input type="text" v-model="loginParam.username" auto-complete="off" placeholder="账号"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="loginParam.password" auto-complete="off" placeholder="密码"></el-input>
</el-form-item>
<el-form-item style="width:100%;">
<el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录
</el-button>
<!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
data() {
return {
logining: false,
redirect: '',
loginParam: {
username: '',
password: ''
},
loginRules: {
username: [
{required: true, message: '请输入账号', trigger: 'blur'},
],
password: [
{required: true, message: '请输入密码', trigger: 'blur'},
]
},
checked: true
};
},
mounted: function () {
this.redirect = this.$route.query.redirect;
},
methods: {
loginSubmit() {
var that = this;
this.$refs.loginParam.validate((valid) => {
if (!valid) return;
that.common.post(that.apilist1.userLogin, that.loginParam, function (json) {
if(!!that.redirect) {
location.href = decodeURIComponent(that.redirect);
} else {
that.$router.back();
}
});
});
}
}
}
</script>
<style>
.login-container {
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-border-radius: 5px;
background-clip: padding-box;
margin: 0 auto;
width: 350px;
padding: 35px 35px 15px 35px;
background: #fff;
border: 1px solid #eaeaea;
box-shadow: 0 0 25px #cac6c6;
}
.title {
margin: 0px auto 40px auto;
text-align: center;
color: #505458;
}
.remember {
margin: 0px 0px 35px 0px;
}
</style>

View File

@@ -0,0 +1,49 @@
<template>
<div class="my-info-vue">
<el-breadcrumb separator-class="el-icon-arrow-right" style="padding: 20px 10px;">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>我的信息</el-breadcrumb-item>
</el-breadcrumb>
<div style="margin: 0 auto;max-width: 1000px;">
<el-card class="box-card">
<div slot="header" class="clearfix">我的信息</div>
<el-form class="search-form-box" label-width="100px">
<el-form-item label="账号:">{{userInfo.userNo}}</el-form-item>
<el-form-item label="用户名:">{{userInfo.userName}}</el-form-item>
<el-form-item label="手机号:">{{userInfo.phone}}</el-form-item>
<el-form-item label="邮箱:">{{userInfo.email}}</el-form-item>
<el-form-item label="状态:">{{userInfo.delFlag==0?'正常':'停用'}}</el-form-item>
<el-form-item label="性别:">{{userInfo.sex==0?'女':'男'}}</el-form-item>
</el-form>
</el-card>
</div>
</div>
</template>
<script>
var app;
export default {
data() {
return {
userInfo: {}
};
},
mounted: function () {
app = this;
this.getUserInfo();
},
methods: {
getUserInfo() {
this.common.post(this.apilist1.getSelfUserInfo, this.searchParam, function (json) {
app.userInfo = json.data;
});
},
}
}
</script>
<style>
.my-info-vue{}
.my-info-vue .box-card{margin: 10px;}
</style>

View File

@@ -0,0 +1,4 @@
<template>
<router-view></router-view>
</template>

View File

@@ -0,0 +1,75 @@
const resolve = require('path').resolve;
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const url = require('url');
const publicPath = '';
module.exports = (options = {}) => ({
entry: {
vendor: './src/vendor',
index: './src/main.js'
},
output: {
path: resolve(__dirname, 'dist'),
filename: options.dev ? '[name].js' : 'doc-db-[name].js?[chunkhash]',
chunkFilename: '[id].js?[chunkhash]',
publicPath: options.dev ? '/assets/' : publicPath
},
module: {
rules: [{
test: /\.vue$/,
use: ['vue-loader']
},
{
test: /\.js$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
},
{
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
use: [{
loader: 'url-loader',
options: {
limit: 800000
}
}]
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
new HtmlWebpackPlugin({
template: options.dev ? 'src/index.html':'src/doc-db.html',
filename: options.dev ? 'index.html':'doc-db.html',
})
],
resolve: {
alias: {
'~': resolve(__dirname, 'src')
},
extensions: ['.js', '.vue', '.json', '.css']
},
devServer: {
host: 'local.zyplayer.com',
port: 8010,
proxy: {
'/api/': {
target: 'http://local.zyplayer.com:8080',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
historyApiFallback: {
index: url.parse(options.dev ? '/assets/' : publicPath).pathname
}
},
devtool: options.dev ? '#eval-source-map' : '#source-map'
});

File diff suppressed because it is too large Load Diff

View File

@@ -40,8 +40,9 @@
<el-dropdown @command="userSettingDropdown" trigger="click">
<i class="el-icon-setting" style="margin-right: 15px; font-size: 16px;cursor: pointer;color: #fff;"> </i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="aboutDoc">关于</el-dropdown-item>
<el-dropdown-item command="" divided>我的资料</el-dropdown-item>
<el-dropdown-item command="console">控制台</el-dropdown-item>
<el-dropdown-item command="aboutDoc" divided>关于</el-dropdown-item>
<el-dropdown-item command="myInfo">我的资料</el-dropdown-item>
<el-dropdown-item command="userSignOut">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@@ -51,7 +52,6 @@
</el-main>
</el-container>
</el-container>
<!--新建空间弹窗-->
<el-dialog title="创建空间" :visible.sync="newSpaceDialogVisible" width="600px" :close-on-click-modal="false">
<el-form label-width="100px" :model="newSpaceForm" :rules="newSpaceFormRules" ref="newSpaceForm">
@@ -360,6 +360,8 @@
this.userSignOut();
} else if (command == 'aboutDoc') {
app.aboutDialogVisible = true;
} else if (command == 'console') {
window.location = this.apilist1.HOST;
} else {
toast.notOpen();
}

View File

@@ -24,7 +24,7 @@ export default {
} else if (res.data.errCode == 400) {
global.vue.$message('请先登录');
var href = encodeURIComponent(window.location.href);
window.location = apimix.apilist1.HOST + "/static/manage/login.html?redirect=" + href;
window.location = apimix.apilist1.HOST + "#/user/login?redirect=" + href;
} else if (res.data.errCode == 402) {
global.vue.$router.push("/common/noAuth");
} else if (res.data.errCode !== 200) {

View File

@@ -1,19 +1,21 @@
<template>
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
class="demo-ruleForm login-container">
<h3 class="title">系统登录</h3>
<el-form-item prop="userNo">
<el-input type="text" v-model="loginParam.userNo" auto-complete="off" placeholder="账号"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="loginParam.password" auto-complete="off" placeholder="密码"></el-input>
</el-form-item>
<el-form-item style="width:100%;">
<el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录
</el-button>
<!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
</el-form-item>
</el-form>
<div style="padding-top: 50px;" @keyup.enter="loginSubmit">
<el-form :model="loginParam" :rules="loginRules" ref="loginParam" label-position="left" label-width="0px"
class="demo-ruleForm login-container">
<h3 class="title">系统登录</h3>
<el-form-item prop="username">
<el-input type="text" v-model="loginParam.username" auto-complete="off" placeholder="账号"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="loginParam.password" auto-complete="off" placeholder="密码"></el-input>
</el-form-item>
<el-form-item style="width:100%;">
<el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录
</el-button>
<!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
</el-form-item>
</el-form>
</div>
</template>
<script>
@@ -21,12 +23,13 @@
data() {
return {
logining: false,
redirect: '',
loginParam: {
userNo: '',
username: '',
password: ''
},
loginRules: {
userNo: [
username: [
{required: true, message: '请输入账号', trigger: 'blur'},
],
password: [
@@ -36,21 +39,20 @@
checked: true
};
},
mounted: function () {
this.redirect = this.$route.query.redirect;
},
methods: {
loginSubmit(ev) {
loginSubmit() {
var that = this;
this.$refs.loginParam.validate((valid) => {
if (!valid) return;
that.common.post(that.apilist1.userLogin, that.loginParam, function (json) {
// 设置cookie
var token = escape(json.data);
var exp = new Date();
exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000);
document.cookie = "accessToken=" + token + ";expires=" + exp.toGMTString();
that.common.setAccessToken(token);
// 跳转
that.global.user.isLogin = true;
that.$router.push("/user/wxLogin");
if(!!that.redirect) {
location.href = decodeURIComponent(that.redirect);
} else {
that.$router.back();
}
});
});
}
@@ -64,7 +66,7 @@
border-radius: 5px;
-moz-border-radius: 5px;
background-clip: padding-box;
margin: 80px auto;
margin: 0 auto;
width: 350px;
padding: 35px 35px 15px 35px;
background: #fff;