删除database-api模块,增加database模块,调整依赖
This commit is contained in:
parent
aadb902d22
commit
ff1bb105dd
@ -1,11 +0,0 @@
|
|||||||
package ink.wgink.database.api.controller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName: DemoController
|
|
||||||
* @Description:
|
|
||||||
* @Author: wanggeng
|
|
||||||
* @Date: 2022/1/18 11:08 AM
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
public class DemoController {
|
|
||||||
}
|
|
@ -9,7 +9,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>module-database-api</artifactId>
|
<artifactId>module-database</artifactId>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
@ -0,0 +1,34 @@
|
|||||||
|
package ink.wgink.database.aop;
|
||||||
|
|
||||||
|
import ink.wgink.exceptions.base.SystemException;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Around;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: JdbcAop
|
||||||
|
* @Description: jdbcAop
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 11:10 上午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class JdbcAop {
|
||||||
|
|
||||||
|
@Around("execution(public * ink.wgink.database.service..*.*(..))")
|
||||||
|
public Object apiLogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||||
|
try {
|
||||||
|
return proceedingJoinPoint.proceed();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
if (e instanceof SQLException) {
|
||||||
|
throw new SystemException(e.getMessage());
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
package ink.wgink.database.controller.api.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.database.pojo.dtos.mysql.MysqlDTO;
|
||||||
|
import ink.wgink.database.pojo.vos.mysql.MysqlVO;
|
||||||
|
import ink.wgink.database.service.mysql.IMysqlService;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlController
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "mysql连接接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/mysql")
|
||||||
|
public class MysqlController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMysqlService mysqlService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增mysql连接", notes = "新增mysql连接接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("save")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult save(@RequestBody MysqlVO mysqlVO) {
|
||||||
|
mysqlService.save(mysqlVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除mysql连接", notes = "删除mysql连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@DeleteMapping("remove/{ids}")
|
||||||
|
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||||
|
mysqlService.remove(Arrays.asList(ids.split("\\_")));
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改mysql连接", notes = "修改mysql连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "mysql连接ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update/{mysqlId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult update(@PathVariable("mysqlId") String mysqlId, @RequestBody MysqlVO mysqlVO) {
|
||||||
|
mysqlService.update(mysqlId, mysqlVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接详情", notes = "mysql连接详情接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "mysql连接ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("get/{mysqlId}")
|
||||||
|
public MysqlDTO get(@PathVariable("mysqlId") String mysqlId) {
|
||||||
|
return mysqlService.get(mysqlId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接列表", notes = "mysql连接列表接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list")
|
||||||
|
public List<MysqlDTO> list() {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return mysqlService.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接分页列表", notes = "mysql连接分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<MysqlDTO>> listPage(ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return mysqlService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接统计", notes = "mysql连接统计接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("count")
|
||||||
|
SuccessResultData<Integer> count() {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return new SuccessResultData<>(mysqlService.count(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package ink.wgink.database.controller.api.mysql.jdbc;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.database.pojo.vos.sql.SqlVO;
|
||||||
|
import ink.wgink.database.service.jdbc.IJdbcService;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlJdbcController
|
||||||
|
* @Description: Mysql JDBC
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/26 11:41 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "mysql jdbc接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/mysql/jdbc")
|
||||||
|
public class MysqlJdbcController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IJdbcService jdbcService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "是否已经连接", notes = "是否已经连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("is-connected/{mysqlId}")
|
||||||
|
public SuccessResultData<Boolean> isConnected(@PathVariable("mysqlId") String mysqlId) {
|
||||||
|
Boolean isConnected = jdbcService.isConnected(mysqlId);
|
||||||
|
return new SuccessResultData<>(isConnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "打开连接", notes = "打开连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("open-connection/{mysqlId}")
|
||||||
|
public SuccessResult openConnection(@PathVariable("mysqlId") String mysqlId) throws SQLException {
|
||||||
|
jdbcService.openConnection(mysqlId);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "关闭连接", notes = "关闭连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("close-connection/{mysqlId}")
|
||||||
|
public SuccessResult closeConnection(@PathVariable("mysqlId") String mysqlId) throws SQLException {
|
||||||
|
jdbcService.closeConnection(mysqlId);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "图示列表", notes = "图示列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list-schemata/{mysqlId}")
|
||||||
|
public List<Map<String, Object>> listSchemata(@PathVariable("mysqlId") String mysqlId) throws SQLException {
|
||||||
|
return jdbcService.listSchemata(mysqlId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "表列表", notes = "表列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list-table/{mysqlId}/{schemata}")
|
||||||
|
public List<Map<String, Object>> listTable(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@PathVariable("schemata") String schemata) throws SQLException {
|
||||||
|
return jdbcService.listTable(mysqlId, schemata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "字段列表", notes = "字段列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "table", value = "表名", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list-field/{mysqlId}/{schemata}/{table}")
|
||||||
|
public List<Map<String, Object>> listField(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@PathVariable("schemata") String schemata,
|
||||||
|
@PathVariable("table") String table) throws SQLException {
|
||||||
|
return jdbcService.listField(mysqlId, schemata, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "数据列表", notes = "数据列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "table", value = "表名", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list-data/{mysqlId}/{schemata}/{table}")
|
||||||
|
public List<Map<String, Object>> listData(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@PathVariable("schemata") String schemata,
|
||||||
|
@PathVariable("table") String table) throws SQLException {
|
||||||
|
return jdbcService.listData(mysqlId, schemata, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "数据列表", notes = "数据列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "table", value = "表名", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("list-data/{mysqlId}/{schemata}/{table}")
|
||||||
|
public List<Map<String, Object>> listData(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@PathVariable("schemata") String schemata,
|
||||||
|
@PathVariable("table") String table,
|
||||||
|
@RequestBody SqlVO sqlVO) throws SQLException {
|
||||||
|
return jdbcService.listData(mysqlId, schemata, table, sqlVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "数据分页列表", notes = "数据分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "table", value = "表名", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage-data/{mysqlId}/{schemata}/{table}")
|
||||||
|
public SuccessResultList<List<Map<String, Object>>> listPageData(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@PathVariable("schemata") String schemata,
|
||||||
|
@PathVariable("table") String table,
|
||||||
|
@RequestParam(name = "page", defaultValue = "1", required = false) int page,
|
||||||
|
@RequestParam(name = "size", defaultValue = "20", required = false) int size) throws SQLException {
|
||||||
|
return jdbcService.listPageData(mysqlId, schemata, table, page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "执行SQL", notes = "数据分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "主键", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "schemata", value = "图示", paramType = "path"),
|
||||||
|
@ApiImplicitParam(name = "table", value = "表名", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("execute-sql/{mysqlId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult executeSql(@PathVariable("mysqlId") String mysqlId,
|
||||||
|
@RequestParam(name = "page", defaultValue = "1", required = false) int page,
|
||||||
|
@RequestParam(name = "size", defaultValue = "20", required = false) int size,
|
||||||
|
@RequestBody SqlVO sqlVO) throws SQLException {
|
||||||
|
String sql = sqlVO.getSql();
|
||||||
|
if (sql.startsWith("select") || sql.startsWith("SELECT")) {
|
||||||
|
return jdbcService.listPageQuerySql(mysqlId, page, size, sqlVO);
|
||||||
|
}
|
||||||
|
jdbcService.updateSql(mysqlId, sqlVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package ink.wgink.database.controller.app.api.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.database.pojo.dtos.mysql.MysqlDTO;
|
||||||
|
import ink.wgink.database.pojo.vos.mysql.MysqlVO;
|
||||||
|
import ink.wgink.database.service.mysql.IMysqlService;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlAppController
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "mysql连接接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.APP_PREFIX + "/mysql")
|
||||||
|
public class MysqlAppController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMysqlService mysqlService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增mysql连接", notes = "新增mysql连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("save")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult save(@RequestHeader("token") String token, @RequestBody MysqlVO mysqlVO) {
|
||||||
|
mysqlService.save(token, mysqlVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除mysql连接(id列表)", notes = "删除mysql连接(id列表)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@DeleteMapping("remove/{ids}")
|
||||||
|
public SuccessResult remove(@RequestHeader("token") String token, @PathVariable("ids") String ids) {
|
||||||
|
mysqlService.remove(token, Arrays.asList(ids.split("\\_")));
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改mysql连接", notes = "修改mysql连接接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "mysql连接ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("updatemysql/{mysqlId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult updateMysql(@RequestHeader("token") String token, @PathVariable("mysqlId") String mysqlId, @RequestBody MysqlVO mysqlVO) {
|
||||||
|
mysqlService.update(token, mysqlId, mysqlVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接详情(通过ID)", notes = "mysql连接详情(通过ID)接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
@ApiImplicitParam(name = "mysqlId", value = "mysql连接ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("get/{mysqlId}")
|
||||||
|
public MysqlDTO get(@RequestHeader("token") String token, @PathVariable("mysqlId") String mysqlId) {
|
||||||
|
return mysqlService.get(mysqlId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接列表", notes = "mysql连接列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list")
|
||||||
|
public List<MysqlDTO> list(@RequestHeader("token") String token) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return mysqlService.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接分页列表", notes = "mysql连接分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpagemysql")
|
||||||
|
public SuccessResultList<List<MysqlDTO>> listPage(@RequestHeader("token") String token, ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return mysqlService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "mysql连接统计", notes = "mysql连接统计接口")
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("count")
|
||||||
|
SuccessResultData<Integer> count() {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return new SuccessResultData<>(mysqlService.count(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package ink.wgink.database.controller.route.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlController
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "mysql连接路由")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/mysql")
|
||||||
|
public class MysqlRouteController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@GetMapping("save")
|
||||||
|
public ModelAndView save() {
|
||||||
|
return new ModelAndView("mysql/save");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("update")
|
||||||
|
public ModelAndView update() {
|
||||||
|
return new ModelAndView("mysql/update");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
public ModelAndView list() {
|
||||||
|
return new ModelAndView("mysql/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package ink.wgink.database.controller.route.mysql.jdbc;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlController
|
||||||
|
* @Description: mysql jdbc
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "mysql jdbc路由")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/mysql/jdbc")
|
||||||
|
public class MysqlJdbcRouteController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@GetMapping("query")
|
||||||
|
public ModelAndView save() {
|
||||||
|
return new ModelAndView("mysql/jdbc/query");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package ink.wgink.database.dao.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.database.pojo.bos.mysql.MysqlBO;
|
||||||
|
import ink.wgink.database.pojo.dtos.mysql.MysqlDTO;
|
||||||
|
import ink.wgink.database.pojo.pos.mysql.MysqlPO;
|
||||||
|
import ink.wgink.exceptions.RemoveException;
|
||||||
|
import ink.wgink.exceptions.SaveException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import ink.wgink.interfaces.init.IInitBaseTable;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IMysqlDao
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Repository
|
||||||
|
public interface IMysqlDao extends IInitBaseTable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mysql连接
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws SaveException
|
||||||
|
*/
|
||||||
|
void save(Map<String, Object> params) throws SaveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mysql连接
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws RemoveException
|
||||||
|
*/
|
||||||
|
void remove(Map<String, Object> params) throws RemoveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mysql连接(物理)
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws RemoveException
|
||||||
|
*/
|
||||||
|
void delete(Map<String, Object> params) throws RemoveException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mysql连接
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @throws UpdateException
|
||||||
|
*/
|
||||||
|
void update(Map<String, Object> params) throws UpdateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
MysqlDTO get(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
MysqlBO getBO(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
MysqlPO getPO(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
List<MysqlDTO> list(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
List<MysqlBO> listBO(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
List<MysqlPO> listPO(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接统计
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
* @throws SearchException
|
||||||
|
*/
|
||||||
|
Integer count(Map<String, Object> params) throws SearchException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package ink.wgink.database.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ConnectionTypeEnum
|
||||||
|
* @Description: 连接类型枚举
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 4:42 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public enum ConnectionTypeEnum {
|
||||||
|
MYSQL("mysql");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
ConnectionTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value == null ? "" : value.trim();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package ink.wgink.database.manager;
|
||||||
|
|
||||||
|
import ink.wgink.database.enums.ConnectionTypeEnum;
|
||||||
|
import ink.wgink.database.manager.entity.ActiveConnection;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ConnectionManager
|
||||||
|
* @Description: 连接管理器
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 4:31 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class ActiveConnectionManager {
|
||||||
|
private static ActiveConnectionManager connectionManager = ConnectionManagerBuilder.CONNECTION_MANAGER;
|
||||||
|
private Map<String, ActiveConnection> mysqlConnectionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private ActiveConnectionManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ActiveConnectionManager getInstance() {
|
||||||
|
return connectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(ConnectionTypeEnum connectionTypeEnum, String id, Connection connection) {
|
||||||
|
if (ConnectionTypeEnum.MYSQL.equals(connectionTypeEnum)) {
|
||||||
|
mysqlConnectionMap.put(id, new ActiveConnection(id, connection));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActiveConnection getActiveConnection(ConnectionTypeEnum connectionTypeEnum, String id) {
|
||||||
|
if (ConnectionTypeEnum.MYSQL.equals(connectionTypeEnum)) {
|
||||||
|
return mysqlConnectionMap.get(id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection getConnection(ConnectionTypeEnum connectionTypeEnum, String id) {
|
||||||
|
ActiveConnection activeConnection = getActiveConnection(connectionTypeEnum, id);
|
||||||
|
if (activeConnection == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
activeConnection.setLastUpdateTime(System.currentTimeMillis());
|
||||||
|
return activeConnection.getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeConnection(ConnectionTypeEnum connectionTypeEnum, String id) throws SQLException {
|
||||||
|
ActiveConnection activeConnection = getActiveConnection(connectionTypeEnum, id);
|
||||||
|
if (activeConnection == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Connection connection = activeConnection.getConnection();
|
||||||
|
if (connection.isClosed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
connection.close();
|
||||||
|
mysqlConnectionMap.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class ConnectionManagerBuilder {
|
||||||
|
public static ActiveConnectionManager CONNECTION_MANAGER = new ActiveConnectionManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package ink.wgink.database.manager.entity;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ActiveConnection
|
||||||
|
* @Description: 激活的连接
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 4:40 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class ActiveConnection {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private Connection connection;
|
||||||
|
private long lastUpdateTime;
|
||||||
|
|
||||||
|
public ActiveConnection(String id, Connection connection) {
|
||||||
|
this.id = id;
|
||||||
|
this.connection = connection;
|
||||||
|
this.lastUpdateTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id == null ? "" : id.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnection(Connection connection) {
|
||||||
|
this.connection = connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastUpdateTime() {
|
||||||
|
return lastUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastUpdateTime(long lastUpdateTime) {
|
||||||
|
this.lastUpdateTime = lastUpdateTime;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package ink.wgink.database.pojo.bos.mysql;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName: MysqlBO
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
public class MysqlBO {
|
||||||
|
|
||||||
|
private String mysqlId;
|
||||||
|
private String mysqlName;
|
||||||
|
private String mysqlHost;
|
||||||
|
private String mysqlPort;
|
||||||
|
private String mysqlUsername;
|
||||||
|
private String mysqlPassword;
|
||||||
|
private String creator;
|
||||||
|
private String gmtCreate;
|
||||||
|
private String modifier;
|
||||||
|
private String gmtModified;
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
public String getMysqlId() {
|
||||||
|
return mysqlId == null ? "" : mysqlId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlId(String mysqlId) {
|
||||||
|
this.mysqlId = mysqlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlName() {
|
||||||
|
return mysqlName == null ? "" : mysqlName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlName(String mysqlName) {
|
||||||
|
this.mysqlName = mysqlName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlHost() {
|
||||||
|
return mysqlHost == null ? "" : mysqlHost.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlHost(String mysqlHost) {
|
||||||
|
this.mysqlHost = mysqlHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPort() {
|
||||||
|
return mysqlPort == null ? "" : mysqlPort.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPort(String mysqlPort) {
|
||||||
|
this.mysqlPort = mysqlPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlUsername() {
|
||||||
|
return mysqlUsername == null ? "" : mysqlUsername.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlUsername(String mysqlUsername) {
|
||||||
|
this.mysqlUsername = mysqlUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPassword() {
|
||||||
|
return mysqlPassword == null ? "" : mysqlPassword.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPassword(String mysqlPassword) {
|
||||||
|
this.mysqlPassword = mysqlPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreator() {
|
||||||
|
return creator == null ? "" : creator.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreator(String creator) {
|
||||||
|
this.creator = creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtCreate(String gmtCreate) {
|
||||||
|
this.gmtCreate = gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifier() {
|
||||||
|
return modifier == null ? "" : modifier.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifier(String modifier) {
|
||||||
|
this.modifier = modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtModified() {
|
||||||
|
return gmtModified == null ? "" : gmtModified.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtModified(String gmtModified) {
|
||||||
|
this.gmtModified = gmtModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsDelete() {
|
||||||
|
return isDelete == null ? 0 : isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDelete(Integer isDelete) {
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package ink.wgink.database.pojo.dtos.mysql;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName: MysqlDTO
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class MysqlDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "mysqlId", value = "主键")
|
||||||
|
private String mysqlId;
|
||||||
|
@ApiModelProperty(name = "mysqlName", value = "连接名")
|
||||||
|
private String mysqlName;
|
||||||
|
@ApiModelProperty(name = "mysqlHost", value = "主机")
|
||||||
|
private String mysqlHost;
|
||||||
|
@ApiModelProperty(name = "mysqlPort", value = "端口")
|
||||||
|
private String mysqlPort;
|
||||||
|
@ApiModelProperty(name = "mysqlUsername", value = "用户名")
|
||||||
|
private String mysqlUsername;
|
||||||
|
@ApiModelProperty(name = "mysqlPassword", value = "密码")
|
||||||
|
private String mysqlPassword;
|
||||||
|
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
|
||||||
|
private String gmtCreate;
|
||||||
|
@ApiModelProperty(name = "gmtModified", value = "修改时间")
|
||||||
|
private String gmtModified;
|
||||||
|
|
||||||
|
public String getMysqlId() {
|
||||||
|
return mysqlId == null ? "" : mysqlId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlId(String mysqlId) {
|
||||||
|
this.mysqlId = mysqlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlName() {
|
||||||
|
return mysqlName == null ? "" : mysqlName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlName(String mysqlName) {
|
||||||
|
this.mysqlName = mysqlName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlHost() {
|
||||||
|
return mysqlHost == null ? "" : mysqlHost.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlHost(String mysqlHost) {
|
||||||
|
this.mysqlHost = mysqlHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPort() {
|
||||||
|
return mysqlPort == null ? "" : mysqlPort.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPort(String mysqlPort) {
|
||||||
|
this.mysqlPort = mysqlPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlUsername() {
|
||||||
|
return mysqlUsername == null ? "" : mysqlUsername.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlUsername(String mysqlUsername) {
|
||||||
|
this.mysqlUsername = mysqlUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPassword() {
|
||||||
|
return mysqlPassword == null ? "" : mysqlPassword.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPassword(String mysqlPassword) {
|
||||||
|
this.mysqlPassword = mysqlPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtCreate(String gmtCreate) {
|
||||||
|
this.gmtCreate = gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtModified() {
|
||||||
|
return gmtModified == null ? "" : gmtModified.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtModified(String gmtModified) {
|
||||||
|
this.gmtModified = gmtModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package ink.wgink.database.pojo.pos.mysql;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @ClassName: MysqlPO
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
public class MysqlPO {
|
||||||
|
|
||||||
|
private String mysqlId;
|
||||||
|
private String mysqlName;
|
||||||
|
private String mysqlHost;
|
||||||
|
private String mysqlPort;
|
||||||
|
private String mysqlUsername;
|
||||||
|
private String mysqlPassword;
|
||||||
|
private String creator;
|
||||||
|
private String gmtCreate;
|
||||||
|
private String modifier;
|
||||||
|
private String gmtModified;
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
public String getMysqlId() {
|
||||||
|
return mysqlId == null ? "" : mysqlId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlId(String mysqlId) {
|
||||||
|
this.mysqlId = mysqlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlName() {
|
||||||
|
return mysqlName == null ? "" : mysqlName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlName(String mysqlName) {
|
||||||
|
this.mysqlName = mysqlName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlHost() {
|
||||||
|
return mysqlHost == null ? "" : mysqlHost.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlHost(String mysqlHost) {
|
||||||
|
this.mysqlHost = mysqlHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPort() {
|
||||||
|
return mysqlPort == null ? "" : mysqlPort.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPort(String mysqlPort) {
|
||||||
|
this.mysqlPort = mysqlPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlUsername() {
|
||||||
|
return mysqlUsername == null ? "" : mysqlUsername.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlUsername(String mysqlUsername) {
|
||||||
|
this.mysqlUsername = mysqlUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPassword() {
|
||||||
|
return mysqlPassword == null ? "" : mysqlPassword.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPassword(String mysqlPassword) {
|
||||||
|
this.mysqlPassword = mysqlPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreator() {
|
||||||
|
return creator == null ? "" : creator.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreator(String creator) {
|
||||||
|
this.creator = creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtCreate() {
|
||||||
|
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtCreate(String gmtCreate) {
|
||||||
|
this.gmtCreate = gmtCreate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifier() {
|
||||||
|
return modifier == null ? "" : modifier.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifier(String modifier) {
|
||||||
|
this.modifier = modifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGmtModified() {
|
||||||
|
return gmtModified == null ? "" : gmtModified.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGmtModified(String gmtModified) {
|
||||||
|
this.gmtModified = gmtModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsDelete() {
|
||||||
|
return isDelete == null ? 0 : isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDelete(Integer isDelete) {
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package ink.wgink.database.pojo.result;
|
||||||
|
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: SuccessResultList
|
||||||
|
* @Description: 成功列表结果
|
||||||
|
* @Author: WangGeng
|
||||||
|
* @Date: 2019/3/3 12:21 AM
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
public class SuccessResultSqlList extends SuccessResult {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7152646978840034322L;
|
||||||
|
|
||||||
|
private List<Map<String, Object>> fields;
|
||||||
|
private List<Map<String, Object>> rows;
|
||||||
|
private Integer page;
|
||||||
|
private Long total;
|
||||||
|
|
||||||
|
public SuccessResultSqlList() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuccessResultSqlList(List<Map<String, Object>> fields, List<Map<String, Object>> rows, Integer page, Long total) {
|
||||||
|
this.fields = fields;
|
||||||
|
this.rows = rows;
|
||||||
|
this.page = page;
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder sb = new StringBuilder("{");
|
||||||
|
sb.append("\"fields\":")
|
||||||
|
.append(fields);
|
||||||
|
sb.append(",\"rows\":")
|
||||||
|
.append(rows);
|
||||||
|
sb.append(",\"page\":")
|
||||||
|
.append(page);
|
||||||
|
sb.append(",\"total\":")
|
||||||
|
.append(total);
|
||||||
|
sb.append('}');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package ink.wgink.database.pojo.vos.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlVO
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class MysqlVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "mysqlName", value = "连接名", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "连接名")
|
||||||
|
private String mysqlName;
|
||||||
|
@ApiModelProperty(name = "mysqlHost", value = "主机", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "主机")
|
||||||
|
private String mysqlHost;
|
||||||
|
@ApiModelProperty(name = "mysqlPort", value = "端口", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "端口")
|
||||||
|
private String mysqlPort;
|
||||||
|
@ApiModelProperty(name = "mysqlUsername", value = "用户名", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "用户名")
|
||||||
|
private String mysqlUsername;
|
||||||
|
@ApiModelProperty(name = "mysqlPassword", value = "密码", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "密码")
|
||||||
|
private String mysqlPassword;
|
||||||
|
|
||||||
|
public String getMysqlName() {
|
||||||
|
return mysqlName == null ? "" : mysqlName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlName(String mysqlName) {
|
||||||
|
this.mysqlName = mysqlName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlHost() {
|
||||||
|
return mysqlHost == null ? "" : mysqlHost.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlHost(String mysqlHost) {
|
||||||
|
this.mysqlHost = mysqlHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPort() {
|
||||||
|
return mysqlPort == null ? "" : mysqlPort.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPort(String mysqlPort) {
|
||||||
|
this.mysqlPort = mysqlPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlUsername() {
|
||||||
|
return mysqlUsername == null ? "" : mysqlUsername.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlUsername(String mysqlUsername) {
|
||||||
|
this.mysqlUsername = mysqlUsername;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMysqlPassword() {
|
||||||
|
return mysqlPassword == null ? "" : mysqlPassword.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMysqlPassword(String mysqlPassword) {
|
||||||
|
this.mysqlPassword = mysqlPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package ink.wgink.database.pojo.vos.sql;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: SqlVO
|
||||||
|
* @Description: SqlVO
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 6:15 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@ApiModel
|
||||||
|
public class SqlVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "sql", value = "sql语句", required = true)
|
||||||
|
@CheckEmptyAnnotation(name = "sql")
|
||||||
|
private String sql;
|
||||||
|
|
||||||
|
public String getSql() {
|
||||||
|
return sql == null ? "" : sql.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSql(String sql) {
|
||||||
|
this.sql = sql;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package ink.wgink.database.service.connection;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IConnection
|
||||||
|
* @Description: 连接
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/26 11:56 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IConnection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Connection connect() throws SQLException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package ink.wgink.database.service.connection.impl;
|
||||||
|
|
||||||
|
import ink.wgink.database.service.connection.IConnection;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MySqlConnectionImpl
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/26 11:57 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class MySqlConnectionImpl implements IConnection {
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
private String port;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public MySqlConnectionImpl(String host, String port, String username, String password) {
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Connection connect() throws SQLException {
|
||||||
|
return DriverManager.getConnection(String.format("jdbc:mysql://%s:%s?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true", host, port), username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package ink.wgink.database.service.jdbc;
|
||||||
|
|
||||||
|
import ink.wgink.database.pojo.vos.sql.SqlVO;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IJdbcService
|
||||||
|
* @Description: jdbc
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 9:59 上午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IJdbcService {
|
||||||
|
|
||||||
|
Boolean isConnected(String mysqlId);
|
||||||
|
|
||||||
|
void openConnection(String mysqlId) throws SQLException;
|
||||||
|
|
||||||
|
void closeConnection(String mysqlId) throws SQLException;
|
||||||
|
|
||||||
|
List<Map<String, Object>> listSchemata(String mysqlId) throws SQLException;
|
||||||
|
|
||||||
|
List<Map<String, Object>> listTable(String mysqlId, String schemata) throws SQLException;
|
||||||
|
|
||||||
|
List<Map<String, Object>> listField(String mysqlId, String schemata, String table) throws SQLException;
|
||||||
|
|
||||||
|
List<Map<String, Object>> listData(String mysqlId, String schemata, String table) throws SQLException;
|
||||||
|
|
||||||
|
List<Map<String, Object>> listData(String mysqlId, String schemata, String table, SqlVO sqlVO) throws SQLException;
|
||||||
|
|
||||||
|
SuccessResultList<List<Map<String, Object>>> listPageData(String mysqlId, String schemata, String table, int index, int size) throws SQLException;
|
||||||
|
|
||||||
|
SuccessResult listPageQuerySql(String mysqlId, int page, int size, SqlVO sqlVO) throws SQLException;
|
||||||
|
|
||||||
|
void updateSql(String mysqlId, SqlVO sqlVO) throws SQLException;
|
||||||
|
}
|
@ -0,0 +1,180 @@
|
|||||||
|
package ink.wgink.database.service.jdbc.impl;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.database.enums.ConnectionTypeEnum;
|
||||||
|
import ink.wgink.database.manager.ActiveConnectionManager;
|
||||||
|
import ink.wgink.database.pojo.pos.mysql.MysqlPO;
|
||||||
|
import ink.wgink.database.pojo.vos.sql.SqlVO;
|
||||||
|
import ink.wgink.database.service.connection.IConnection;
|
||||||
|
import ink.wgink.database.service.connection.impl.MySqlConnectionImpl;
|
||||||
|
import ink.wgink.database.service.jdbc.IJdbcService;
|
||||||
|
import ink.wgink.database.service.mysql.IMysqlService;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.exceptions.base.SystemException;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.jdbc.JdbcUtil;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: JdbcServiceImpl
|
||||||
|
* @Description: jdbc
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/27 9:59 上午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class JdbcServiceImpl extends DefaultBaseService implements IJdbcService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMysqlService mysqlService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isConnected(String mysqlId) {
|
||||||
|
Connection connection = ActiveConnectionManager.getInstance().getConnection(ConnectionTypeEnum.MYSQL, mysqlId);
|
||||||
|
if (connection == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openConnection(String mysqlId) throws SQLException {
|
||||||
|
Connection connection = ActiveConnectionManager.getInstance().getConnection(ConnectionTypeEnum.MYSQL, mysqlId);
|
||||||
|
if (connection != null && !connection.isClosed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MysqlPO mysqlPO = mysqlService.getPO(mysqlId);
|
||||||
|
if (mysqlPO == null) {
|
||||||
|
throw new SearchException("数据库配置不存在");
|
||||||
|
}
|
||||||
|
IConnection conn = new MySqlConnectionImpl(mysqlPO.getMysqlHost(), mysqlPO.getMysqlPort(), mysqlPO.getMysqlUsername(), mysqlPO.getMysqlPassword());
|
||||||
|
ActiveConnectionManager.getInstance().add(ConnectionTypeEnum.MYSQL, mysqlId, conn.connect());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeConnection(String mysqlId) throws SQLException {
|
||||||
|
ActiveConnectionManager.getInstance().closeConnection(ConnectionTypeEnum.MYSQL, mysqlId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> listSchemata(String mysqlId) throws SQLException {
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
String SQL = "SELECT * FROM `information_schema`.`SCHEMATA`";
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(SQL);
|
||||||
|
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> listTable(String mysqlId, String schemata) throws SQLException {
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
String SQL = "SELECT * FROM `information_schema`.`TABLES` WHERE TABLE_SCHEMA = ?";
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, schemata);
|
||||||
|
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> listField(String mysqlId, String schemata, String table) throws SQLException {
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
String SQL = "SELECT * FROM `information_schema`.`COLUMNS` WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(SQL);
|
||||||
|
preparedStatement.setString(1, schemata);
|
||||||
|
preparedStatement.setString(2, table);
|
||||||
|
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> listData(String mysqlId, String schemata, String table) throws SQLException {
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
String SQL = String.format("SELECT * FROM `%s`.`%s`", schemata, table);
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(SQL);
|
||||||
|
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> listData(String mysqlId, String schemata, String table, SqlVO sqlVO) throws SQLException {
|
||||||
|
String sql = Base64.encodeBase64String(sqlVO.getSql().getBytes(StandardCharsets.UTF_8));
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
||||||
|
return JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<Map<String, Object>>> listPageData(String mysqlId, String schemata, String table, int page, int size) throws SQLException {
|
||||||
|
if (page < 1) {
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
if (size <= 0) {
|
||||||
|
size = 20;
|
||||||
|
}
|
||||||
|
String SQL = String.format("SELECT * FROM `%s`.`%s`", schemata, table);
|
||||||
|
return listPageQuery(mysqlId, SQL, page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<Map<String, Object>>> listPageQuerySql(String mysqlId, int page, int size, SqlVO sqlVO) throws SQLException {
|
||||||
|
if (page < 1) {
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
if (size <= 0) {
|
||||||
|
size = 20;
|
||||||
|
}
|
||||||
|
return listPageQuery(mysqlId, sqlVO.getSql(), page, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSql(String mysqlId, SqlVO sqlVO) throws SQLException {
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(sqlVO.getSql());
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行请求
|
||||||
|
*
|
||||||
|
* @param mysqlId
|
||||||
|
* @param sql
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
private SuccessResultList<List<Map<String, Object>>> listPageQuery(String mysqlId, String sql, int page, int size) throws SQLException {
|
||||||
|
// 总数
|
||||||
|
Connection connection = getConnection(mysqlId);
|
||||||
|
String countSQL = String.format("SELECT COUNT(*) total FROM (%s) t", sql);
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(countSQL);
|
||||||
|
Map<String, Object> countResult = JdbcUtil.getResult(preparedStatement.executeQuery());
|
||||||
|
// 列表
|
||||||
|
String querySQL = String.format("%s LIMIT ?,?", sql);
|
||||||
|
preparedStatement = connection.prepareStatement(querySQL);
|
||||||
|
preparedStatement.setInt(1, (page - 1) * size);
|
||||||
|
preparedStatement.setInt(2, size);
|
||||||
|
List<Map<String, Object>> queryResult = JdbcUtil.listResult(preparedStatement.executeQuery());
|
||||||
|
|
||||||
|
return new SuccessResultList<>(queryResult, page, Long.valueOf(countResult.get("total").toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到连接
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Connection getConnection(String mysqlId) throws SQLException {
|
||||||
|
Connection connection = ActiveConnectionManager.getInstance().getConnection(ConnectionTypeEnum.MYSQL, mysqlId);
|
||||||
|
if (connection == null || connection.isClosed()) {
|
||||||
|
throw new SystemException("请重新连接数据库");
|
||||||
|
}
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,188 @@
|
|||||||
|
package ink.wgink.database.service.mysql;
|
||||||
|
|
||||||
|
import ink.wgink.database.pojo.bos.mysql.MysqlBO;
|
||||||
|
import ink.wgink.database.pojo.dtos.mysql.MysqlDTO;
|
||||||
|
import ink.wgink.database.pojo.pos.mysql.MysqlPO;
|
||||||
|
import ink.wgink.database.pojo.vos.mysql.MysqlVO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IMysqlService
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
public interface IMysqlService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mysql连接
|
||||||
|
*
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void save(MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mysql连接
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void save(String token, MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mysql连接
|
||||||
|
*
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return mysqlId
|
||||||
|
*/
|
||||||
|
String saveReturnId(MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增mysql连接
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return mysqlId
|
||||||
|
*/
|
||||||
|
String saveReturnId(String token, MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mysql连接
|
||||||
|
*
|
||||||
|
* @param ids id列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void remove(List<String> ids);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mysql连接
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param ids id列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void remove(String token, List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除mysql连接(物理删除)
|
||||||
|
*
|
||||||
|
* @param ids id列表
|
||||||
|
*/
|
||||||
|
void delete(List<String> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mysql连接
|
||||||
|
*
|
||||||
|
* @param mysqlId
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void update(String mysqlId, MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改mysql连接
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param mysqlId
|
||||||
|
* @param mysqlVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void update(String token, String mysqlId, MysqlVO mysqlVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params 参数Map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlDTO get(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param mysqlId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlDTO get(String mysqlId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params 参数Map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlBO getBO(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param mysqlId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlBO getBO(String mysqlId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param params 参数Map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlPO getPO(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接详情
|
||||||
|
*
|
||||||
|
* @param mysqlId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MysqlPO getPO(String mysqlId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MysqlDTO> list(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MysqlBO> listBO(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接列表
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MysqlPO> listPO(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接分页列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SuccessResultList<List<MysqlDTO>> listPage(ListPage page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mysql连接统计
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer count(Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,171 @@
|
|||||||
|
package ink.wgink.database.service.mysql.impl;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.database.dao.mysql.IMysqlDao;
|
||||||
|
import ink.wgink.database.pojo.bos.mysql.MysqlBO;
|
||||||
|
import ink.wgink.database.pojo.dtos.mysql.MysqlDTO;
|
||||||
|
import ink.wgink.database.pojo.pos.mysql.MysqlPO;
|
||||||
|
import ink.wgink.database.pojo.vos.mysql.MysqlVO;
|
||||||
|
import ink.wgink.database.service.mysql.IMysqlService;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.UUIDUtil;
|
||||||
|
import ink.wgink.util.map.HashMapUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MysqlServiceImpl
|
||||||
|
* @Description: mysql连接
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-26 23:05:32
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class MysqlServiceImpl extends DefaultBaseService implements IMysqlService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMysqlDao mysqlDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(MysqlVO mysqlVO) {
|
||||||
|
saveReturnId(mysqlVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(String token, MysqlVO mysqlVO) {
|
||||||
|
saveReturnId(token, mysqlVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String saveReturnId(MysqlVO mysqlVO) {
|
||||||
|
return saveReturnId(null, mysqlVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String saveReturnId(String token, MysqlVO mysqlVO) {
|
||||||
|
String mysqlId = UUIDUtil.getUUID();
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(mysqlVO);
|
||||||
|
params.put("mysqlId", mysqlId);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
setSaveInfo(params);
|
||||||
|
} else {
|
||||||
|
setAppSaveInfo(token, params);
|
||||||
|
}
|
||||||
|
mysqlDao.save(params);
|
||||||
|
return mysqlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<String> ids) {
|
||||||
|
remove(null, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(String token, List<String> ids) {
|
||||||
|
Map<String, Object> params = getHashMap(2);
|
||||||
|
params.put("mysqlIds", ids);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
} else {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
}
|
||||||
|
mysqlDao.remove(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(List<String> ids) {
|
||||||
|
Map<String, Object> params = getHashMap(2);
|
||||||
|
params.put("mysqlIds", ids);
|
||||||
|
mysqlDao.delete(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(String mysqlId, MysqlVO mysqlVO) {
|
||||||
|
update(null, mysqlId, mysqlVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(String token, String mysqlId, MysqlVO mysqlVO) {
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(mysqlVO);
|
||||||
|
params.put("mysqlId", mysqlId);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
setUpdateInfo(params);
|
||||||
|
} else {
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
}
|
||||||
|
mysqlDao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlDTO get(Map<String, Object> params) {
|
||||||
|
return mysqlDao.get(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlDTO get(String mysqlId) {
|
||||||
|
Map<String, Object> params = super.getHashMap(2);
|
||||||
|
params.put("mysqlId", mysqlId);
|
||||||
|
return get(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlBO getBO(Map<String, Object> params) {
|
||||||
|
return mysqlDao.getBO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlBO getBO(String mysqlId) {
|
||||||
|
Map<String, Object> params = super.getHashMap(2);
|
||||||
|
params.put("mysqlId", mysqlId);
|
||||||
|
return getBO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlPO getPO(Map<String, Object> params) {
|
||||||
|
return mysqlDao.getPO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MysqlPO getPO(String mysqlId) {
|
||||||
|
Map<String, Object> params = super.getHashMap(2);
|
||||||
|
params.put("mysqlId", mysqlId);
|
||||||
|
return getPO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MysqlDTO> list(Map<String, Object> params) {
|
||||||
|
return mysqlDao.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MysqlBO> listBO(Map<String, Object> params) {
|
||||||
|
return mysqlDao.listBO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MysqlPO> listPO(Map<String, Object> params) {
|
||||||
|
return mysqlDao.listPO(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<MysqlDTO>> listPage(ListPage page) {
|
||||||
|
PageHelper.startPage(page.getPage(), page.getRows());
|
||||||
|
List<MysqlDTO> mysqlDTOs = list(page.getParams());
|
||||||
|
PageInfo<MysqlDTO> pageInfo = new PageInfo<>(mysqlDTOs);
|
||||||
|
return new SuccessResultList<>(mysqlDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer count(Map<String, Object> params) {
|
||||||
|
Integer count = mysqlDao.count(params);
|
||||||
|
return count == null ? 0 : count;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,341 @@
|
|||||||
|
<?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="ink.wgink.database.dao.mysql.IMysqlDao">
|
||||||
|
|
||||||
|
<resultMap id="mysqlDTO" type="ink.wgink.database.pojo.dtos.mysql.MysqlDTO">
|
||||||
|
<result column="mysql_id" property="mysqlId"/>
|
||||||
|
<result column="mysql_name" property="mysqlName"/>
|
||||||
|
<result column="mysql_host" property="mysqlHost"/>
|
||||||
|
<result column="mysql_port" property="mysqlPort"/>
|
||||||
|
<result column="mysql_username" property="mysqlUsername"/>
|
||||||
|
<result column="mysql_password" property="mysqlPassword"/>
|
||||||
|
<result column="gmt_create" property="gmtCreate"/>
|
||||||
|
<result column="gmt_modified" property="gmtModified"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="mysqlBO" type="ink.wgink.database.pojo.bos.mysql.MysqlBO">
|
||||||
|
<result column="mysql_id" property="mysqlId"/>
|
||||||
|
<result column="mysql_name" property="mysqlName"/>
|
||||||
|
<result column="mysql_host" property="mysqlHost"/>
|
||||||
|
<result column="mysql_port" property="mysqlPort"/>
|
||||||
|
<result column="mysql_username" property="mysqlUsername"/>
|
||||||
|
<result column="mysql_password" property="mysqlPassword"/>
|
||||||
|
<result column="creator" property="creator"/>
|
||||||
|
<result column="gmt_create" property="gmtCreate"/>
|
||||||
|
<result column="modifier" property="modifier"/>
|
||||||
|
<result column="gmt_modified" property="gmtModified"/>
|
||||||
|
<result column="is_delete" property="isDelete"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="mysqlPO" type="ink.wgink.database.pojo.pos.mysql.MysqlPO">
|
||||||
|
<result column="mysql_id" property="mysqlId"/>
|
||||||
|
<result column="mysql_name" property="mysqlName"/>
|
||||||
|
<result column="mysql_host" property="mysqlHost"/>
|
||||||
|
<result column="mysql_port" property="mysqlPort"/>
|
||||||
|
<result column="mysql_username" property="mysqlUsername"/>
|
||||||
|
<result column="mysql_password" property="mysqlPassword"/>
|
||||||
|
<result column="creator" property="creator"/>
|
||||||
|
<result column="gmt_create" property="gmtCreate"/>
|
||||||
|
<result column="modifier" property="modifier"/>
|
||||||
|
<result column="gmt_modified" property="gmtModified"/>
|
||||||
|
<result column="is_delete" property="isDelete"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<update id="createTable">
|
||||||
|
CREATE TABLE IF NOT EXISTS `conn_mysql` (
|
||||||
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`mysql_id` char(36) DEFAULT NULL COMMENT '主键',
|
||||||
|
`mysql_name` varchar(255) DEFAULT NULL COMMENT '连接名',
|
||||||
|
`mysql_host` varchar(255) DEFAULT NULL COMMENT '主机',
|
||||||
|
`mysql_port` varchar(10) DEFAULT NULL COMMENT '端口',
|
||||||
|
`mysql_username` varchar(255) DEFAULT NULL COMMENT '用户名',
|
||||||
|
`mysql_password` varchar(255) DEFAULT NULL COMMENT '密码',
|
||||||
|
`creator` char(36) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`modifier` char(36) DEFAULT NULL COMMENT '修改人',
|
||||||
|
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
|
||||||
|
`is_delete` int(1) DEFAULT '0' COMMENT '是否删除',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `connection_id` (`mysql_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='mysql连接';
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 新增mysql连接 -->
|
||||||
|
<insert id="save" parameterType="map">
|
||||||
|
INSERT INTO conn_mysql(
|
||||||
|
mysql_id,
|
||||||
|
mysql_name,
|
||||||
|
mysql_host,
|
||||||
|
mysql_port,
|
||||||
|
mysql_username,
|
||||||
|
mysql_password,
|
||||||
|
creator,
|
||||||
|
gmt_create,
|
||||||
|
modifier,
|
||||||
|
gmt_modified,
|
||||||
|
is_delete
|
||||||
|
) VALUES(
|
||||||
|
#{mysqlId},
|
||||||
|
#{mysqlName},
|
||||||
|
#{mysqlHost},
|
||||||
|
#{mysqlPort},
|
||||||
|
#{mysqlUsername},
|
||||||
|
#{mysqlPassword},
|
||||||
|
#{creator},
|
||||||
|
#{gmtCreate},
|
||||||
|
#{modifier},
|
||||||
|
#{gmtModified},
|
||||||
|
#{isDelete}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 删除mysql连接 -->
|
||||||
|
<update id="remove" parameterType="map">
|
||||||
|
UPDATE
|
||||||
|
conn_mysql
|
||||||
|
SET
|
||||||
|
gmt_modified = #{gmtModified},
|
||||||
|
modifier = #{modifier},
|
||||||
|
is_delete = 1
|
||||||
|
WHERE
|
||||||
|
mysql_id IN
|
||||||
|
<foreach collection="mysqlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{mysqlIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 删除mysql连接(物理) -->
|
||||||
|
<update id="delete" parameterType="map">
|
||||||
|
DELETE FROM
|
||||||
|
conn_mysql
|
||||||
|
WHERE
|
||||||
|
mysql_id IN
|
||||||
|
<foreach collection="mysqlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{mysqlIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 修改mysql连接 -->
|
||||||
|
<update id="update" parameterType="map">
|
||||||
|
UPDATE
|
||||||
|
conn_mysql
|
||||||
|
SET
|
||||||
|
<if test="mysqlName != null and mysqlName != ''">
|
||||||
|
mysql_name = #{mysqlName},
|
||||||
|
</if>
|
||||||
|
<if test="mysqlHost != null and mysqlHost != ''">
|
||||||
|
mysql_host = #{mysqlHost},
|
||||||
|
</if>
|
||||||
|
<if test="mysqlPort != null and mysqlPort != ''">
|
||||||
|
mysql_port = #{mysqlPort},
|
||||||
|
</if>
|
||||||
|
<if test="mysqlUsername != null and mysqlUsername != ''">
|
||||||
|
mysql_username = #{mysqlUsername},
|
||||||
|
</if>
|
||||||
|
<if test="mysqlPassword != null and mysqlPassword != ''">
|
||||||
|
mysql_password = #{mysqlPassword},
|
||||||
|
</if>
|
||||||
|
gmt_modified = #{gmtModified},
|
||||||
|
modifier = #{modifier},
|
||||||
|
mysql_id = mysql_id
|
||||||
|
WHERE
|
||||||
|
mysql_id = #{mysqlId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- mysql连接详情 -->
|
||||||
|
<select id="get" parameterType="map" resultMap="mysqlDTO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.mysql_id
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="mysqlId != null and mysqlId != ''">
|
||||||
|
AND
|
||||||
|
t1.mysql_id = #{mysqlId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接详情 -->
|
||||||
|
<select id="getBO" parameterType="map" resultMap="mysqlBO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_id,
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.creator,
|
||||||
|
t1.gmt_create,
|
||||||
|
t1.modifier,
|
||||||
|
t1.gmt_modified,
|
||||||
|
t1.is_delete
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="mysqlId != null and mysqlId != ''">
|
||||||
|
AND
|
||||||
|
t1.mysql_id = #{mysqlId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接详情 -->
|
||||||
|
<select id="getPO" parameterType="map" resultMap="mysqlPO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_id,
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.creator,
|
||||||
|
t1.gmt_create,
|
||||||
|
t1.modifier,
|
||||||
|
t1.gmt_modified,
|
||||||
|
t1.is_delete
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="mysqlId != null and mysqlId != ''">
|
||||||
|
AND
|
||||||
|
t1.mysql_id = #{mysqlId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接列表 -->
|
||||||
|
<select id="list" parameterType="map" resultMap="mysqlDTO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_id,
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.gmt_create,
|
||||||
|
t1.gmt_modified
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="keywords != null and keywords != ''">
|
||||||
|
AND (
|
||||||
|
t1.mysql_name LIKE CONCAT('%', #{keywords}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="mysqlIds != null and mysqlIds.size > 0">
|
||||||
|
AND
|
||||||
|
t1.mysql_id IN
|
||||||
|
<foreach collection="mysqlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{mysqlIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接列表 -->
|
||||||
|
<select id="listBO" parameterType="map" resultMap="mysqlBO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_id,
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.creator,
|
||||||
|
t1.gmt_create,
|
||||||
|
t1.modifier,
|
||||||
|
t1.gmt_modified,
|
||||||
|
t1.is_delete
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="keywords != null and keywords != ''">
|
||||||
|
AND (
|
||||||
|
<!-- 这里添加其他条件 -->
|
||||||
|
t1.id LIKE CONCAT('%', #{keywords}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="mysqlIds != null and mysqlIds.size > 0">
|
||||||
|
AND
|
||||||
|
t1.mysql_id IN
|
||||||
|
<foreach collection="mysqlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{mysqlIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接列表 -->
|
||||||
|
<select id="listPO" parameterType="map" resultMap="mysqlPO">
|
||||||
|
SELECT
|
||||||
|
t1.mysql_id,
|
||||||
|
t1.mysql_name,
|
||||||
|
t1.mysql_host,
|
||||||
|
t1.mysql_port,
|
||||||
|
t1.mysql_username,
|
||||||
|
t1.mysql_password,
|
||||||
|
t1.creator,
|
||||||
|
t1.gmt_create,
|
||||||
|
t1.modifier,
|
||||||
|
t1.gmt_modified,
|
||||||
|
t1.is_delete
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
<if test="keywords != null and keywords != ''">
|
||||||
|
AND (
|
||||||
|
<!-- 这里添加其他条件 -->
|
||||||
|
t1.id LIKE CONCAT('%', #{keywords}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND
|
||||||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||||||
|
</if>
|
||||||
|
<if test="mysqlIds != null and mysqlIds.size > 0">
|
||||||
|
AND
|
||||||
|
t1.mysql_id IN
|
||||||
|
<foreach collection="mysqlIds" index="index" open="(" separator="," close=")">
|
||||||
|
#{mysqlIds[${index}]}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- mysql连接统计 -->
|
||||||
|
<select id="count" parameterType="map" resultType="Integer">
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
conn_mysql t1
|
||||||
|
WHERE
|
||||||
|
t1.is_delete = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,505 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/common.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/codemirror/codemirror.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/codemirror/addon/hint/show-hint.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/css/query-default.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<div id="connectionBtnBox" class="layui-btn-group">
|
||||||
|
<button id="connectionBtn" class="layui-btn layui-btn-xs" style="display: none;">打开连接</button>
|
||||||
|
<button id="closeConnectionBtn" class="layui-btn layui-btn-xs layui-btn-danger" style="display: none;">关闭连接</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body left-tree-wrap">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-xs2">
|
||||||
|
<div id="leftTreeWrap">
|
||||||
|
<ul id="leftTree" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-col-xs10">
|
||||||
|
<div id="queryBox">
|
||||||
|
<div id="queryTopBox">
|
||||||
|
<div id="queryTopOptionBox">
|
||||||
|
<button id="runSqlBtn" class="layui-btn layui-btn-xs">运行</button>
|
||||||
|
只能运行一条SQL语句
|
||||||
|
</div>
|
||||||
|
<textarea id="queryTop"></textarea>
|
||||||
|
</div>
|
||||||
|
<div id="tableBottomBox">
|
||||||
|
<div class="layui-tab">
|
||||||
|
<ul class="layui-tab-title">
|
||||||
|
<li class="layui-this">查询结果</li>
|
||||||
|
</ul>
|
||||||
|
<div class="layui-tab-content">
|
||||||
|
<div class="layui-tab-item layui-show">
|
||||||
|
<table class="layui-hide" id="dataTableBottom" lay-filter="dataTableBottom"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="zTreeSchemataRightMenu">
|
||||||
|
<ul>
|
||||||
|
<li id="openSchemataBtn">打开</li>
|
||||||
|
<li id="closeSchemataBtn" style="display: none;">关闭</li>
|
||||||
|
<li id="refreshSchemataBtn" style="display: none;">刷新</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/codemirror/codemirror.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/mode/sql/sql.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/hint/show-hint.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/hint/sql-hint.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/selection/active-line.js"></script>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
var common;
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laypage', 'util', 'ztree', 'common'], function() {
|
||||||
|
common = layui.common;
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var dataTable = layui.table;
|
||||||
|
var laypage = layui.laypage;
|
||||||
|
var util = layui.util;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var zTree = null;
|
||||||
|
var mysqlId = top.restAjax.params(window.location.href).mysqlId;
|
||||||
|
var rightSelectedTreeNode = null;
|
||||||
|
var queryTopEditor = null;
|
||||||
|
var queryTopEditorSqlTables = {}
|
||||||
|
var queryResultTable = null;
|
||||||
|
|
||||||
|
function initSize() {
|
||||||
|
$('#leftTreeWrap').css({
|
||||||
|
height: $win.height() - 44,
|
||||||
|
overflow: 'auto'
|
||||||
|
});
|
||||||
|
$('#queryTopBox').css({
|
||||||
|
height: $win.height() / 2 - 80,
|
||||||
|
});
|
||||||
|
$('#tableBottomBox').css({
|
||||||
|
height: $win.height() / 2 + 35,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initQueryTop() {
|
||||||
|
if(queryTopEditor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#queryTopBox').css('visibility', 'visible');
|
||||||
|
queryTopEditor = CodeMirror.fromTextArea(document.getElementById('queryTop'), {
|
||||||
|
mode: 'text/x-mysql',
|
||||||
|
indentWithTabs: true,
|
||||||
|
smartIndent: true,
|
||||||
|
lineNumbers: true,
|
||||||
|
matchBrackets : true,
|
||||||
|
autofocus: true,
|
||||||
|
hintOptions: {
|
||||||
|
completeSingle: false,
|
||||||
|
completeOnSingleClick: true,
|
||||||
|
tables: queryTopEditorSqlTables
|
||||||
|
},
|
||||||
|
indentUnit: 4,
|
||||||
|
lineWrapping: true,
|
||||||
|
autofocus: false,
|
||||||
|
});
|
||||||
|
queryTopEditor.setSize('auto', ($win.height() / 2 - 115) + 'px');
|
||||||
|
queryTopEditor.on("inputRead", function(value) {
|
||||||
|
if (!value.state.completionActive) {
|
||||||
|
var cursor = value.getCursor();
|
||||||
|
cursor = value.getTokenAt(cursor);
|
||||||
|
var cursorValue = '';
|
||||||
|
cursor.string.match(/^[.`\w@]\w*$/) && (cursorValue = cursor.string);
|
||||||
|
0 < cursorValue.length && CodeMirror.commands.autocomplete(value)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化表格(下)
|
||||||
|
* @param schemata
|
||||||
|
* @param table
|
||||||
|
*/
|
||||||
|
function initTableBottom(schemata, table, page, limit) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/listpage-data/{mysqlId}/{schemata}/{table}', [mysqlId, schemata, table]), {
|
||||||
|
page: page ? page : 1,
|
||||||
|
limit: limit ? limit : 20
|
||||||
|
}, null, function(code, data) {
|
||||||
|
var cols = [];
|
||||||
|
var datas = [];
|
||||||
|
for(var i = 0, item; item = data.rows[i++];) {
|
||||||
|
if(i === 1) {
|
||||||
|
for(var k in item) {
|
||||||
|
cols.push({
|
||||||
|
field: k, width: 180, title: k, align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
datas.push(item);
|
||||||
|
}
|
||||||
|
if(!data.curr) {
|
||||||
|
queryResultTable = dataTable.render({
|
||||||
|
elem: '#dataTableBottom',
|
||||||
|
id: 'dataTableBottom',
|
||||||
|
width: '100%',
|
||||||
|
height: $win.height() / 2 + 6,
|
||||||
|
cols: [cols],
|
||||||
|
data: datas,
|
||||||
|
page: {
|
||||||
|
count: data.total,
|
||||||
|
curr: 1,
|
||||||
|
layout: ['limit', 'count', 'first', 'prev', 'page', 'last', 'next', 'skip'],
|
||||||
|
groups: 4,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
jump: function(obj, first) {
|
||||||
|
if(data.page == obj.curr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(obj.curr);
|
||||||
|
initTableBottom(schemata, table, obj.curr, obj.limit);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
queryResultTable.render({
|
||||||
|
cols: [cols],
|
||||||
|
data: datas,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function initTableBottom1(schemata, table) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/list-field/{mysqlId}/{schemata}/{table}', [mysqlId, schemata, table]), {}, null, function(code, data) {
|
||||||
|
var cols = [];
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
cols.push({
|
||||||
|
field: item.COLUMN_NAME, width: 180, title: item.COLUMN_NAME, align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
dataTable.render({
|
||||||
|
elem: '#dataTableBottom',
|
||||||
|
id: 'dataTableBottom',
|
||||||
|
url: top.restAjax.path('api/mysql/jdbc/listpage-data/{mysqlId}/{schemata}/{table}', [mysqlId, schemata, table]),
|
||||||
|
width: '100%',
|
||||||
|
height: $win.height() / 2 + 6,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [cols],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
// 对结果转义,正常显示html代码
|
||||||
|
for(var i = 0, item; item = data.rows[i++]; ) {
|
||||||
|
for(k in item) {
|
||||||
|
item[k] = util.escape(item[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏数据库右键菜单
|
||||||
|
*/
|
||||||
|
function hideZTreeSchemataRightMenu() {
|
||||||
|
rightSelectedTreeNode = null;
|
||||||
|
$('#zTreeSchemataRightMenu').css('visibility', 'hidden');
|
||||||
|
$(document.body).unbind('mousedown');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示数据库右键菜单
|
||||||
|
* @param treeNode
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
*/
|
||||||
|
function showZTreeSchemataRightMenu(treeNode, x, y) {
|
||||||
|
rightSelectedTreeNode = treeNode;
|
||||||
|
if(treeNode.children) {
|
||||||
|
$("#openSchemataBtn").hide();
|
||||||
|
$("#closeSchemataBtn").show();
|
||||||
|
$("#refreshSchemataBtn").show();
|
||||||
|
} else {
|
||||||
|
$("#openSchemataBtn").show();
|
||||||
|
$("#closeSchemataBtn").hide();
|
||||||
|
$("#refreshSchemataBtn").hide();
|
||||||
|
}
|
||||||
|
y += document.body.scrollTop;
|
||||||
|
x += document.body.scrollLeft;
|
||||||
|
$('#zTreeSchemataRightMenu').css({'top': y +'px', 'left': x + 'px', 'visibility': 'visible'});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化表
|
||||||
|
* @param schemataTreeNode
|
||||||
|
*/
|
||||||
|
function initTable(schemataTreeNode) {
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/list-table/{mysqlId}/{schemata}', [mysqlId, schemataTreeNode.id]), {}, null, function(code, data) {
|
||||||
|
zTree.removeChildNodes(schemataTreeNode);
|
||||||
|
var tableTreeNodes = [];
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
queryTopEditorSqlTables[schemataTreeNode.id].push(item.TABLE_NAME);
|
||||||
|
queryTopEditorSqlTables[item.TABLE_NAME] = [];
|
||||||
|
tableTreeNodes.push({
|
||||||
|
id: item.TABLE_NAME,
|
||||||
|
name: item.TABLE_NAME,
|
||||||
|
pId: schemataTreeNode.id,
|
||||||
|
nodeType: 'table',
|
||||||
|
icon: 'assets/images/tree/tree-table.png'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
zTree.addNodes(schemataTreeNode, tableTreeNodes);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化树
|
||||||
|
*/
|
||||||
|
function initThree() {
|
||||||
|
var setting = {
|
||||||
|
async: {
|
||||||
|
enable: true,
|
||||||
|
autoLoad: true,
|
||||||
|
type: 'get',
|
||||||
|
url: top.restAjax.path('api/mysql/jdbc/list-schemata/{mysqlId}', [mysqlId]),
|
||||||
|
autoParam: ['id'],
|
||||||
|
otherParam: {},
|
||||||
|
dataFilter: function (treeId, parentNode, childNodes) {
|
||||||
|
if (!childNodes) return null;
|
||||||
|
for(var i = 0, item; item = childNodes[i++];) {
|
||||||
|
queryTopEditorSqlTables[item.SCHEMA_NAME] = [];
|
||||||
|
item.id = item.SCHEMA_NAME;
|
||||||
|
item.name = item.SCHEMA_NAME;
|
||||||
|
item.pId = '0';
|
||||||
|
item.url = 'javascript:void(0);';
|
||||||
|
item.icon = 'assets/images/tree/tree-database.png';
|
||||||
|
item.nodeType = 'schemata';
|
||||||
|
}
|
||||||
|
return childNodes;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: function (event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 数据库单点无效
|
||||||
|
if(treeNode.nodeType == 'schemata') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initTableBottom(treeNode.pId, treeNode.id);
|
||||||
|
initQueryTop();
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onDblClick: function(event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 表双点无效
|
||||||
|
if(treeNode.nodeType == 'table') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initTable(treeNode);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onRightClick: function(event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 表右键无效
|
||||||
|
if(treeNode.nodeType == 'table') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showZTreeSchemataRightMenu(treeNode, event.clientX, event.clientY);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
zTree = $.fn.zTree.init($("#leftTree"), setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭连接
|
||||||
|
function closeConnection() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
$('#closeConnectionBtn').hide();
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/close-connection/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
window.location.reload();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开连接
|
||||||
|
function openConnection(callback) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
$('#connectionBtn').hide();
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/open-connection/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
callback();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否连接
|
||||||
|
function isConnected(callback) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/is-connected/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
if(!data.data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
callback();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initSize();
|
||||||
|
isConnected(function() {
|
||||||
|
initThree();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#connectionBtn').on('click', function() {
|
||||||
|
openConnection(function() {
|
||||||
|
initThree();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#closeConnectionBtn').on('click', function() {
|
||||||
|
closeConnection();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#openSchemataBtn').on('click', function() {
|
||||||
|
initTable(rightSelectedTreeNode);
|
||||||
|
hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$('#closeSchemataBtn').on('click', function() {
|
||||||
|
zTree.removeChildNodes(rightSelectedTreeNode);
|
||||||
|
hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$('#refreshSchemataBtn').on('click', function() {
|
||||||
|
initTable(rightSelectedTreeNode);
|
||||||
|
hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#runSqlBtn').on('click', function() {
|
||||||
|
var sql = queryTopEditor.getValue();
|
||||||
|
if(!sql) {
|
||||||
|
top.dialog.msg('请输入SQL');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/is-connected/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
if(!data.data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
callback();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
initSize();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,529 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/easyui/themes/default/easyui.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/codemirror/codemirror.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/js/vendor/codemirror/addon/hint/show-hint.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/css/query-easyui.css"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app" class="easyui-layout">
|
||||||
|
<div id="appTop" data-options="region:'north',split:false" style="height:35px;">
|
||||||
|
<div id="connectionBtnBox" class="layui-btn-group">
|
||||||
|
<button id="connectionBtn" class="layui-btn layui-btn-xs">打开连接</button>
|
||||||
|
<button id="closeConnectionBtn" class="layui-btn layui-btn-xs layui-btn-danger">关闭连接</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="appLeft" data-options="region:'west',split:true" style="width:200px;">
|
||||||
|
<ul id="leftTree" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
<div id="appCenter" data-options="region:'center'">
|
||||||
|
<div id="mainTab" class="easyui-tabs" data-options="border:false" style="visibility: hidden;">
|
||||||
|
<div title="首页" data-options="border:false">
|
||||||
|
<div id="queryTopBox">
|
||||||
|
<div id="queryTopOptionBox">
|
||||||
|
<button id="executeSqlBtn" class="layui-btn layui-btn-xs">运行</button>
|
||||||
|
</div>
|
||||||
|
<textarea id="queryTopTextarea"></textarea>
|
||||||
|
</div>
|
||||||
|
<div id="queryResultTab" class="easyui-tabs" data-options="border:false"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="zTreeSchemataRightMenu">
|
||||||
|
<ul>
|
||||||
|
<li id="openSchemataBtn">打开</li>
|
||||||
|
<li id="closeSchemataBtn" style="display: none;">关闭</li>
|
||||||
|
<li id="refreshSchemataBtn" style="display: none;">刷新</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/vendor/codemirror/codemirror.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/mode/sql/sql.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/hint/show-hint.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/hint/sql-hint.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/selection/active-line.js"></script>
|
||||||
|
<script src="assets/js/vendor/codemirror/addon/display/placeholder.js"></script>
|
||||||
|
<script src="assets/js/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="assets/js/vendor/zTree3/js/jquery.ztree.all.js"></script>
|
||||||
|
<script src="assets/easyui/jquery.easyui.min.js"></script>
|
||||||
|
<script src="assets/easyui/locale/easyui-lang-zh_CN.js"></script>
|
||||||
|
<script>
|
||||||
|
var mysqlId = top.restAjax.params(window.location.href).mysqlId;
|
||||||
|
function EasyUI(option) {
|
||||||
|
this.el = option.el;
|
||||||
|
this.mounted = option.mounted;
|
||||||
|
if(option.data) {
|
||||||
|
for(var k in option.data) {
|
||||||
|
this[k] = option.data[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(option.methods) {
|
||||||
|
for(var k in option.methods) {
|
||||||
|
this[k] = option.methods[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var easyUI = new EasyUI({
|
||||||
|
el: '#app',
|
||||||
|
data: {
|
||||||
|
win: $(window),
|
||||||
|
zTree: null,
|
||||||
|
|
||||||
|
rightSelectedTreeNode: null,
|
||||||
|
queryTopEditor: null,
|
||||||
|
queryTopEditorSqlTables: {},
|
||||||
|
queryResultTable: null,
|
||||||
|
queryResultTabs: []
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initLayout: function() {
|
||||||
|
var self = this;
|
||||||
|
$('#app').css({width: self.win.width() +'px', height: self.win.height() +'px'});
|
||||||
|
$('#mainTab').css({width: '100%', height: '100%'});
|
||||||
|
},
|
||||||
|
getTabByTitle: function(title) {
|
||||||
|
return $('#mainTab').tabs('getTab', title);
|
||||||
|
},
|
||||||
|
// 更新tab内容
|
||||||
|
updateTabContent: function(tabId, tab, content) {
|
||||||
|
$(tabId).tabs('update', {
|
||||||
|
tab: tab,
|
||||||
|
options: {
|
||||||
|
content: content
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 清空tab
|
||||||
|
clearTabs: function(tabId, tabTitleArray) {
|
||||||
|
for(var i = 0, tabTitle; tabTitle = tabTitleArray[i++];) {
|
||||||
|
$(tabId).tabs('close', tabTitle);
|
||||||
|
}
|
||||||
|
tabTitleArray = [];
|
||||||
|
},
|
||||||
|
// 执行的SQL列表,目前只去最后一条非空内容
|
||||||
|
listExecuteSql: function(sqlContent) {
|
||||||
|
var sqlArray = sqlContent.split(';');
|
||||||
|
var executeSql = [];
|
||||||
|
for(var i = 0, sql; sql = sqlArray[i++];) {
|
||||||
|
if(!sql) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!sql.replace(/\s+/g, '')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
executeSql.push(sql);
|
||||||
|
}
|
||||||
|
return executeSql;
|
||||||
|
},
|
||||||
|
// 初始化查询结果
|
||||||
|
initSqlQueryResult: function(tabIndex, tab, sql, data, page, size) {
|
||||||
|
var self = this;
|
||||||
|
// 查询
|
||||||
|
var cols = [];
|
||||||
|
var datas = [];
|
||||||
|
for(var i = 0, item; item = data.rows[i++];) {
|
||||||
|
if(i === 1) {
|
||||||
|
for(var k in item) {
|
||||||
|
cols.push({
|
||||||
|
field: k,
|
||||||
|
title: k
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
datas.push(item);
|
||||||
|
}
|
||||||
|
var dataGridId = 't_result_'+ tabIndex;
|
||||||
|
self.updateTabContent('#queryResultTab', tab, '<table id="'+ dataGridId +'"></table>');
|
||||||
|
$('#'+ dataGridId).datagrid({
|
||||||
|
columns:[cols],
|
||||||
|
data: datas,
|
||||||
|
width: (self.win.width() - 205) +'px',
|
||||||
|
height: (self.win.height() / 2 - 24)+'px',
|
||||||
|
selectOnCheck: true,
|
||||||
|
rownumbers: true,
|
||||||
|
pagination: true,
|
||||||
|
});
|
||||||
|
var pager = $('#'+ dataGridId).datagrid('getPager');
|
||||||
|
pager.pagination({
|
||||||
|
total: data.total,
|
||||||
|
pageSize: size,
|
||||||
|
pageNumber: page,
|
||||||
|
pageList: [20, 40, 60, 80, 100, 200],
|
||||||
|
onSelectPage: function(pageNumber, pageSize) {
|
||||||
|
self.initExecuteResult(tabIndex, sql, pageNumber, pageSize)
|
||||||
|
},
|
||||||
|
onChangePageSize: function(pageSize) {
|
||||||
|
self.initExecuteResult(tabIndex, sql, page, pageSize)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 初始化执行结果
|
||||||
|
initExecuteResult: function(tabIndex, sql, page, size) {
|
||||||
|
var self = this;
|
||||||
|
var tab = $('#queryResultTab').tabs('getTab', '结果'+ tabIndex);
|
||||||
|
page = page ? page : 1;
|
||||||
|
size = size ? size : 20;
|
||||||
|
top.restAjax.post(top.restAjax.path('api/mysql/jdbc/execute-sql/{mysqlId}?page={page}&size={size}', [mysqlId, page, size]), {
|
||||||
|
sql: sql
|
||||||
|
}, {
|
||||||
|
tabIndex: tabIndex
|
||||||
|
}, function(code, data, args) {
|
||||||
|
if(data.rows) {
|
||||||
|
self.initSqlQueryResult(args.tabIndex, tab, sql, data, page, size);
|
||||||
|
} else {
|
||||||
|
// 更新
|
||||||
|
self.updateTabContent('#queryResultTab', tab, '执行成功');
|
||||||
|
}
|
||||||
|
}, function(code, data) {
|
||||||
|
self.updateTabContent('#queryResultTab', tab, data.msg);
|
||||||
|
}, function() {
|
||||||
|
self.updateTabContent('#queryResultTab', tab, '正在请求...');
|
||||||
|
}, function() {
|
||||||
|
// self.updateTabContent('#queryResultTab', tab, '请求成功');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 执行SQL
|
||||||
|
executeSql: function() {
|
||||||
|
var self = this;
|
||||||
|
var sqlContnt = self.queryTopEditor.getValue();
|
||||||
|
var executeSqlArray = self.listExecuteSql(sqlContnt);
|
||||||
|
self.clearTabs('#queryResultTab', self.queryResultTabs);
|
||||||
|
for(var i = 0, sql; sql = executeSqlArray[i++];) {
|
||||||
|
$('#queryResultTab').tabs('add', {
|
||||||
|
title: '结果'+ i,
|
||||||
|
closable: true,
|
||||||
|
});
|
||||||
|
self.queryResultTabs.push('结果'+ i);
|
||||||
|
self.initExecuteResult(i, sql);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initQueryTopTextArea: function() {
|
||||||
|
var self = this;
|
||||||
|
self.queryTopEditor = CodeMirror.fromTextArea(document.getElementById('queryTopTextarea'), {
|
||||||
|
mode: 'text/x-mysql',
|
||||||
|
placeholder: '请输入要执行的SQL,只运行最后一条非空语句。请使用 database.table 的方式来操作具体的表',
|
||||||
|
indentWithTabs: true,
|
||||||
|
smartIndent: true,
|
||||||
|
lineNumbers: false,
|
||||||
|
matchBrackets : true,
|
||||||
|
autofocus: true,
|
||||||
|
hintOptions: {
|
||||||
|
completeSingle: false,
|
||||||
|
completeOnSingleClick: true,
|
||||||
|
tables: self.queryTopEditorSqlTables
|
||||||
|
},
|
||||||
|
indentUnit: 4,
|
||||||
|
lineWrapping: true,
|
||||||
|
autofocus: false,
|
||||||
|
});
|
||||||
|
self.queryTopEditor.setSize('auto', (self.win.height() / 2 - 115) + 'px');
|
||||||
|
self.queryTopEditor.on("inputRead", function(value) {
|
||||||
|
if (!value.state.completionActive) {
|
||||||
|
var cursor = value.getCursor();
|
||||||
|
cursor = value.getTokenAt(cursor);
|
||||||
|
var cursorValue = '';
|
||||||
|
cursor.string.match(/^[.`\w@]\w*$/) && (cursorValue = cursor.string);
|
||||||
|
0 < cursorValue.length && CodeMirror.commands.autocomplete(value)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
initHomePage: function() {
|
||||||
|
var self = this;
|
||||||
|
$('#mainTab').css({'visibility': 'visible'});
|
||||||
|
self.initQueryTopTextArea();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* newTableData
|
||||||
|
* @param schemata
|
||||||
|
* @param table
|
||||||
|
* @param page
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
|
initTableData: function(schemata, table, page, size) {
|
||||||
|
page = page ? page : 1;
|
||||||
|
size = size ? size : 20;
|
||||||
|
var self = this;
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/listpage-data/{mysqlId}/{schemata}/{table}', [mysqlId, schemata, table]), {
|
||||||
|
page: page,
|
||||||
|
size: size
|
||||||
|
}, null, function(code, data) {
|
||||||
|
var cols = [];
|
||||||
|
var datas = [];
|
||||||
|
for(var i = 0, item; item = data.rows[i++];) {
|
||||||
|
if(i === 1) {
|
||||||
|
for(var k in item) {
|
||||||
|
cols.push({
|
||||||
|
field: k,
|
||||||
|
title: k
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
datas.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataGridId = '#t_'+ schemata +'_'+ table;
|
||||||
|
$(dataGridId).datagrid({
|
||||||
|
columns:[cols],
|
||||||
|
data: datas,
|
||||||
|
height: (self.win.height() - 72)+'px',
|
||||||
|
selectOnCheck: true,
|
||||||
|
rownumbers: true,
|
||||||
|
pagination: true,
|
||||||
|
});
|
||||||
|
var pager = $(dataGridId).datagrid('getPager');
|
||||||
|
pager.pagination({
|
||||||
|
total: data.total,
|
||||||
|
pageSize: size,
|
||||||
|
pageNumber: page,
|
||||||
|
pageList: [20, 40, 60, 80, 100, 200],
|
||||||
|
onSelectPage: function(pageNumber, pageSize) {
|
||||||
|
self.initTableData(schemata, table, pageNumber, pageSize)
|
||||||
|
},
|
||||||
|
onChangePageSize: function(pageSize) {
|
||||||
|
self.initTableData(schemata, table, page, pageSize)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化表
|
||||||
|
* @param schemataTreeNode
|
||||||
|
*/
|
||||||
|
initTable: function(schemataTreeNode) {
|
||||||
|
var self = this;
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/list-table/{mysqlId}/{schemata}', [mysqlId, schemataTreeNode.id]), {}, null, function(code, data) {
|
||||||
|
self.zTree.removeChildNodes(schemataTreeNode);
|
||||||
|
var tableTreeNodes = [];
|
||||||
|
for(var i = 0, item; item = data[i++];) {
|
||||||
|
self.queryTopEditorSqlTables[schemataTreeNode.id].push(item.TABLE_NAME);
|
||||||
|
self.queryTopEditorSqlTables[item.TABLE_NAME] = [];
|
||||||
|
tableTreeNodes.push({
|
||||||
|
id: item.TABLE_NAME,
|
||||||
|
name: item.TABLE_NAME,
|
||||||
|
pId: schemataTreeNode.id,
|
||||||
|
nodeType: 'table',
|
||||||
|
icon: 'assets/images/tree/tree-table.png'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.zTree.addNodes(schemataTreeNode, tableTreeNodes);
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 显示数据库右键菜单
|
||||||
|
* @param treeNode
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
*/
|
||||||
|
showZTreeSchemataRightMenu: function(treeNode, x, y) {
|
||||||
|
var self = this;
|
||||||
|
self.rightSelectedTreeNode = treeNode;
|
||||||
|
if(treeNode.children) {
|
||||||
|
$("#openSchemataBtn").hide();
|
||||||
|
$("#closeSchemataBtn").show();
|
||||||
|
$("#refreshSchemataBtn").show();
|
||||||
|
} else {
|
||||||
|
$("#openSchemataBtn").show();
|
||||||
|
$("#closeSchemataBtn").hide();
|
||||||
|
$("#refreshSchemataBtn").hide();
|
||||||
|
}
|
||||||
|
y += document.body.scrollTop;
|
||||||
|
x += document.body.scrollLeft;
|
||||||
|
$('#zTreeSchemataRightMenu').css({'top': y +'px', 'left': x + 'px', 'visibility': 'visible'});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 隐藏数据库右键菜单
|
||||||
|
*/
|
||||||
|
hideZTreeSchemataRightMenu: function() {
|
||||||
|
this.rightSelectedTreeNode = null;
|
||||||
|
$('#zTreeSchemataRightMenu').css('visibility', 'hidden');
|
||||||
|
$(document.body).unbind('mousedown');
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化树
|
||||||
|
*/
|
||||||
|
initThree: function() {
|
||||||
|
var self = this;
|
||||||
|
var setting = {
|
||||||
|
async: {
|
||||||
|
enable: true,
|
||||||
|
autoLoad: true,
|
||||||
|
type: 'get',
|
||||||
|
url: top.restAjax.path('api/mysql/jdbc/list-schemata/{mysqlId}', [mysqlId]),
|
||||||
|
autoParam: ['id'],
|
||||||
|
otherParam: {},
|
||||||
|
dataFilter: function (treeId, parentNode, childNodes) {
|
||||||
|
if (!childNodes) return null;
|
||||||
|
for(var i = 0, item; item = childNodes[i++];) {
|
||||||
|
self.queryTopEditorSqlTables[item.SCHEMA_NAME] = [];
|
||||||
|
item.id = item.SCHEMA_NAME;
|
||||||
|
item.name = item.SCHEMA_NAME;
|
||||||
|
item.pId = '0';
|
||||||
|
item.url = 'javascript:void(0);';
|
||||||
|
item.icon = 'assets/images/tree/tree-database.png';
|
||||||
|
item.nodeType = 'schemata';
|
||||||
|
}
|
||||||
|
return childNodes;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: function (event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 数据库单点无效
|
||||||
|
if(treeNode.nodeType == 'schemata') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var tab = self.getTabByTitle(treeNode.id);
|
||||||
|
// 添加tab
|
||||||
|
if(!tab) {
|
||||||
|
$('#mainTab').tabs('add', {
|
||||||
|
title: treeNode.id,
|
||||||
|
content:'<table id="t_'+ treeNode.pId +'_'+ treeNode.id +'"></table>',
|
||||||
|
closable: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#mainTab').tabs('select', treeNode.id);
|
||||||
|
}
|
||||||
|
self.initTableData(treeNode.pId, treeNode.id);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onDblClick: function(event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 表双点无效
|
||||||
|
if(treeNode.nodeType == 'table') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.initTable(treeNode);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onRightClick: function(event, treeId, treeNode) {
|
||||||
|
if(!treeNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 表右键无效
|
||||||
|
if(treeNode.nodeType == 'table') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.showZTreeSchemataRightMenu(treeNode, event.clientX, event.clientY);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
self.zTree = $.fn.zTree.init($("#leftTree"), setting);
|
||||||
|
},
|
||||||
|
// 关闭连接
|
||||||
|
closeConnection: function() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
$('#closeConnectionBtn').hide();
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/close-connection/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
window.location.reload();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 打开连接
|
||||||
|
openConnection: function(callback) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
$('#connectionBtn').hide();
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/open-connection/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
callback();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 是否连接
|
||||||
|
isConnected: function(callback) {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/jdbc/is-connected/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
if(!data.data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#closeConnectionBtn').show();
|
||||||
|
callback();
|
||||||
|
}, function(code, data) {
|
||||||
|
$('#connectionBtn').show();
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted: function() {
|
||||||
|
var self = this;
|
||||||
|
self.initLayout();
|
||||||
|
self.isConnected(function() {
|
||||||
|
self.initThree();
|
||||||
|
self.initHomePage();
|
||||||
|
});
|
||||||
|
$('#connectionBtn').on('click', function() {
|
||||||
|
self.openConnection(function() {
|
||||||
|
self.initThree();
|
||||||
|
self.initHomePage();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#closeConnectionBtn').on('click', function() {
|
||||||
|
self.closeConnection();
|
||||||
|
});
|
||||||
|
$('#openSchemataBtn').on('click', function() {
|
||||||
|
self.initTable(self.rightSelectedTreeNode);
|
||||||
|
self.hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$('#closeSchemataBtn').on('click', function() {
|
||||||
|
self.zTree.removeChildNodes(self.rightSelectedTreeNode);
|
||||||
|
self.hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$('#refreshSchemataBtn').on('click', function() {
|
||||||
|
self.initTable(self.rightSelectedTreeNode);
|
||||||
|
self.hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$(self.el).on('click', function() {
|
||||||
|
self.hideZTreeSchemataRightMenu();
|
||||||
|
})
|
||||||
|
$('#executeSqlBtn').on('click', function() {
|
||||||
|
self.executeSql();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
easyUI.mounted();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
301
module-database/src/main/resources/templates/mysql/list.html
Normal file
301
module-database/src/main/resources/templates/mysql/list.html
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
|
||||||
|
</div>
|
||||||
|
新增时间
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="startTime" class="layui-input search-item search-item-width-100" placeholder="开始时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="endTime" class="layui-input search-item search-item-width-100" placeholder="结束时间" readonly>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||||
|
<!-- 表头按钮组 -->
|
||||||
|
<script type="text/html" id="headerToolBar">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||||
|
<i class="fa fa-lg fa-plus"></i> 新增
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||||
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||||
|
<i class="fa fa-lg fa-trash"></i> 删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var table = layui.table;
|
||||||
|
var admin = layui.admin;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var common = layui.common;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var tableUrl = 'api/mysql/listpage';
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
function initTable() {
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{type:'checkbox', fixed: 'left'},
|
||||||
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
|
{field: 'mysqlName', width: 180, title: '连接名', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'mysqlHost', width: 180, title: '主机', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'mysqlPort', width: 180, title: '端口', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'mysqlUsername', width: 180, title: '用户名', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'mysqlPassword', width: 180, title: '密码', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'gmtCreate', width: 180, title: '创建时间', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'gmtModified', width: 180, title: '修改时间', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'option', width: 80, title: '操作', align:'center', fixed: 'right',
|
||||||
|
templet: function(row) {
|
||||||
|
return '<div class="layui-btn-group">' +
|
||||||
|
'<button class="layui-btn layui-btn-xs" lay-event="databaseEvent">数据库</button>' +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 重载表格
|
||||||
|
function reloadTable(currentPage) {
|
||||||
|
table.reload('dataTable', {
|
||||||
|
where: {
|
||||||
|
keywords: $('#keywords').val(),
|
||||||
|
startTime: $('#startTime').val(),
|
||||||
|
endTime: $('#endTime').val()
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: currentPage
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 初始化日期
|
||||||
|
function initDate() {
|
||||||
|
// 日期选择
|
||||||
|
laydate.render({
|
||||||
|
elem: '#startTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#endTime',
|
||||||
|
format: 'yyyy-MM-dd'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
function removeData(ids) {
|
||||||
|
top.dialog.msg(top.dataMessage.delete, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var layIndex;
|
||||||
|
top.restAjax.delete(top.restAjax.path('api/mysql/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||||
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(layIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initTable();
|
||||||
|
initDate();
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
reloadTable();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
// 事件 - 搜索
|
||||||
|
$(document).on('click', '#search', function() {
|
||||||
|
reloadTable(1);
|
||||||
|
});
|
||||||
|
// 事件 - 增删改
|
||||||
|
table.on('toolbar(dataTable)', function(obj) {
|
||||||
|
var layEvent = obj.event;
|
||||||
|
var checkStatus = table.checkStatus('dataTable');
|
||||||
|
var checkDatas = checkStatus.data;
|
||||||
|
if(layEvent === 'saveEvent') {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/mysql/save', []),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(layEvent === 'updateEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||||
|
} else if(checkDatas.length > 1) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/mysql/update?mysqlId={mysqlId}', [checkDatas[0].mysqlId]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if(layEvent === 'removeEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||||
|
} else {
|
||||||
|
var ids = '';
|
||||||
|
for(var i = 0, item; item = checkDatas[i++];) {
|
||||||
|
if(i > 1) {
|
||||||
|
ids += '_';
|
||||||
|
}
|
||||||
|
ids += item['mysqlId'];
|
||||||
|
}
|
||||||
|
removeData(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
table.on('tool(dataTable)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
var event = obj.event;
|
||||||
|
if(event === 'databaseEvent') {
|
||||||
|
top.dialog.open({
|
||||||
|
url: top.restAjax.path('route/mysql/jdbc/query?mysqlId={mysqlId}', [data.mysqlId]),
|
||||||
|
title: '数据库',
|
||||||
|
width: '90%',
|
||||||
|
height: '90%',
|
||||||
|
onClose: function() {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
130
module-database/src/main/resources/templates/mysql/save.html
Normal file
130
module-database/src/main/resources/templates/mysql/save.html
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">连接名 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlName" name="mysqlName" class="layui-input" value="" placeholder="请输入连接名" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">主机 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlHost" name="mysqlHost" class="layui-input" value="" placeholder="请输入主机,如:192.168.0.1" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux">注意:必须是服务器能够访问到的地址</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">端口 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" id="mysqlPort" name="mysqlPort" class="layui-input" value="3306" placeholder="请输入端口,如:3306" maxlength="10" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">用户名 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlUsername" name="mysqlUsername" class="layui-input" value="" placeholder="请输入用户名,如:root" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">密码 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="password" id="mysqlPassword" name="mysqlPassword" class="layui-input" value="" placeholder="请输入密码" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.post(top.restAjax.path('api/mysql/save', []), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
147
module-database/src/main/resources/templates/mysql/update.html
Normal file
147
module-database/src/main/resources/templates/mysql/update.html
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||||
|
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||||
|
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body" style="padding: 15px;">
|
||||||
|
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">连接名 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlName" name="mysqlName" class="layui-input" value="" placeholder="请输入连接名" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">主机 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlHost" name="mysqlHost" class="layui-input" value="" placeholder="请输入主机,如:192.168.0.1" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-mid layui-word-aux">注意:必须是服务器能够访问到的地址</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">端口 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlPort" name="mysqlPort" class="layui-input" value="" placeholder="请输入端口,如:3306" maxlength="10" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">用户名 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlUsername" name="mysqlUsername" class="layui-input" value="" placeholder="请输入用户名,如:root" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">密码 *</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" id="mysqlPassword" name="mysqlPassword" class="layui-input" value="" placeholder="请输入密码" maxlength="255" lay-verify="required">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item layui-layout-admin">
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<div class="layui-footer" style="left: 0;">
|
||||||
|
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index' //主入口模块
|
||||||
|
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||||
|
var $ = layui.$;
|
||||||
|
var form = layui.form;
|
||||||
|
var laytpl = layui.laytpl;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var mysqlId = top.restAjax.params(window.location.href).mysqlId;
|
||||||
|
|
||||||
|
|
||||||
|
function closeBox() {
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化内容
|
||||||
|
function initData() {
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.get(top.restAjax.path('api/mysql/get/{mysqlId}', [mysqlId]), {}, null, function(code, data) {
|
||||||
|
var dataFormData = {};
|
||||||
|
for(var i in data) {
|
||||||
|
dataFormData[i] = data[i] +'';
|
||||||
|
}
|
||||||
|
form.val('dataForm', dataFormData);
|
||||||
|
form.render(null, 'dataForm');
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initData();
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
form.on('submit(submitForm)', function(formData) {
|
||||||
|
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var loadLayerIndex;
|
||||||
|
top.restAjax.put(top.restAjax.path('api/mysql/update/{mysqlId}', [mysqlId]), formData.field, null, function(code, data) {
|
||||||
|
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function(index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
btn2: function() {
|
||||||
|
closeBox();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function() {
|
||||||
|
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function() {
|
||||||
|
top.dialog.close(loadLayerIndex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.close').on('click', function() {
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
form.verify({
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
pom.xml
18
pom.xml
@ -43,7 +43,7 @@
|
|||||||
<module>mongo-module-dictionary</module>
|
<module>mongo-module-dictionary</module>
|
||||||
<module>redis-cache</module>
|
<module>redis-cache</module>
|
||||||
<module>mongo-module-file</module>
|
<module>mongo-module-file</module>
|
||||||
<module>module-database-api</module>
|
<module>module-database</module>
|
||||||
<module>module-form</module>
|
<module>module-form</module>
|
||||||
<module>basic-abstract</module>
|
<module>basic-abstract</module>
|
||||||
</modules>
|
</modules>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
<spring-security.version>5.2.9.RELEASE</spring-security.version>
|
<spring-security.version>5.2.9.RELEASE</spring-security.version>
|
||||||
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
|
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
|
||||||
<fastjson.version>1.2.25</fastjson.version>
|
<fastjson.version>1.2.25</fastjson.version>
|
||||||
|
<fastjson2.version>2.0.2</fastjson2.version>
|
||||||
<json.version>20210307</json.version>
|
<json.version>20210307</json.version>
|
||||||
<easyexcel.version>2.2.11</easyexcel.version>
|
<easyexcel.version>2.2.11</easyexcel.version>
|
||||||
<cglib.version>3.2.12</cglib.version>
|
<cglib.version>3.2.12</cglib.version>
|
||||||
@ -188,6 +189,11 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>${fastjson2.version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- fastjson end -->
|
<!-- fastjson end -->
|
||||||
|
|
||||||
<!-- json start -->
|
<!-- json start -->
|
||||||
@ -437,16 +443,6 @@
|
|||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>${tomcat-embed.version}</version>
|
<version>${tomcat-embed.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-el</artifactId>
|
|
||||||
<version>${tomcat-embed.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-websocket</artifactId>
|
|
||||||
<version>${tomcat-embed.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- tomcat end -->
|
<!-- tomcat end -->
|
||||||
|
|
||||||
<!-- lombok start -->
|
<!-- lombok start -->
|
||||||
|
Loading…
Reference in New Issue
Block a user