同步指定表结构到目标管控项目的表中
同步指定库中所有表结构到目标管控项目的表中
This commit is contained in:
parent
5478a347b8
commit
25fe49383b
12
pom.xml
12
pom.xml
@ -57,6 +57,18 @@
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>3.5.12</version>
|
||||
</dependency>
|
||||
<!-- fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.29</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package iet.ustb.sf;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("iet.ustb.sf.mapper")
|
||||
public class IetKpiServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
54
src/main/java/iet/ustb/sf/controller/SyncController.java
Normal file
54
src/main/java/iet/ustb/sf/controller/SyncController.java
Normal file
@ -0,0 +1,54 @@
|
||||
package iet.ustb.sf.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import iet.ustb.sf.common.R;
|
||||
import iet.ustb.sf.service.TableColumnService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* web中未使用的有用接口
|
||||
* SyncController
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/8/5 12:37:22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sync")
|
||||
@Tag(name = "web中未使用的有用接口")
|
||||
public class SyncController {
|
||||
|
||||
@Resource
|
||||
private TableColumnService tableColumnService;
|
||||
|
||||
/**
|
||||
* 同步指定表结构
|
||||
* @param params 表名
|
||||
* @return 结果
|
||||
*/
|
||||
@Operation(summary = "同步指定表结构")
|
||||
@PostMapping("/syncTableData")
|
||||
public R<String> syncTableData(@RequestBody JSONObject params) {
|
||||
String tableName = params.getString("tableName");
|
||||
String result = tableColumnService.syncTableData(tableName);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步指定库的所有表结构
|
||||
* @param params 库名
|
||||
* @return 结果
|
||||
*/
|
||||
@Operation(summary = "同步指定库的所有表结构")
|
||||
@PostMapping("/syncTableDataByDb")
|
||||
public R<String> syncTableDataByDb(@RequestBody JSONObject params) {
|
||||
String dbName = params.getString("dbName");
|
||||
String result = tableColumnService.syncTableDataByDb(dbName);
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
238
src/main/java/iet/ustb/sf/domain/Columns.java
Normal file
238
src/main/java/iet/ustb/sf/domain/Columns.java
Normal file
@ -0,0 +1,238 @@
|
||||
package iet.ustb.sf.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName columns
|
||||
*/
|
||||
@TableName(value ="information_schema.columns")
|
||||
@Data
|
||||
public class Columns {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableCatalog;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableSchema;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long ordinalPosition;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String columnDefault;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String isNullable;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long characterMaximumLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long characterOctetLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long numericPrecision;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long numericScale;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long datetimePrecision;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String characterSetName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String collationName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String columnKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String privileges;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String columnComment;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long columnSize;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long decimalDigits;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String generationExpression;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long srsId;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Columns other = (Columns) that;
|
||||
return (this.getTableCatalog() == null ? other.getTableCatalog() == null : this.getTableCatalog().equals(other.getTableCatalog()))
|
||||
&& (this.getTableSchema() == null ? other.getTableSchema() == null : this.getTableSchema().equals(other.getTableSchema()))
|
||||
&& (this.getTableName() == null ? other.getTableName() == null : this.getTableName().equals(other.getTableName()))
|
||||
&& (this.getColumnName() == null ? other.getColumnName() == null : this.getColumnName().equals(other.getColumnName()))
|
||||
&& (this.getOrdinalPosition() == null ? other.getOrdinalPosition() == null : this.getOrdinalPosition().equals(other.getOrdinalPosition()))
|
||||
&& (this.getColumnDefault() == null ? other.getColumnDefault() == null : this.getColumnDefault().equals(other.getColumnDefault()))
|
||||
&& (this.getIsNullable() == null ? other.getIsNullable() == null : this.getIsNullable().equals(other.getIsNullable()))
|
||||
&& (this.getDataType() == null ? other.getDataType() == null : this.getDataType().equals(other.getDataType()))
|
||||
&& (this.getCharacterMaximumLength() == null ? other.getCharacterMaximumLength() == null : this.getCharacterMaximumLength().equals(other.getCharacterMaximumLength()))
|
||||
&& (this.getCharacterOctetLength() == null ? other.getCharacterOctetLength() == null : this.getCharacterOctetLength().equals(other.getCharacterOctetLength()))
|
||||
&& (this.getNumericPrecision() == null ? other.getNumericPrecision() == null : this.getNumericPrecision().equals(other.getNumericPrecision()))
|
||||
&& (this.getNumericScale() == null ? other.getNumericScale() == null : this.getNumericScale().equals(other.getNumericScale()))
|
||||
&& (this.getDatetimePrecision() == null ? other.getDatetimePrecision() == null : this.getDatetimePrecision().equals(other.getDatetimePrecision()))
|
||||
&& (this.getCharacterSetName() == null ? other.getCharacterSetName() == null : this.getCharacterSetName().equals(other.getCharacterSetName()))
|
||||
&& (this.getCollationName() == null ? other.getCollationName() == null : this.getCollationName().equals(other.getCollationName()))
|
||||
&& (this.getColumnType() == null ? other.getColumnType() == null : this.getColumnType().equals(other.getColumnType()))
|
||||
&& (this.getColumnKey() == null ? other.getColumnKey() == null : this.getColumnKey().equals(other.getColumnKey()))
|
||||
&& (this.getExtra() == null ? other.getExtra() == null : this.getExtra().equals(other.getExtra()))
|
||||
&& (this.getPrivileges() == null ? other.getPrivileges() == null : this.getPrivileges().equals(other.getPrivileges()))
|
||||
&& (this.getColumnComment() == null ? other.getColumnComment() == null : this.getColumnComment().equals(other.getColumnComment()))
|
||||
&& (this.getColumnSize() == null ? other.getColumnSize() == null : this.getColumnSize().equals(other.getColumnSize()))
|
||||
&& (this.getDecimalDigits() == null ? other.getDecimalDigits() == null : this.getDecimalDigits().equals(other.getDecimalDigits()))
|
||||
&& (this.getGenerationExpression() == null ? other.getGenerationExpression() == null : this.getGenerationExpression().equals(other.getGenerationExpression()))
|
||||
&& (this.getSrsId() == null ? other.getSrsId() == null : this.getSrsId().equals(other.getSrsId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getTableCatalog() == null) ? 0 : getTableCatalog().hashCode());
|
||||
result = prime * result + ((getTableSchema() == null) ? 0 : getTableSchema().hashCode());
|
||||
result = prime * result + ((getTableName() == null) ? 0 : getTableName().hashCode());
|
||||
result = prime * result + ((getColumnName() == null) ? 0 : getColumnName().hashCode());
|
||||
result = prime * result + ((getOrdinalPosition() == null) ? 0 : getOrdinalPosition().hashCode());
|
||||
result = prime * result + ((getColumnDefault() == null) ? 0 : getColumnDefault().hashCode());
|
||||
result = prime * result + ((getIsNullable() == null) ? 0 : getIsNullable().hashCode());
|
||||
result = prime * result + ((getDataType() == null) ? 0 : getDataType().hashCode());
|
||||
result = prime * result + ((getCharacterMaximumLength() == null) ? 0 : getCharacterMaximumLength().hashCode());
|
||||
result = prime * result + ((getCharacterOctetLength() == null) ? 0 : getCharacterOctetLength().hashCode());
|
||||
result = prime * result + ((getNumericPrecision() == null) ? 0 : getNumericPrecision().hashCode());
|
||||
result = prime * result + ((getNumericScale() == null) ? 0 : getNumericScale().hashCode());
|
||||
result = prime * result + ((getDatetimePrecision() == null) ? 0 : getDatetimePrecision().hashCode());
|
||||
result = prime * result + ((getCharacterSetName() == null) ? 0 : getCharacterSetName().hashCode());
|
||||
result = prime * result + ((getCollationName() == null) ? 0 : getCollationName().hashCode());
|
||||
result = prime * result + ((getColumnType() == null) ? 0 : getColumnType().hashCode());
|
||||
result = prime * result + ((getColumnKey() == null) ? 0 : getColumnKey().hashCode());
|
||||
result = prime * result + ((getExtra() == null) ? 0 : getExtra().hashCode());
|
||||
result = prime * result + ((getPrivileges() == null) ? 0 : getPrivileges().hashCode());
|
||||
result = prime * result + ((getColumnComment() == null) ? 0 : getColumnComment().hashCode());
|
||||
result = prime * result + ((getColumnSize() == null) ? 0 : getColumnSize().hashCode());
|
||||
result = prime * result + ((getDecimalDigits() == null) ? 0 : getDecimalDigits().hashCode());
|
||||
result = prime * result + ((getGenerationExpression() == null) ? 0 : getGenerationExpression().hashCode());
|
||||
result = prime * result + ((getSrsId() == null) ? 0 : getSrsId().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", tableCatalog=").append(tableCatalog);
|
||||
sb.append(", tableSchema=").append(tableSchema);
|
||||
sb.append(", tableName=").append(tableName);
|
||||
sb.append(", columnName=").append(columnName);
|
||||
sb.append(", ordinalPosition=").append(ordinalPosition);
|
||||
sb.append(", columnDefault=").append(columnDefault);
|
||||
sb.append(", isNullable=").append(isNullable);
|
||||
sb.append(", dataType=").append(dataType);
|
||||
sb.append(", characterMaximumLength=").append(characterMaximumLength);
|
||||
sb.append(", characterOctetLength=").append(characterOctetLength);
|
||||
sb.append(", numericPrecision=").append(numericPrecision);
|
||||
sb.append(", numericScale=").append(numericScale);
|
||||
sb.append(", datetimePrecision=").append(datetimePrecision);
|
||||
sb.append(", characterSetName=").append(characterSetName);
|
||||
sb.append(", collationName=").append(collationName);
|
||||
sb.append(", columnType=").append(columnType);
|
||||
sb.append(", columnKey=").append(columnKey);
|
||||
sb.append(", extra=").append(extra);
|
||||
sb.append(", privileges=").append(privileges);
|
||||
sb.append(", columnComment=").append(columnComment);
|
||||
sb.append(", columnSize=").append(columnSize);
|
||||
sb.append(", decimalDigits=").append(decimalDigits);
|
||||
sb.append(", generationExpression=").append(generationExpression);
|
||||
sb.append(", srsId=").append(srsId);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
167
src/main/java/iet/ustb/sf/domain/TableColumn.java
Normal file
167
src/main/java/iet/ustb/sf/domain/TableColumn.java
Normal file
@ -0,0 +1,167 @@
|
||||
package iet.ustb.sf.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName mbgk_table_column
|
||||
*/
|
||||
@TableName(value ="mbgk_table_column")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableColumn {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 表名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 中文表名称
|
||||
*/
|
||||
private String tableNameCn;
|
||||
|
||||
/**
|
||||
* 列名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 中文列名称
|
||||
*/
|
||||
private String columnNameCn;
|
||||
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
private String colnumnType;
|
||||
|
||||
/**
|
||||
* 模式
|
||||
*/
|
||||
private String schema;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 删除标识,1:true,0:false
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 主键标识,1:true,0:false
|
||||
*/
|
||||
private Integer isPrimary;
|
||||
|
||||
/**
|
||||
* 操作,1:可计算,2:可筛选,可以有多个中间用逗号英文分割
|
||||
*/
|
||||
private String op;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("sort_")
|
||||
private Integer sort;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TableColumn other = (TableColumn) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTableName() == null ? other.getTableName() == null : this.getTableName().equals(other.getTableName()))
|
||||
&& (this.getTableNameCn() == null ? other.getTableNameCn() == null : this.getTableNameCn().equals(other.getTableNameCn()))
|
||||
&& (this.getColumnName() == null ? other.getColumnName() == null : this.getColumnName().equals(other.getColumnName()))
|
||||
&& (this.getColumnNameCn() == null ? other.getColumnNameCn() == null : this.getColumnNameCn().equals(other.getColumnNameCn()))
|
||||
&& (this.getColnumnType() == null ? other.getColnumnType() == null : this.getColnumnType().equals(other.getColnumnType()))
|
||||
&& (this.getSchema() == null ? other.getSchema() == null : this.getSchema().equals(other.getSchema()))
|
||||
&& (this.getDataSource() == null ? other.getDataSource() == null : this.getDataSource().equals(other.getDataSource()))
|
||||
&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
|
||||
&& (this.getIsPrimary() == null ? other.getIsPrimary() == null : this.getIsPrimary().equals(other.getIsPrimary()))
|
||||
&& (this.getOp() == null ? other.getOp() == null : this.getOp().equals(other.getOp()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getTableName() == null) ? 0 : getTableName().hashCode());
|
||||
result = prime * result + ((getTableNameCn() == null) ? 0 : getTableNameCn().hashCode());
|
||||
result = prime * result + ((getColumnName() == null) ? 0 : getColumnName().hashCode());
|
||||
result = prime * result + ((getColumnNameCn() == null) ? 0 : getColumnNameCn().hashCode());
|
||||
result = prime * result + ((getColnumnType() == null) ? 0 : getColnumnType().hashCode());
|
||||
result = prime * result + ((getSchema() == null) ? 0 : getSchema().hashCode());
|
||||
result = prime * result + ((getDataSource() == null) ? 0 : getDataSource().hashCode());
|
||||
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
|
||||
result = prime * result + ((getIsPrimary() == null) ? 0 : getIsPrimary().hashCode());
|
||||
result = prime * result + ((getOp() == null) ? 0 : getOp().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", tableName=").append(tableName);
|
||||
sb.append(", tableNameCn=").append(tableNameCn);
|
||||
sb.append(", columnName=").append(columnName);
|
||||
sb.append(", columnNameCn=").append(columnNameCn);
|
||||
sb.append(", colnumnType=").append(colnumnType);
|
||||
sb.append(", schema=").append(schema);
|
||||
sb.append(", dataSource=").append(dataSource);
|
||||
sb.append(", isDelete=").append(isDelete);
|
||||
sb.append(", isPrimary=").append(isPrimary);
|
||||
sb.append(", op=").append(op);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", sort=").append(sort);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
215
src/main/java/iet/ustb/sf/domain/Tables.java
Normal file
215
src/main/java/iet/ustb/sf/domain/Tables.java
Normal file
@ -0,0 +1,215 @@
|
||||
package iet.ustb.sf.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName tables
|
||||
*/
|
||||
@TableName(value ="information_schema.tables")
|
||||
@Data
|
||||
public class Tables {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableCatalog;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableSchema;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String engine;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long version;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String rowFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long tableRows;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long avgRowLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long dataLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long maxDataLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long indexLength;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long dataFree;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long autoIncrement;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date checkTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableCollation;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long checksum;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String tableComment;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tables other = (Tables) that;
|
||||
return (this.getTableCatalog() == null ? other.getTableCatalog() == null : this.getTableCatalog().equals(other.getTableCatalog()))
|
||||
&& (this.getTableSchema() == null ? other.getTableSchema() == null : this.getTableSchema().equals(other.getTableSchema()))
|
||||
&& (this.getTableName() == null ? other.getTableName() == null : this.getTableName().equals(other.getTableName()))
|
||||
&& (this.getTableType() == null ? other.getTableType() == null : this.getTableType().equals(other.getTableType()))
|
||||
&& (this.getEngine() == null ? other.getEngine() == null : this.getEngine().equals(other.getEngine()))
|
||||
&& (this.getVersion() == null ? other.getVersion() == null : this.getVersion().equals(other.getVersion()))
|
||||
&& (this.getRowFormat() == null ? other.getRowFormat() == null : this.getRowFormat().equals(other.getRowFormat()))
|
||||
&& (this.getTableRows() == null ? other.getTableRows() == null : this.getTableRows().equals(other.getTableRows()))
|
||||
&& (this.getAvgRowLength() == null ? other.getAvgRowLength() == null : this.getAvgRowLength().equals(other.getAvgRowLength()))
|
||||
&& (this.getDataLength() == null ? other.getDataLength() == null : this.getDataLength().equals(other.getDataLength()))
|
||||
&& (this.getMaxDataLength() == null ? other.getMaxDataLength() == null : this.getMaxDataLength().equals(other.getMaxDataLength()))
|
||||
&& (this.getIndexLength() == null ? other.getIndexLength() == null : this.getIndexLength().equals(other.getIndexLength()))
|
||||
&& (this.getDataFree() == null ? other.getDataFree() == null : this.getDataFree().equals(other.getDataFree()))
|
||||
&& (this.getAutoIncrement() == null ? other.getAutoIncrement() == null : this.getAutoIncrement().equals(other.getAutoIncrement()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||
&& (this.getCheckTime() == null ? other.getCheckTime() == null : this.getCheckTime().equals(other.getCheckTime()))
|
||||
&& (this.getTableCollation() == null ? other.getTableCollation() == null : this.getTableCollation().equals(other.getTableCollation()))
|
||||
&& (this.getChecksum() == null ? other.getChecksum() == null : this.getChecksum().equals(other.getChecksum()))
|
||||
&& (this.getCreateOptions() == null ? other.getCreateOptions() == null : this.getCreateOptions().equals(other.getCreateOptions()))
|
||||
&& (this.getTableComment() == null ? other.getTableComment() == null : this.getTableComment().equals(other.getTableComment()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getTableCatalog() == null) ? 0 : getTableCatalog().hashCode());
|
||||
result = prime * result + ((getTableSchema() == null) ? 0 : getTableSchema().hashCode());
|
||||
result = prime * result + ((getTableName() == null) ? 0 : getTableName().hashCode());
|
||||
result = prime * result + ((getTableType() == null) ? 0 : getTableType().hashCode());
|
||||
result = prime * result + ((getEngine() == null) ? 0 : getEngine().hashCode());
|
||||
result = prime * result + ((getVersion() == null) ? 0 : getVersion().hashCode());
|
||||
result = prime * result + ((getRowFormat() == null) ? 0 : getRowFormat().hashCode());
|
||||
result = prime * result + ((getTableRows() == null) ? 0 : getTableRows().hashCode());
|
||||
result = prime * result + ((getAvgRowLength() == null) ? 0 : getAvgRowLength().hashCode());
|
||||
result = prime * result + ((getDataLength() == null) ? 0 : getDataLength().hashCode());
|
||||
result = prime * result + ((getMaxDataLength() == null) ? 0 : getMaxDataLength().hashCode());
|
||||
result = prime * result + ((getIndexLength() == null) ? 0 : getIndexLength().hashCode());
|
||||
result = prime * result + ((getDataFree() == null) ? 0 : getDataFree().hashCode());
|
||||
result = prime * result + ((getAutoIncrement() == null) ? 0 : getAutoIncrement().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
result = prime * result + ((getCheckTime() == null) ? 0 : getCheckTime().hashCode());
|
||||
result = prime * result + ((getTableCollation() == null) ? 0 : getTableCollation().hashCode());
|
||||
result = prime * result + ((getChecksum() == null) ? 0 : getChecksum().hashCode());
|
||||
result = prime * result + ((getCreateOptions() == null) ? 0 : getCreateOptions().hashCode());
|
||||
result = prime * result + ((getTableComment() == null) ? 0 : getTableComment().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", tableCatalog=").append(tableCatalog);
|
||||
sb.append(", tableSchema=").append(tableSchema);
|
||||
sb.append(", tableName=").append(tableName);
|
||||
sb.append(", tableType=").append(tableType);
|
||||
sb.append(", engine=").append(engine);
|
||||
sb.append(", version=").append(version);
|
||||
sb.append(", rowFormat=").append(rowFormat);
|
||||
sb.append(", tableRows=").append(tableRows);
|
||||
sb.append(", avgRowLength=").append(avgRowLength);
|
||||
sb.append(", dataLength=").append(dataLength);
|
||||
sb.append(", maxDataLength=").append(maxDataLength);
|
||||
sb.append(", indexLength=").append(indexLength);
|
||||
sb.append(", dataFree=").append(dataFree);
|
||||
sb.append(", autoIncrement=").append(autoIncrement);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", checkTime=").append(checkTime);
|
||||
sb.append(", tableCollation=").append(tableCollation);
|
||||
sb.append(", checksum=").append(checksum);
|
||||
sb.append(", createOptions=").append(createOptions);
|
||||
sb.append(", tableComment=").append(tableComment);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -18,7 +18,8 @@ public enum ErrorCode {
|
||||
NOT_FOUND_ERROR(40400, "请求数据不存在"),
|
||||
FORBIDDEN_ERROR(40300, "禁止访问"),
|
||||
SYSTEM_ERROR(50000, "系统内部异常"),
|
||||
OPERATION_ERROR(50001, "操作失败");
|
||||
OPERATION_ERROR(50001, "操作失败"),
|
||||
NULL_ERROR(60000, "空值");
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
|
18
src/main/java/iet/ustb/sf/mapper/ColumnsMapper.java
Normal file
18
src/main/java/iet/ustb/sf/mapper/ColumnsMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package iet.ustb.sf.mapper;
|
||||
|
||||
import iet.ustb.sf.domain.Columns;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【columns】的数据库操作Mapper
|
||||
* @createDate 2025-08-05 13:53:45
|
||||
* @Entity iet.ustb.sf.domain.Columns
|
||||
*/
|
||||
public interface ColumnsMapper extends BaseMapper<Columns> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
49
src/main/java/iet/ustb/sf/mapper/TableColumnMapper.java
Normal file
49
src/main/java/iet/ustb/sf/mapper/TableColumnMapper.java
Normal file
@ -0,0 +1,49 @@
|
||||
package iet.ustb.sf.mapper;
|
||||
|
||||
import iet.ustb.sf.domain.TableColumn;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【mbgk_table_column】的数据库操作Mapper
|
||||
* @createDate 2025-08-05 12:33:36
|
||||
* @Entity iet.ustb.sf.domain.TableColumn
|
||||
*/
|
||||
public interface TableColumnMapper extends BaseMapper<TableColumn> {
|
||||
|
||||
@Select("SELECT DISTINCT c.table_name AS \"tableName\", " +
|
||||
" c.column_name AS \"columnName\", " +
|
||||
" c.data_type AS \"colnumnType\", " +
|
||||
" cc.comments AS \"columnNameCn\", " +
|
||||
" t.comments AS \"tableNameCn\", " +
|
||||
" t.owner AS \"schema\", " +
|
||||
" CASE " +
|
||||
" WHEN kcu.column_name IS NOT NULL THEN '1' " +
|
||||
" ELSE '0' " +
|
||||
" END AS \"isPrimary\" " +
|
||||
"FROM all_tab_columns c " +
|
||||
" JOIN all_tab_comments t " +
|
||||
" ON c.table_name = t.table_name " +
|
||||
" AND c.owner = t.owner " +
|
||||
" LEFT JOIN all_col_comments cc " +
|
||||
" ON c.table_name = cc.table_name " +
|
||||
" AND c.column_name = cc.column_name " +
|
||||
" AND c.owner = cc.owner " +
|
||||
" LEFT JOIN all_cons_columns kcu " +
|
||||
" ON c.table_name = kcu.table_name " +
|
||||
" AND c.column_name = kcu.column_name " +
|
||||
" AND c.owner = kcu.owner " +
|
||||
" LEFT JOIN all_constraints ku " +
|
||||
" ON kcu.constraint_name = ku.constraint_name " +
|
||||
" AND ku.constraint_type = 'P' " +
|
||||
"WHERE c.table_name = ?1")
|
||||
List<Map<String,?>> getOriColumnByTableName(String tableName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
18
src/main/java/iet/ustb/sf/mapper/TablesMapper.java
Normal file
18
src/main/java/iet/ustb/sf/mapper/TablesMapper.java
Normal file
@ -0,0 +1,18 @@
|
||||
package iet.ustb.sf.mapper;
|
||||
|
||||
import iet.ustb.sf.domain.Tables;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【tables】的数据库操作Mapper
|
||||
* @createDate 2025-08-05 13:08:39
|
||||
* @Entity iet.ustb.sf.domain.Tables
|
||||
*/
|
||||
public interface TablesMapper extends BaseMapper<Tables> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
13
src/main/java/iet/ustb/sf/service/ColumnsService.java
Normal file
13
src/main/java/iet/ustb/sf/service/ColumnsService.java
Normal file
@ -0,0 +1,13 @@
|
||||
package iet.ustb.sf.service;
|
||||
|
||||
import iet.ustb.sf.domain.Columns;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【columns】的数据库操作Service
|
||||
* @createDate 2025-08-05 13:53:45
|
||||
*/
|
||||
public interface ColumnsService extends IService<Columns> {
|
||||
|
||||
}
|
16
src/main/java/iet/ustb/sf/service/TableColumnService.java
Normal file
16
src/main/java/iet/ustb/sf/service/TableColumnService.java
Normal file
@ -0,0 +1,16 @@
|
||||
package iet.ustb.sf.service;
|
||||
|
||||
import iet.ustb.sf.domain.TableColumn;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【mbgk_table_column】的数据库操作Service
|
||||
* @createDate 2025-08-05 12:33:36
|
||||
*/
|
||||
public interface TableColumnService extends IService<TableColumn> {
|
||||
|
||||
String syncTableData(String tableName);
|
||||
|
||||
String syncTableDataByDb(String dbName);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package iet.ustb.sf.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import iet.ustb.sf.domain.Columns;
|
||||
import iet.ustb.sf.service.ColumnsService;
|
||||
import iet.ustb.sf.mapper.ColumnsMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【columns】的数据库操作Service实现
|
||||
* @createDate 2025-08-05 13:53:45
|
||||
*/
|
||||
@Service
|
||||
public class ColumnsServiceImpl extends ServiceImpl<ColumnsMapper, Columns>
|
||||
implements ColumnsService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,113 @@
|
||||
package iet.ustb.sf.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import iet.ustb.sf.domain.Columns;
|
||||
import iet.ustb.sf.domain.TableColumn;
|
||||
import iet.ustb.sf.domain.Tables;
|
||||
import iet.ustb.sf.exception.ThrowUtils;
|
||||
import iet.ustb.sf.mapper.ColumnsMapper;
|
||||
import iet.ustb.sf.mapper.TablesMapper;
|
||||
import iet.ustb.sf.service.TableColumnService;
|
||||
import iet.ustb.sf.mapper.TableColumnMapper;
|
||||
import iet.ustb.sf.util.CheckUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hyy
|
||||
* @description 针对表【mbgk_table_column】的数据库操作Service实现
|
||||
* @createDate 2025-08-05 12:33:36
|
||||
*/
|
||||
@Service
|
||||
public class TableColumnServiceImpl extends ServiceImpl<TableColumnMapper, TableColumn>
|
||||
implements TableColumnService {
|
||||
|
||||
@Resource
|
||||
private TableColumnMapper tableColumnMapper;
|
||||
|
||||
@Resource
|
||||
private TablesMapper tablesMapper;
|
||||
|
||||
@Resource
|
||||
private ColumnsMapper columnsMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncTableData(String tableName) {
|
||||
CheckUtils.checkTableName(tableName);
|
||||
List<TableColumn> list = tableColumnMapper.selectList(new QueryWrapper<TableColumn>().eq("table_name", tableName));
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
List<String> columnList = list.stream().map(TableColumn::getColumnName).toList();
|
||||
|
||||
List<Columns> oriList = columnsMapper.selectList(new QueryWrapper<Columns>().in("table_name", tableName));
|
||||
if (oriList == null) {
|
||||
oriList = new ArrayList<>();
|
||||
}
|
||||
List<String> oriColumns = oriList.stream().map(Columns::getColumnName).toList();
|
||||
|
||||
Tables tables = tablesMapper.selectOne(new QueryWrapper<Tables>().eq("table_name", tableName));
|
||||
|
||||
List<TableColumn> saveList = new ArrayList<>();
|
||||
Date now = new Date();
|
||||
int addCount = 0;
|
||||
for (Columns columns : oriList) {
|
||||
if (columnList.contains(columns.getColumnName())) {
|
||||
continue;
|
||||
}
|
||||
TableColumn ori = TableColumn.builder()
|
||||
.id(UUID.randomUUID().toString())
|
||||
.tableName(tableName)
|
||||
.tableNameCn(tables.getTableComment())
|
||||
.columnName(columns.getColumnName())
|
||||
.columnNameCn(columns.getColumnComment())
|
||||
.colnumnType(columns.getDataType())
|
||||
.schema(columns.getTableSchema())
|
||||
.isDelete(0)
|
||||
.isPrimary("UNI".equals(columns.getColumnKey()) ? 1 : 0)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.sort(list.size())
|
||||
.build();
|
||||
saveList.add(ori);
|
||||
list.add(ori);
|
||||
addCount++;
|
||||
}
|
||||
int delCount = 0;
|
||||
for (TableColumn tableColumn : list) {
|
||||
if (!oriColumns.contains(tableColumn.getColumnName())) {
|
||||
tableColumn.setIsDelete(1);
|
||||
tableColumn.setUpdateTime(now);
|
||||
saveList.add(tableColumn);
|
||||
delCount++;
|
||||
}
|
||||
}
|
||||
tableColumnMapper.insert(saveList);
|
||||
return "添加" + addCount + "个字段,删除" + delCount + "个字段";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncTableDataByDb(String dbName) {
|
||||
List<Tables> tablesList = tablesMapper.selectList(new QueryWrapper<Tables>().eq("table_schema", dbName));
|
||||
ThrowUtils.throwIf(tablesList.size() <= 0, new RuntimeException("数据库不存在!"));
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (Tables tables : tablesList) {
|
||||
String tableName = tables.getTableName();
|
||||
result.append("\n" + "数据库表:").append(tableName);
|
||||
result.append(syncTableData(tableName));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
42
src/main/java/iet/ustb/sf/util/CheckUtils.java
Normal file
42
src/main/java/iet/ustb/sf/util/CheckUtils.java
Normal file
@ -0,0 +1,42 @@
|
||||
package iet.ustb.sf.util;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import iet.ustb.sf.exception.ErrorCode;
|
||||
import iet.ustb.sf.exception.ThrowUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CheckUtils
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/8/5 12:43:14
|
||||
*/
|
||||
@Component
|
||||
public class CheckUtils {
|
||||
|
||||
/**
|
||||
* 字符串空值验证
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param name 中文名
|
||||
*/
|
||||
public static void checkEmpty(String str, String name) {
|
||||
ThrowUtils.throwIf(StringUtils.isEmpty(str), ErrorCode.NULL_ERROR, name + "不能为空!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 表名验证
|
||||
*
|
||||
* @param tableName 表名
|
||||
*/
|
||||
public static void checkTableName(String tableName) {
|
||||
checkEmpty(tableName, "表名");
|
||||
String sql = "SELECT COUNT(1) FROM information_schema.tables WHERE table_schema = 'mbgk' AND table_name = '" + tableName + "'";
|
||||
long cnt = SqlRunner.db().selectCount(sql);
|
||||
ThrowUtils.throwIf(cnt <= 0, new RuntimeException("表" + tableName + "不存在!"));
|
||||
}
|
||||
}
|
@ -17,4 +17,13 @@ springdoc:
|
||||
knife4j:
|
||||
enable: true
|
||||
setting:
|
||||
language: zh_cn
|
||||
language: zh_cn
|
||||
mybatis-plus:
|
||||
global-config:
|
||||
enable-sql-runner: true
|
||||
configuration:
|
||||
# ??????????
|
||||
map-underscore-to-camel-case: true
|
||||
# ????SQL
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
41
src/main/resources/iet/ustb/sf/mapper/ColumnsMapper.xml
Normal file
41
src/main/resources/iet/ustb/sf/mapper/ColumnsMapper.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?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="iet.ustb.sf.mapper.ColumnsMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="iet.ustb.sf.domain.Columns">
|
||||
<result property="tableCatalog" column="TABLE_CATALOG" />
|
||||
<result property="tableSchema" column="TABLE_SCHEMA" />
|
||||
<result property="tableName" column="TABLE_NAME" />
|
||||
<result property="columnName" column="COLUMN_NAME" />
|
||||
<result property="ordinalPosition" column="ORDINAL_POSITION" />
|
||||
<result property="columnDefault" column="COLUMN_DEFAULT" />
|
||||
<result property="isNullable" column="IS_NULLABLE" />
|
||||
<result property="dataType" column="DATA_TYPE" />
|
||||
<result property="characterMaximumLength" column="CHARACTER_MAXIMUM_LENGTH" />
|
||||
<result property="characterOctetLength" column="CHARACTER_OCTET_LENGTH" />
|
||||
<result property="numericPrecision" column="NUMERIC_PRECISION" />
|
||||
<result property="numericScale" column="NUMERIC_SCALE" />
|
||||
<result property="datetimePrecision" column="DATETIME_PRECISION" />
|
||||
<result property="characterSetName" column="CHARACTER_SET_NAME" />
|
||||
<result property="collationName" column="COLLATION_NAME" />
|
||||
<result property="columnType" column="COLUMN_TYPE" />
|
||||
<result property="columnKey" column="COLUMN_KEY" />
|
||||
<result property="extra" column="EXTRA" />
|
||||
<result property="privileges" column="PRIVILEGES" />
|
||||
<result property="columnComment" column="COLUMN_COMMENT" />
|
||||
<result property="columnSize" column="COLUMN_SIZE" />
|
||||
<result property="decimalDigits" column="DECIMAL_DIGITS" />
|
||||
<result property="generationExpression" column="GENERATION_EXPRESSION" />
|
||||
<result property="srsId" column="SRS_ID" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,ORDINAL_POSITION,COLUMN_DEFAULT,
|
||||
IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_OCTET_LENGTH,NUMERIC_PRECISION,
|
||||
NUMERIC_SCALE,DATETIME_PRECISION,CHARACTER_SET_NAME,COLLATION_NAME,COLUMN_TYPE,
|
||||
COLUMN_KEY,EXTRA,PRIVILEGES,COLUMN_COMMENT,COLUMN_SIZE,
|
||||
DECIMAL_DIGITS,GENERATION_EXPRESSION,SRS_ID
|
||||
</sql>
|
||||
</mapper>
|
29
src/main/resources/iet/ustb/sf/mapper/TableColumnMapper.xml
Normal file
29
src/main/resources/iet/ustb/sf/mapper/TableColumnMapper.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?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="iet.ustb.sf.mapper.TableColumnMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="iet.ustb.sf.domain.TableColumn">
|
||||
<result property="id" column="id" />
|
||||
<result property="table_name" column="table_name" />
|
||||
<result property="table_name_cn" column="table_name_cn" />
|
||||
<result property="column_name" column="column_name" />
|
||||
<result property="column_name_cn" column="column_name_cn" />
|
||||
<result property="colnumn_type" column="colnumn_type" />
|
||||
<result property="schema" column="schema" />
|
||||
<result property="data_source" column="data_source" />
|
||||
<result property="is_delete" column="is_delete" />
|
||||
<result property="is_primary" column="is_primary" />
|
||||
<result property="op" column="op" />
|
||||
<result property="create_time" column="create_time" />
|
||||
<result property="update_time" column="update_time" />
|
||||
<result property="sort_" column="sort_" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,table_name,table_name_cn,column_name,column_name_cn,colnumn_type,
|
||||
schema,data_source,is_delete,is_primary,op,
|
||||
create_time,update_time,sort_
|
||||
</sql>
|
||||
</mapper>
|
37
src/main/resources/iet/ustb/sf/mapper/TablesMapper.xml
Normal file
37
src/main/resources/iet/ustb/sf/mapper/TablesMapper.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?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="iet.ustb.sf.mapper.TablesMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="iet.ustb.sf.domain.Tables">
|
||||
<result property="TABLE_CATALOG" column="TABLE_CATALOG" />
|
||||
<result property="TABLE_SCHEMA" column="TABLE_SCHEMA" />
|
||||
<result property="TABLE_NAME" column="TABLE_NAME" />
|
||||
<result property="TABLE_TYPE" column="TABLE_TYPE" />
|
||||
<result property="ENGINE" column="ENGINE" />
|
||||
<result property="VERSION" column="VERSION" />
|
||||
<result property="ROW_FORMAT" column="ROW_FORMAT" />
|
||||
<result property="TABLE_ROWS" column="TABLE_ROWS" />
|
||||
<result property="AVG_ROW_LENGTH" column="AVG_ROW_LENGTH" />
|
||||
<result property="DATA_LENGTH" column="DATA_LENGTH" />
|
||||
<result property="MAX_DATA_LENGTH" column="MAX_DATA_LENGTH" />
|
||||
<result property="INDEX_LENGTH" column="INDEX_LENGTH" />
|
||||
<result property="DATA_FREE" column="DATA_FREE" />
|
||||
<result property="AUTO_INCREMENT" column="AUTO_INCREMENT" />
|
||||
<result property="CREATE_TIME" column="CREATE_TIME" />
|
||||
<result property="UPDATE_TIME" column="UPDATE_TIME" />
|
||||
<result property="CHECK_TIME" column="CHECK_TIME" />
|
||||
<result property="TABLE_COLLATION" column="TABLE_COLLATION" />
|
||||
<result property="CHECKSUM" column="CHECKSUM" />
|
||||
<result property="CREATE_OPTIONS" column="CREATE_OPTIONS" />
|
||||
<result property="TABLE_COMMENT" column="TABLE_COMMENT" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,VERSION,
|
||||
ROW_FORMAT,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,
|
||||
INDEX_LENGTH,DATA_FREE,AUTO_INCREMENT,CREATE_TIME,UPDATE_TIME,
|
||||
CHECK_TIME,TABLE_COLLATION,CHECKSUM,CREATE_OPTIONS,TABLE_COMMENT
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user