feat(DataAccessServiceImpl)重写同步
parent
50b273c1fc
commit
c647dbf7fe
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.common.redis.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
|
@ -143,7 +144,7 @@ public class RedisService {
|
|||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList (final String key) {
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
return (List<T>) redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,10 +191,9 @@ public class RedisService {
|
|||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap (final String key) {
|
||||
public <T> Map<Object, Object> getCacheMap (final String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.table.TableParams;
|
||||
import com.muyu.system.domain.vo.DeptVO;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.domain.vo.SysUserVo;
|
||||
|
@ -11,10 +12,14 @@ import com.muyu.system.domain.vo.TableVo;
|
|||
import com.muyu.system.service.AccreditService;
|
||||
import com.muyu.system.service.SysDeptService;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.bouncycastle.pqc.crypto.newhope.NHSecretKeyProcessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.imageio.ImageTranscoder;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
@ -130,12 +135,12 @@ public class AccreditController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据名称获取表结构
|
||||
* @param tableName
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selNameListStructure/{tableName}")
|
||||
public Result<List<ListStructure>> selNameListStructure(@PathVariable String tableName){
|
||||
List<ListStructure> list = service.selNameListStructure(tableName);
|
||||
@PostMapping("/selNameListStructure")
|
||||
public Result<List<ListStructure>> selNameListStructure(@RequestParam String databaseName,@RequestParam String tableName){
|
||||
List<ListStructure> list = service.selNameListStructure(databaseName,tableName);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
@ -166,13 +171,82 @@ public class AccreditController extends BaseController {
|
|||
|
||||
/**
|
||||
* 获取部门
|
||||
* @param name
|
||||
* @param tableName
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listMiddle")
|
||||
public Result<List<Middle>> listMiddle(@RequestParam String name){
|
||||
List<Middle> middleList = service.listMiddle(name);
|
||||
public Result<List<Middle>> listMiddle(@RequestParam String tableName , @RequestParam String databaseName){
|
||||
List<Middle> middleList = service.listMiddle(tableName,databaseName);
|
||||
return success(middleList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门2
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listMiddle2")
|
||||
public Result<List<Middle>> listMiddle2(@RequestParam String databaseName){
|
||||
List<Middle> list = service.listMiddle2(databaseName);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
* @param tableName
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listUserMiddle")
|
||||
public Result<List<UserMiddle>> listUserMiddle(@RequestParam String tableName ,@RequestParam String databaseName){
|
||||
List<UserMiddle> list = service.listUserMiddle(tableName, databaseName);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户2
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listUserMiddle2")
|
||||
public Result<List<UserMiddle>> listUserMiddle2(@RequestParam String databaseName){
|
||||
List<UserMiddle> list = service.listUserMiddle2(databaseName);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门授权
|
||||
* @param mid
|
||||
* @param statusId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("updateMiddle")
|
||||
public Result updateMiddle(@RequestParam Integer mid,@RequestParam Integer statusId){
|
||||
Integer id = service.updateMiddle(mid,statusId);
|
||||
if (id>0){
|
||||
return success("修改完成");
|
||||
}else{
|
||||
return error("异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权
|
||||
* @param mid
|
||||
* @param statusId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("updateUserMiddle")
|
||||
public Result updateUserMiddle(@RequestParam Integer mid,@RequestParam Integer statusId){
|
||||
Integer id = service.updateUserMiddle(mid,statusId);
|
||||
if (id>0){
|
||||
return success("修改完成");
|
||||
}else{
|
||||
return error("异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.system.controller;
|
|||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import jdk.jfr.StackTrace;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
|
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
@ -75,6 +76,8 @@ public class Middle {
|
|||
*/
|
||||
private String email;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 父部门名称
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,15 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class TableList {
|
||||
private Integer id;
|
||||
/**
|
||||
* 接入名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 系统名称
|
||||
*/
|
||||
private String systemName;
|
||||
/**
|
||||
* 数据库名
|
||||
*/
|
||||
|
@ -11,9 +20,9 @@ public class TableList {
|
|||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
private String tableName;
|
||||
/**
|
||||
*表
|
||||
*备注
|
||||
*/
|
||||
private String as;
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,30 @@ public class UserMiddle {
|
|||
* 用户名主键
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
/**
|
||||
* 用户部门
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String phonenumber;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.system.domain.table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TableParams {
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String tableName;
|
||||
/**
|
||||
* 数据库名
|
||||
*/
|
||||
private String databaseName;
|
||||
}
|
|
@ -12,11 +12,11 @@ public class FrimaryVo {
|
|||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
* 接入名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 名称
|
||||
* 系统名称
|
||||
*/
|
||||
private String systemName;
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.table.TableParams;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -30,7 +31,7 @@ public interface AccreditMapper {
|
|||
|
||||
TableList selNameTableList(@Param("databaseName") String databaseName, @Param("name") String name);
|
||||
|
||||
List<ListStructure> selNameListStructure(@Param("tableName") String tableName);
|
||||
List<ListStructure> selNameListStructure(@Param("databaseName") String databaseName, @Param("tableName") String tableName);
|
||||
|
||||
int selectOneTableList(@Param("databaseName") String databaseName, @Param("s") String s);
|
||||
|
||||
|
@ -46,5 +47,16 @@ public interface AccreditMapper {
|
|||
|
||||
void delOneTableList(@Param("databaseName") String databaseName, @Param("s") String s);
|
||||
|
||||
List<Middle> listMiddle(@Param("name") String name);
|
||||
List<Middle> listMiddle(@Param("tableName") String tableName , @Param("databaseName") String databaseName);
|
||||
|
||||
List<UserMiddle> listUserMiddle(@Param("tableName") String tableName , @Param("databaseName") String databaseName);
|
||||
|
||||
List<UserMiddle> listUserMiddle2(@Param("databaseName") String databaseName);
|
||||
|
||||
Integer updateMiddle(@Param("mid") Integer mid, @Param("statusId") Integer statusId);
|
||||
|
||||
Integer updateUserMiddle(@Param("mapper") AccreditMapper mapper, @Param("statusId") Integer statusId);
|
||||
|
||||
|
||||
List<Middle> listMiddle2(@Param("databaseName") String databaseName);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.muyu.system.service;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.table.TableParams;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
@ -22,7 +24,7 @@ public interface AccreditService {
|
|||
|
||||
TableList selNameTableList(String databaseName,String name);
|
||||
|
||||
List<ListStructure> selNameListStructure(String tableName);
|
||||
List<ListStructure> selNameListStructure(String databaseName,String tableName);
|
||||
|
||||
Integer updateListStructure(ListStructure listStructure);
|
||||
|
||||
|
@ -31,5 +33,16 @@ public interface AccreditService {
|
|||
|
||||
List<FrimaryVo> selectFrimary();
|
||||
|
||||
List<Middle> listMiddle(String name);
|
||||
List<Middle> listMiddle(String tableName ,String databaseName);
|
||||
|
||||
List<Middle> listMiddle2(String databaseName);
|
||||
|
||||
List<UserMiddle> listUserMiddle(String tableName ,String databaseName);
|
||||
|
||||
List<UserMiddle> listUserMiddle2(String databaseName);
|
||||
|
||||
Integer updateMiddle(Integer mid, Integer statusId);
|
||||
|
||||
Integer updateUserMiddle(Integer mid, Integer statusId);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,13 +3,16 @@ package com.muyu.system.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.table.TableParams;
|
||||
import com.muyu.system.domain.vo.FrimaryVo;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
import com.muyu.system.mapper.AccreditMapper;
|
||||
import com.muyu.system.service.AccreditService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.sql.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -37,22 +40,11 @@ public class AccreditServiceImpl implements AccreditService {
|
|||
@Override
|
||||
public List<String> tableNameList2() throws SQLException {
|
||||
List<String> list = mapper.tableNameList2();
|
||||
// for (String s : list) {
|
||||
// int i = mapper.selectOneTableList(s);
|
||||
// if (i>0){
|
||||
// }else{
|
||||
// mapper.inserttableList(s);
|
||||
// }
|
||||
// int i1 = mapper.selectOneSqlJdbc(s);
|
||||
// if (i1>0){
|
||||
// }else{
|
||||
// listSqlJdbc(s);
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result listSqlJdbc(Connection connection,String tableName) throws SQLException {
|
||||
try {
|
||||
PreparedStatement pst = connection.prepareCall("select * from " + tableName);
|
||||
|
@ -123,8 +115,8 @@ public class AccreditServiceImpl implements AccreditService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ListStructure> selNameListStructure(String tableName) {
|
||||
return mapper.selNameListStructure(tableName);
|
||||
public List<ListStructure> selNameListStructure(String databaseName,String tableName) {
|
||||
return mapper.selNameListStructure(databaseName,tableName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,8 +164,33 @@ public class AccreditServiceImpl implements AccreditService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Middle> listMiddle(String name) {
|
||||
return mapper.listMiddle(name);
|
||||
public List<Middle> listMiddle(String tableName ,String databaseName) {
|
||||
return mapper.listMiddle(tableName,databaseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Middle> listMiddle2(String databaseName) {
|
||||
return mapper.listMiddle2(databaseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMiddle> listUserMiddle(String tableName ,String databaseName) {
|
||||
return mapper.listUserMiddle(tableName,databaseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMiddle> listUserMiddle2(String databaseName) {
|
||||
return mapper.listUserMiddle2(databaseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateMiddle(Integer mid, Integer statusId) {
|
||||
return mapper.updateMiddle(mid,statusId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateUserMiddle(Integer mid, Integer statusId) {
|
||||
return mapper.updateUserMiddle(mapper,statusId);
|
||||
}
|
||||
|
||||
//获取字段注解
|
||||
|
|
|
@ -135,121 +135,122 @@ public class DataAccessServiceImpl implements IDataAccessService
|
|||
try {
|
||||
Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
Driver driver = (Driver) aClass.newInstance();
|
||||
System.out.println(driver);
|
||||
//获取数据库连接
|
||||
Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":"+ dataAccess.getPort() +"/"+ dataAccess.getDatabaseName() +"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8",dataAccess.getUsername(),dataAccess.getPassword());
|
||||
//获取数据库名
|
||||
//获取数据库的元数据
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
System.out.println(metaData);
|
||||
//获取全部表名
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet rs = statement.executeQuery("SHOW TABLES");
|
||||
while (rs.next()){
|
||||
stringList.add(rs.getString(1));
|
||||
}
|
||||
System.out.println(stringList);
|
||||
accreditMapper.delListStructure(dataAccess.getDatabaseName());
|
||||
//处理表名
|
||||
for (String s : stringList) {
|
||||
int i1 = accreditMapper.selectOneSqlJdbc(dataAccess.getDatabaseName(),s);
|
||||
if (i1>0){
|
||||
}else{
|
||||
PreparedStatement pst = connection.prepareCall("select * from " + s);
|
||||
ResultSetMetaData rsd = pst.getMetaData();
|
||||
//获取元数据
|
||||
DatabaseMetaData metaData1 = connection.getMetaData();
|
||||
Map<String,String> columnComments =getColumnComments(metaData,s);
|
||||
//添加数据结构
|
||||
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||
System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
||||
System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
||||
System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
||||
System.out.println("表名" + rsd.getTableName(i + 1));
|
||||
System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
||||
System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
||||
System.out.println("列数" + rsd.getColumnCount());
|
||||
System.out.println("列类型" + rsd.getColumnType(i + 1));
|
||||
System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
||||
System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
||||
System.out.println("精度" + rsd.getPrecision(i + 1));
|
||||
System.out.println("规模" + rsd.getScale(i + 1));
|
||||
System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
||||
System.out.println("是否为空" + rsd.isNullable(i + 1));
|
||||
System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
||||
System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
||||
System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
||||
System.out.println("签署" + rsd.isSigned(i + 1));
|
||||
System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
||||
System.out.println("只读" + rsd.isReadOnly(i + 1));
|
||||
System.out.println("是可写的" + rsd.isWritable(i + 1));
|
||||
System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
||||
ListStructure listStructure = new ListStructure();
|
||||
//获取数据库名
|
||||
listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
||||
//获取表名
|
||||
listStructure.setTableName(rsd.getTableName(i + 1));
|
||||
//获取java类型
|
||||
listStructure.setColumnLassName(rsd.getColumnClassName(i + 1));
|
||||
//获取映射类型
|
||||
listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
||||
//获取字段名称
|
||||
listStructure.setColumnName(rsd.getColumnName(i + 1));
|
||||
//获取长度
|
||||
listStructure.setPrecisions(rsd.getPrecision(i + 1));
|
||||
//获取小数
|
||||
listStructure.setScale(rsd.getScale(i + 1));
|
||||
//获取非空
|
||||
listStructure.setIsNull(rsd.isNullable(i + 1));
|
||||
//获取默认
|
||||
listStructure.setSchemaName(rsd.getSchemaName(i + 1));
|
||||
//获取注解
|
||||
listStructure.setColumnComments(columnComments.get(rsd.getColumnName(i + 1)));
|
||||
accreditMapper.insertListStructure(listStructure);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取所有的部门
|
||||
*/
|
||||
List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
for (SysDept sysDept : list) {
|
||||
Integer sysDeptIds = dataAccessMapper.selectOneMiddel(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
if (sysDeptIds == 0){
|
||||
//添加中间件
|
||||
dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
}
|
||||
}
|
||||
//获取所有用户
|
||||
List<SysUserVo> sysUserVos = sysUserMapper.listSelectSysUser();
|
||||
for (SysUserVo sysUserVo : sysUserVos) {
|
||||
Integer sysUserVoIds = dataAccessMapper.selectOneUserMiddel(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
if (sysUserVoIds == 0){
|
||||
//添加中间件
|
||||
dataAccessMapper.insertUserMiddle(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
}
|
||||
}
|
||||
ResultSet rst = statement.executeQuery("select TABLE_NAME, TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema = " + dataAccess.getDatabaseName());
|
||||
|
||||
//获取字段名
|
||||
// while (rs.next()){
|
||||
// stringList.add(rs.getString(1));
|
||||
// }
|
||||
// accreditMapper.delOneTableList(dataAccess.getDatabaseName(),);
|
||||
while (rst.next()){
|
||||
System.out.println("表名"+rst.getString(1)+",注释:"+rst.getString(2));
|
||||
//框架子类
|
||||
int i = accreditMapper.selectOneTableList(dataAccess.getDatabaseName(), s);
|
||||
if (i>0){
|
||||
accreditMapper.delOneTableList(dataAccess.getDatabaseName(), s);
|
||||
accreditMapper.inserttableList(dataAccess.getDatabaseName(),s);
|
||||
}else{
|
||||
accreditMapper.inserttableList(dataAccess.getDatabaseName(),s);
|
||||
}
|
||||
// accreditMapper.inserttableList(dataAccess,s);
|
||||
|
||||
}
|
||||
// accreditMapper.delListStructure(dataAccess.getDatabaseName());
|
||||
// 表介绍
|
||||
|
||||
//处理表名
|
||||
// for (String s : stringList) {
|
||||
// int i1 = accreditMapper.selectOneSqlJdbc(dataAccess.getDatabaseName(),s);
|
||||
// if (i1>0){
|
||||
// }else{
|
||||
// PreparedStatement pst = connection.prepareCall("select * from " + s);
|
||||
// ResultSetMetaData rsd = pst.getMetaData();
|
||||
// //获取元数据
|
||||
// DatabaseMetaData metaData1 = connection.getMetaData();
|
||||
// Map<String,String> columnComments =getColumnComments(metaData,s);
|
||||
// //添加数据结构
|
||||
// for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||
// System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
||||
// System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
||||
// System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
||||
// System.out.println("表名" + rsd.getTableName(i + 1));
|
||||
// System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
||||
// System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
||||
// System.out.println("列数" + rsd.getColumnCount());
|
||||
// System.out.println("列类型" + rsd.getColumnType(i + 1));
|
||||
// System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
||||
// System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
||||
// System.out.println("精度" + rsd.getPrecision(i + 1));
|
||||
// System.out.println("规模" + rsd.getScale(i + 1));
|
||||
// System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
||||
// System.out.println("是否为空" + rsd.isNullable(i + 1));
|
||||
// System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
||||
// System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
||||
// System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
||||
// System.out.println("签署" + rsd.isSigned(i + 1));
|
||||
// System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
||||
// System.out.println("只读" + rsd.isReadOnly(i + 1));
|
||||
// System.out.println("是可写的" + rsd.isWritable(i + 1));
|
||||
// System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
||||
// ListStructure listStructure = new ListStructure();
|
||||
// //获取数据库名
|
||||
// listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
||||
// //获取表名
|
||||
// listStructure.setTableName(rsd.getTableName(i + 1));
|
||||
// //获取java类型
|
||||
// listStructure.setColumnLassName(rsd.getColumnClassName(i + 1));
|
||||
// //获取映射类型
|
||||
// listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
||||
// //获取字段名称
|
||||
// listStructure.setColumnName(rsd.getColumnName(i + 1));
|
||||
// //获取长度
|
||||
// listStructure.setPrecisions(rsd.getPrecision(i + 1));
|
||||
// //获取小数
|
||||
// listStructure.setScale(rsd.getScale(i + 1));
|
||||
// //获取非空
|
||||
// listStructure.setIsNull(rsd.isNullable(i + 1));
|
||||
// //获取默认
|
||||
// listStructure.setSchemaName(rsd.getSchemaName(i + 1));
|
||||
// //获取注解
|
||||
// listStructure.setColumnComments(columnComments.get(rsd.getColumnName(i + 1)));
|
||||
// accreditMapper.insertListStructure(listStructure);
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * 获取所有的部门
|
||||
// */
|
||||
// List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
// for (SysDept sysDept : list) {
|
||||
// Integer sysDeptIds = dataAccessMapper.selectOneMiddel(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// if (sysDeptIds == 0){
|
||||
// //添加中间件
|
||||
// dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// }
|
||||
// }
|
||||
// //获取所有用户
|
||||
// List<SysUserVo> sysUserVos = sysUserMapper.listSelectSysUser();
|
||||
// for (SysUserVo sysUserVo : sysUserVos) {
|
||||
// Integer sysUserVoIds = dataAccessMapper.selectOneUserMiddel(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// if (sysUserVoIds == 0){
|
||||
// //添加中间件
|
||||
// dataAccessMapper.insertUserMiddle(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//关闭连接
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//获取结构父类比表
|
||||
Integer in = dataAccessMapper.oneSelFrimary(dataAccess);
|
||||
if (in<=0){
|
||||
dataAccessMapper.indexFrimary(dataAccess);
|
||||
}else{
|
||||
dataAccessMapper.deleteFrimary(dataAccess);
|
||||
dataAccessMapper.indexFrimary(dataAccess);
|
||||
}
|
||||
// Integer in = dataAccessMapper.oneSelFrimary(dataAccess);
|
||||
// if (in<=0){
|
||||
// dataAccessMapper.indexFrimary(dataAccess);
|
||||
// }else{
|
||||
// dataAccessMapper.deleteFrimary(dataAccess);
|
||||
// dataAccessMapper.indexFrimary(dataAccess);
|
||||
// }
|
||||
id = 1;
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
schema_name = #{schemaName} and
|
||||
column_comments = #{columnComments}
|
||||
</update>
|
||||
<update id="updateMiddle">
|
||||
update middle
|
||||
set status_id = #{statusId}
|
||||
where mid = #{mid};
|
||||
</update>
|
||||
<update id="updateUserMiddle">
|
||||
update user_maiddle
|
||||
set status_id = #{statusId}
|
||||
where mid = #{statusId};
|
||||
</update>
|
||||
<delete id="delListStructure">
|
||||
delete
|
||||
from list_structure
|
||||
|
@ -70,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selNameListStructure" resultType="com.muyu.system.domain.ListStructure">
|
||||
select *
|
||||
from list_structure
|
||||
where table_name = #{tableName} or catalog_name = #{tableName}
|
||||
where table_name = #{tableName} and catalog_name = #{databaseName}
|
||||
</select>
|
||||
<select id="selectOneTableList" resultType="java.lang.Integer">
|
||||
select count(name)
|
||||
|
@ -89,9 +99,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from list_structure where catalog_name = #{catalogName} and table_name = #{tableName} and column_name = #{columnName};
|
||||
</select>
|
||||
<select id="listMiddle" resultType="com.muyu.system.domain.Middle">
|
||||
select *
|
||||
from middle
|
||||
where database_name = #{name} or table_name = #{name};
|
||||
select m.mid,m.id,m.database_name,m.table_name,d.*
|
||||
from middle m
|
||||
left join sys_dept d on m.dept_id = d.dept_id
|
||||
where database_name = #{databaseName} and table_name = #{tableName};
|
||||
</select>
|
||||
<select id="listUserMiddle" resultType="com.muyu.system.domain.UserMiddle">
|
||||
select u.*,m.mid,m.id,m.database_name,m.table_name,m.status_id,d.dept_name
|
||||
from user_maiddle m left join sys_user u on m.user_id = u.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
where database_name = #{databaseName} and table_name = #{tableName}
|
||||
</select>
|
||||
<select id="listUserMiddle2" resultType="com.muyu.system.domain.UserMiddle">
|
||||
select u.*,m.mid,m.id,m.database_name,m.table_name,m.status_id,d.dept_name
|
||||
from user_maiddle m left join sys_user u on m.user_id = u.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
where database_name = #{databaseName}
|
||||
</select>
|
||||
<select id="listMiddle2" resultType="com.muyu.system.domain.Middle">
|
||||
select m.mid,m.id,m.database_name,m.table_name,d.*
|
||||
from middle m
|
||||
left join sys_dept d on m.dept_id = d.dept_id
|
||||
where database_name = #{databaseName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue