swagger文档优化,数据库文档优化
This commit is contained in:
@@ -19,7 +19,7 @@ zyplayer-doc-swagger 原[swagger-mg-ui](https://gitee.com/zyplayer/swagger-mg-ui
|
||||
|
||||
#### 打开方式
|
||||
|
||||
1. 创建数据库:[zyplayer-doc-manage.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/zyplayer-doc-manage.sql)
|
||||
1. 创建数据库:[zyplayer_doc_manage.sql](https://gitee.com/zyplayer/zyplayer-doc/blob/master/zyplayer-doc-manage/src/main/resources/sql/zyplayer_doc_manage.sql)
|
||||
|
||||
2. 修改zyplayer-doc-manage项目的application.yml配置文件里面的数据库账号密码
|
||||
|
||||
|
||||
@@ -1,30 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<groupId>com.zyplayer</groupId>
|
||||
<artifactId>zyplayer-doc-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>zyplayer-doc-core</name>
|
||||
|
||||
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>3.4.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -9,6 +9,8 @@ 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;
|
||||
@@ -26,12 +28,12 @@ import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;
|
||||
|
||||
@Component
|
||||
public class ApplicationListenerBean implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
|
||||
@Autowired
|
||||
DatabaseRegistrationBean databaseRegistrationBean;
|
||||
|
||||
private volatile static boolean IS_INIT = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (databaseRegistrationBean == null || IS_INIT) {
|
||||
@@ -40,6 +42,7 @@ 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 {
|
||||
@@ -99,6 +102,7 @@ public class ApplicationListenerBean implements ApplicationListener<ContextRefre
|
||||
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);
|
||||
@@ -111,5 +115,5 @@ public class ApplicationListenerBean implements ApplicationListener<ContextRefre
|
||||
}
|
||||
databaseRegistrationBean.setDatabaseFactoryBeanList(databaseFactoryBeanList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.zyplayer.doc.db.framework.db.interceptor;
|
||||
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.ParameterMapping;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
@Intercepts({
|
||||
@Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }),
|
||||
@Signature(type = Executor.class, method = "query", args = { MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class })
|
||||
})
|
||||
public class SqlLogInterceptor implements Interceptor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SqlLogInterceptor.class);
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
||||
Object parameter = null;
|
||||
if (invocation.getArgs().length > 1) {
|
||||
parameter = invocation.getArgs()[1];
|
||||
}
|
||||
BoundSql boundSql = mappedStatement.getBoundSql(parameter);
|
||||
Configuration configuration = mappedStatement.getConfiguration();
|
||||
// 获取sql语句
|
||||
String sql = getSqlString(configuration, boundSql);
|
||||
LOGGER.info(sql);
|
||||
// 执行结果
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
if (target instanceof Executor) {
|
||||
return Plugin.wrap(target, this);
|
||||
} else {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
}
|
||||
|
||||
private String getParameterValue(Object obj) {
|
||||
String value = null;
|
||||
if (obj instanceof String) {
|
||||
value = "'" + obj.toString() + "'";
|
||||
} else if (obj instanceof Date) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.CHINA);
|
||||
value = "'" + formatter.format(obj) + "'";
|
||||
//System.out.println(value);
|
||||
} else {
|
||||
if (obj != null) {
|
||||
value = obj.toString();
|
||||
} else {
|
||||
value = "'null'";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getSqlString(Configuration configuration, BoundSql boundSql) {
|
||||
Object parameterObject = boundSql.getParameterObject();
|
||||
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
||||
StringBuilder sqlSb = new StringBuilder(boundSql.getSql().replaceAll("[\\s]+", " "));
|
||||
int fromIndex = 0;
|
||||
if (parameterMappings.size() > 0 && parameterObject != null) {
|
||||
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
|
||||
if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
|
||||
//sqlSb = sqlSb.replaceFirst("\\?", getParameterValue(parameterObject));
|
||||
fromIndex = replacePlaceholder(sqlSb, fromIndex, getParameterValue(parameterObject));
|
||||
} else {
|
||||
MetaObject metaObject = configuration.newMetaObject(parameterObject);
|
||||
for (ParameterMapping parameterMapping : parameterMappings) {
|
||||
String propertyName = parameterMapping.getProperty();
|
||||
if (metaObject.hasGetter(propertyName)) {
|
||||
Object obj = metaObject.getValue(propertyName);
|
||||
//sqlSb = sqlSb.replaceFirst("\\?", getParameterValue(obj));
|
||||
fromIndex = replacePlaceholder(sqlSb, fromIndex, getParameterValue(obj));
|
||||
} else if (boundSql.hasAdditionalParameter(propertyName)) {
|
||||
Object obj = boundSql.getAdditionalParameter(propertyName);
|
||||
//sqlSb = sqlSb.replaceFirst("\\?", getParameterValue(obj));
|
||||
fromIndex = replacePlaceholder(sqlSb, fromIndex, getParameterValue(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlSb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换?占位符
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年10月27日
|
||||
* @param sql
|
||||
* @param fromIndex
|
||||
* @param replaceStr
|
||||
* @return
|
||||
*/
|
||||
private int replacePlaceholder(StringBuilder sql, int fromIndex, String replaceStr) {
|
||||
int index = sql.indexOf("?", fromIndex);
|
||||
if (index >= 0) {
|
||||
sql.replace(index, index + 1, replaceStr);
|
||||
}
|
||||
return index + replaceStr.length();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,68 @@
|
||||
<?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.db.framework.db.mapper.base.BaseMapper">
|
||||
|
||||
<resultMap id="TableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto" >
|
||||
<result column="NAME" property="name" jdbcType="VARCHAR" />
|
||||
<result column="ISIDENITY" property="isidenity" jdbcType="VARCHAR" />
|
||||
<result column="TYPE" property="type" jdbcType="VARCHAR" />
|
||||
<result column="NULLABLE" property="nullable" jdbcType="VARCHAR" />
|
||||
<result column="LENGTH" property="length" jdbcType="VARCHAR" />
|
||||
<result column="ISPRAMARY" property="ispramary" jdbcType="VARCHAR" />
|
||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="QueryTableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.QueryTableColumnDescDto" >
|
||||
<result column="TABLE_NAME" property="tableName" jdbcType="VARCHAR" />
|
||||
<result column="COLUMN_NAME" property="columnName" jdbcType="VARCHAR" />
|
||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getDatabaseList" resultType="com.zyplayer.doc.db.framework.db.dto.DatabaseInfoDto">
|
||||
select TABLE_SCHEMA dbName
|
||||
from information_schema.tables
|
||||
group by TABLE_SCHEMA
|
||||
</select>
|
||||
|
||||
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
|
||||
select table_name tableName, table_comment as tableComment
|
||||
from information_schema.tables
|
||||
where table_schema=#{dbName}
|
||||
</select>
|
||||
|
||||
<select id="getTableColumnList" resultMap="TableColumnDescDtoMap">
|
||||
SELECT COLUMN_NAME NAME,column_comment DESCRIPTION,column_type TYPE,if(is_nullable='YES',1,0) NULLABLE
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE table_schema=#{dbName} AND table_name=#{tableName}
|
||||
</select>
|
||||
|
||||
<select id="getTableColumnDescList" resultMap="TableColumnDescDtoMap">
|
||||
select 1
|
||||
</select>
|
||||
|
||||
<select id="getTableAndColumnBySearch" resultMap="QueryTableColumnDescDtoMap">
|
||||
SELECT TABLE_NAME, COLUMN_NAME, column_comment DESCRIPTION
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE table_schema=#{dbName} AND (COLUMN_NAME like #{searchText} or column_comment like #{searchText})
|
||||
</select>
|
||||
|
||||
<select id="getTableDescList" resultType="com.zyplayer.doc.db.framework.db.dto.TableDescDto">
|
||||
select table_name tableName, table_comment as description
|
||||
from information_schema.tables
|
||||
<if test="tableName != null">
|
||||
where table_name=#{tableName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="updateTableDesc">
|
||||
alter table ${dbName}.${tableName} comment #{newDesc}
|
||||
</insert>
|
||||
|
||||
<insert id="updateTableColumnDesc">
|
||||
alter table ${dbName}.${tableName} modify column ${columnName}
|
||||
${columnInfo.columnType} ${columnInfo.isNullable} ${columnInfo.columnDefault} ${columnInfo.extra}
|
||||
comment #{newDesc}
|
||||
<?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.db.framework.db.mapper.base.BaseMapper">
|
||||
|
||||
<resultMap id="TableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.TableColumnDescDto" >
|
||||
<result column="NAME" property="name" jdbcType="VARCHAR" />
|
||||
<result column="ISIDENITY" property="isidenity" jdbcType="VARCHAR" />
|
||||
<result column="TYPE" property="type" jdbcType="VARCHAR" />
|
||||
<result column="NULLABLE" property="nullable" jdbcType="VARCHAR" />
|
||||
<result column="LENGTH" property="length" jdbcType="VARCHAR" />
|
||||
<result column="ISPRAMARY" property="ispramary" jdbcType="VARCHAR" />
|
||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="QueryTableColumnDescDtoMap" type="com.zyplayer.doc.db.framework.db.dto.QueryTableColumnDescDto" >
|
||||
<result column="TABLE_NAME" property="tableName" jdbcType="VARCHAR" />
|
||||
<result column="COLUMN_NAME" property="columnName" jdbcType="VARCHAR" />
|
||||
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getDatabaseList" resultType="com.zyplayer.doc.db.framework.db.dto.DatabaseInfoDto">
|
||||
select TABLE_SCHEMA dbName
|
||||
from information_schema.tables
|
||||
group by TABLE_SCHEMA
|
||||
</select>
|
||||
|
||||
<select id="getTableList" resultType="com.zyplayer.doc.db.framework.db.dto.TableInfoDto">
|
||||
select table_name tableName, table_comment as tableComment
|
||||
from information_schema.tables
|
||||
where table_schema=#{dbName}
|
||||
</select>
|
||||
|
||||
<select id="getTableColumnList" resultMap="TableColumnDescDtoMap">
|
||||
SELECT COLUMN_NAME NAME,column_comment DESCRIPTION,column_type TYPE,if(is_nullable='YES',1,0) NULLABLE
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE table_schema=#{dbName} AND table_name=#{tableName}
|
||||
ORDER BY ordinal_position
|
||||
</select>
|
||||
|
||||
<select id="getTableColumnDescList" resultMap="TableColumnDescDtoMap">
|
||||
select 1
|
||||
</select>
|
||||
|
||||
<select id="getTableAndColumnBySearch" resultMap="QueryTableColumnDescDtoMap">
|
||||
SELECT TABLE_NAME, COLUMN_NAME, column_comment DESCRIPTION
|
||||
FROM INFORMATION_SCHEMA.Columns
|
||||
WHERE table_schema=#{dbName} AND (COLUMN_NAME like #{searchText} or column_comment like #{searchText})
|
||||
</select>
|
||||
|
||||
<select id="getTableDescList" resultType="com.zyplayer.doc.db.framework.db.dto.TableDescDto">
|
||||
select table_name tableName, table_comment as description
|
||||
from information_schema.tables
|
||||
<if test="tableName != null">
|
||||
where table_name=#{tableName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="updateTableDesc">
|
||||
alter table ${dbName}.${tableName} comment #{newDesc}
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
<insert id="updateTableColumnDesc">
|
||||
alter table ${dbName}.${tableName} modify column ${columnName}
|
||||
${columnInfo.columnType} ${columnInfo.isNullable} ${columnInfo.columnDefault} ${columnInfo.extra}
|
||||
comment #{newDesc}
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,58 +1,66 @@
|
||||
package com.zyplayer.doc.manage.web.manage;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
|
||||
@RestController
|
||||
public class LoginController {
|
||||
private RequestCache requestCache = new HttpSessionRequestCache();
|
||||
|
||||
@GetMapping(value = "/login")
|
||||
public ModelAndView loginPage(HttpServletRequest request) {
|
||||
return new ModelAndView("/statics/manage/login.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果是访问受限页面后,跳转到登录页的,则在targetUrl保存之前受限页面的路径,供页面调用
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/login/success")
|
||||
public DocResponseJson<String> loginSuccess(HttpServletRequest request, HttpServletResponse response) {
|
||||
SavedRequest savedRequest = requestCache.getRequest(request, response);
|
||||
String targetUrl = null;
|
||||
if (savedRequest != null) {
|
||||
targetUrl = savedRequest.getRedirectUrl();
|
||||
}
|
||||
if (StringUtils.isBlank(targetUrl)) {
|
||||
targetUrl = "/";
|
||||
}
|
||||
return DocResponseJson.ok(targetUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常信息返回给页面
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/login/failure")
|
||||
public DocResponseJson<String> loginFailure(HttpServletRequest request, HttpServletResponse response) {
|
||||
AuthenticationException ae = (AuthenticationException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
|
||||
return DocResponseJson.warn(ae.getMessage());
|
||||
}
|
||||
package com.zyplayer.doc.manage.web.manage;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
|
||||
@RestController
|
||||
public class LoginController {
|
||||
private RequestCache requestCache = new HttpSessionRequestCache();
|
||||
|
||||
@GetMapping(value = "/login")
|
||||
public ModelAndView loginPage(HttpServletRequest request) {
|
||||
return new ModelAndView("/statics/manage/login.html");
|
||||
}
|
||||
|
||||
// @PostMapping(value = "/logout")
|
||||
// public DocResponseJson<Object> logout(HttpServletRequest request) {
|
||||
//
|
||||
// return DocResponseJson.ok();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 如果是访问受限页面后,跳转到登录页的,则在targetUrl保存之前受限页面的路径,供页面调用
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/login/success")
|
||||
public DocResponseJson<String> loginSuccess(HttpServletRequest request, HttpServletResponse response) {
|
||||
SavedRequest savedRequest = requestCache.getRequest(request, response);
|
||||
String targetUrl = null;
|
||||
if (savedRequest != null) {
|
||||
targetUrl = savedRequest.getRedirectUrl();
|
||||
}
|
||||
if (StringUtils.isBlank(targetUrl)) {
|
||||
targetUrl = "/";
|
||||
}
|
||||
return DocResponseJson.ok(targetUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常信息返回给页面
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/login/failure")
|
||||
public DocResponseJson<String> loginFailure(HttpServletRequest request, HttpServletResponse response) {
|
||||
AuthenticationException ae = (AuthenticationException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
|
||||
return DocResponseJson.warn(ae.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -27,24 +27,24 @@ server:
|
||||
|
||||
zyplayer:
|
||||
doc:
|
||||
# zyplayer-doc-manage管理端的数据库配置
|
||||
# zyplayer_doc_manage管理端的数据库配置
|
||||
manage:
|
||||
datasource:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/zyplayer-doc-manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
url: jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
# 数据库文档相关
|
||||
# 打开/zyplayer-doc-manage/doc-db.html即可看到这里配置的数据库的文档
|
||||
# 打开/zyplayer_doc_manage/doc-db.html即可看到这里配置的数据库的文档
|
||||
db:
|
||||
dbConfigList:
|
||||
- driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/zyplayer-doc-manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
url: jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
# 多个数据源直接这样累加
|
||||
# - driverClassName: com.mysql.jdbc.Driver
|
||||
# url: jdbc:mysql://127.0.0.1:3306/zyplayer-doc-manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
# url: jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false
|
||||
# username: root
|
||||
# password: root
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 80012
|
||||
Source Host : localhost:3306
|
||||
Source Schema : zyplayer-doc-manage
|
||||
Source Schema : zyplayer_doc_manage
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 80012
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 15/12/2018 22:34:43
|
||||
Date: 22/12/2018 22:58:00
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@@ -25,11 +25,11 @@ CREATE TABLE `auth_info` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`auth_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限名',
|
||||
`auth_desc` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限说明',
|
||||
`can_edit` tinyint(4) NULL DEFAULT NULL COMMENT '是否可编辑 0=否 1=是',
|
||||
`can_edit` tinyint(4) NULL DEFAULT 1 COMMENT '是否可编辑 0=否 1=是',
|
||||
`create_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建人用户ID',
|
||||
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '权限信息表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of auth_info
|
||||
@@ -53,19 +53,11 @@ CREATE TABLE `user_auth` (
|
||||
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户权限表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user_auth
|
||||
-- ----------------------------
|
||||
INSERT INTO `user_auth` VALUES (1, 1, 1, 1, 1, 1, '2018-12-01 11:41:13', '2018-12-15 22:19:59');
|
||||
INSERT INTO `user_auth` VALUES (2, 1, 2, 1, 1, 1, '2018-12-15 19:51:13', '2018-12-15 22:19:59');
|
||||
INSERT INTO `user_auth` VALUES (3, 1, 3, 1, 1, 1, '2018-12-15 19:51:28', '2018-12-15 22:19:59');
|
||||
INSERT INTO `user_auth` VALUES (4, 1, 4, 1, 1, 1, '2018-12-15 19:51:40', '2018-12-15 22:19:59');
|
||||
INSERT INTO `user_auth` VALUES (5, 1, 1, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (6, 1, 2, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (7, 1, 3, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (8, 1, 4, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (9, 2, 1, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (10, 2, 2, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (11, 2, 3, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
@@ -74,6 +66,10 @@ INSERT INTO `user_auth` VALUES (13, 3, 1, 1, NULL, 0, '2018-12-15 22:19:59', NUL
|
||||
INSERT INTO `user_auth` VALUES (14, 3, 2, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (15, 3, 3, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (16, 3, 4, 1, NULL, 0, '2018-12-15 22:19:59', NULL);
|
||||
INSERT INTO `user_auth` VALUES (24, 1, 1, 1, NULL, 0, '2018-12-16 21:41:01', NULL);
|
||||
INSERT INTO `user_auth` VALUES (25, 1, 2, 1, NULL, 0, '2018-12-16 21:41:01', NULL);
|
||||
INSERT INTO `user_auth` VALUES (26, 1, 3, 1, NULL, 0, '2018-12-16 21:41:01', NULL);
|
||||
INSERT INTO `user_auth` VALUES (27, 1, 4, 1, NULL, 0, '2018-12-16 21:41:01', NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user_info
|
||||
@@ -92,7 +88,7 @@ CREATE TABLE `user_info` (
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `idx_userNo`(`user_no`) USING BTREE COMMENT '登录用户名'
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户信息表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user_info
|
||||
@@ -106,17 +102,16 @@ INSERT INTO `user_info` VALUES (3, '2', NULL, '11', '11', NULL, 0, '2018-12-15 2
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `zyplayer_storage`;
|
||||
CREATE TABLE `zyplayer_storage` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`doc_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`doc_value` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
`creation_time` datetime(0) NULL DEFAULT NULL,
|
||||
`update_time` datetime(0) NULL DEFAULT NULL,
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数名字',
|
||||
`doc_value` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数值',
|
||||
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `key`(`doc_key`) USING BTREE COMMENT 'key唯一索引'
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '存储网页上相关的数据' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of zyplayer_storage
|
||||
-- ----------------------------
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -47,6 +47,13 @@
|
||||
<li><a target="_blank" href="../../swagger-ui.html"><i class="icon-window"></i> springfox-swagger-ui</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="icon icon-window-alt"></i> 信息管理</a>
|
||||
<ul>
|
||||
<li><a href="#" class="page-nav" data-id="operation-log" data-href="./user/operation-log.html" data-icon="icon-check-board" data-reload="1"><i class="icon-check-board"></i> 操作日志</a></li>
|
||||
<li><a href="#" class="user-signout"><i class="icon-signout"></i> 退出登录</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,6 +122,14 @@
|
||||
$("#showLeftContent").hide();
|
||||
changeContentWidth(360);
|
||||
});
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
$(".user-signout").click(function () {
|
||||
post(ctx + "logout", {}, function () {}, function () {}, function () {
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 页面导航切换
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html xmlns:v-on="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>操作日志</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../lib/zui/css/zui.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
操作日志,暂未开发
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script src="../../lib/jquery/jquery-3.1.0.min.js"></script>
|
||||
<script src="../../lib/zui/js/zui.min.js"></script>
|
||||
<script src="../../lib/vue/vue.js"></script>
|
||||
<script src="../../lib/mg/js/common.js"></script>
|
||||
<script src="../../lib/mg/js/toast.js"></script>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
},
|
||||
mounted: function(){
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body{padding: 10px;}
|
||||
</style>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,6 @@
|
||||
<ul class="nav nav-secondary gray">
|
||||
<li class="active"><a data-tab href="#docRequestParam">说明</a></li>
|
||||
<li><a data-tab href="#docRequestExample">例子</a></li>
|
||||
<!-- <i class="icon icon-info-sign" title='例:@ApiModelProperty(value="用户ID", example = "9527"),将example填入对象值里面'></i> -->
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane tab-param-type-pane active" id="docRequestParam">
|
||||
@@ -203,7 +202,7 @@
|
||||
<div class="panel-heading" id="headingOne">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#tabParamHeader">请求头</a>
|
||||
<label><input type="checkbox" id="bulkEditHeaderCheck" value="1"> 批量编辑</label>
|
||||
<label class="overwrite-label"><input type="checkbox" id="bulkEditHeaderCheck" value="1"> 批量编辑</label>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="tabParamHeader" class="panel-collapse collapse in">
|
||||
|
||||
@@ -12,7 +12,9 @@ ul{list-style: none;list-style-type: none;}
|
||||
.tree-menu li li li li li li li li li li a{padding-left: 188px;}
|
||||
.table td, .table th {vertical-align: middle;}
|
||||
#tabDocInfo{position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
|
||||
#tabOnlineDebug .param-response-box{position: absolute; bottom: 0;top: 100px;overflow-y: auto; right: 0; left: 10px;}
|
||||
#tabOnlineDebug .param-response-box{position: absolute; bottom: 0;top: 100px;overflow-y: auto; right: 0; left: 10px;padding-right: 10px;}
|
||||
#tabOnlineDebug .panel{margin-bottom: 10px;}
|
||||
#requestParamForm .nav > li > a{padding: 6px 15px;}
|
||||
|
||||
.local-storage{display: none;}
|
||||
|
||||
@@ -20,6 +22,7 @@ ul{list-style: none;list-style-type: none;}
|
||||
.label{font-size: 100%;}
|
||||
.label-warning {background-color: #f9f5ee; color: #f1a325;}
|
||||
label{font-weight: normal;}
|
||||
.overwrite-label{margin-bottom: 0;}
|
||||
|
||||
.nav.gray{background-color: #f1f1f1;margin-bottom: 10px;}
|
||||
|
||||
@@ -83,11 +86,12 @@ label{font-weight: normal;}
|
||||
.post-url-box .send-request .hide{display: none;}
|
||||
|
||||
.param-box{}
|
||||
.param-box .panel-collapse{padding: 10px;}
|
||||
.param-box .panel-collapse{padding: 10px 10px 0 10px;}
|
||||
.param-box .nav{background-color: #f1f1f1;}
|
||||
.param-box .table{margin-bottom: 0;}
|
||||
/* .param-box .nav > li > *{padding: 8px 25px;} */
|
||||
.param-box .nav > li > span{position: relative; display: block;background-color: #ccc;padding: 9px 25px;}
|
||||
.param-box .nav > .form-to-url{position: relative; display: block;padding: 10px 0 0 25px;}
|
||||
.param-box .nav > .form-to-url{position: relative; display: block;padding: 8px 0 0 25px;}
|
||||
.param-box .nav > .form-to-url label{margin: 0;}
|
||||
.param-box .nav > .form-to-url input{margin: 0;}
|
||||
.param-box .tab-content .tab-param-pane{padding: 10px 10px 0 10px;}
|
||||
@@ -98,10 +102,10 @@ label{font-weight: normal;}
|
||||
.param-box .param-table tbody td:nth-child(3) i{cursor: pointer;color: #ccc;}
|
||||
.param-box .param-table tbody td:nth-child(3) i:hover{color: #888;}
|
||||
.param-box .param-table tbody tr.base td:last-child i{display: none;}
|
||||
#bulkEditHeaderCheck{margin-left: 10px;}
|
||||
#bulkEditHeaderCheck{margin: 0 0 0 10px;}
|
||||
#bulkEditHeader,#bulkEditForm{display: none;}
|
||||
|
||||
.response-box{margin-top: 20px;}
|
||||
.response-box{margin-top: 10px;}
|
||||
.response-box .nav > li > *{padding: 8px 25px;}
|
||||
.response-box .nav > li span{position: relative; display: block;padding: 9px 25px;}
|
||||
.response-box .nav > li.info span{background-color: #ccc;}
|
||||
@@ -113,7 +117,7 @@ label{font-weight: normal;}
|
||||
#responseBodyJsonIframe{width: 100%;height: 300px;border: 0;}
|
||||
|
||||
/* S-模拟请求 */
|
||||
#tabSimulationResult{padding: 10px 0;}
|
||||
#tabSimulationResult{padding: 0 10px 0 0;position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
|
||||
/* E-模拟请求 */
|
||||
|
||||
/* S-JSON展示的样式 */
|
||||
|
||||
Reference in New Issue
Block a user