修改
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package com.jeesite.modules.app.dao;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据表字段信息表
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2025-11-17
|
||||
*/
|
||||
@Data
|
||||
public class DataTableField implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 字段唯一标识(主键)
|
||||
*/
|
||||
private String fieldId;
|
||||
|
||||
/**
|
||||
* 关联的数据表ID(外键,关联data_table_info.table_id)
|
||||
*/
|
||||
private String tableId;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据表名称
|
||||
*/
|
||||
private String dataName;
|
||||
|
||||
/**
|
||||
* 字段序号(表示字段在表中的顺序)
|
||||
*/
|
||||
private Integer fieldOrder;
|
||||
|
||||
/**
|
||||
* 字段类型(如:int、varchar、datetime等)
|
||||
*/
|
||||
private String fieldType;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段长度(如varchar(50)中的50,数值型可表示精度)
|
||||
*/
|
||||
private Long fieldLength;
|
||||
|
||||
/**
|
||||
* 字段说明
|
||||
*/
|
||||
private String fieldRemark;
|
||||
|
||||
/**
|
||||
* 分区日期
|
||||
*/
|
||||
private String ds;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.jeesite.modules.app.dao;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 数据表基础信息表
|
||||
* </p>
|
||||
*
|
||||
* @author gaoxq
|
||||
* @since 2025-11-17
|
||||
*/
|
||||
@Data
|
||||
public class DataTableInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 数据表唯一标识(主键)
|
||||
*/
|
||||
private String tableId;
|
||||
|
||||
/**
|
||||
* 数据表名称
|
||||
*/
|
||||
private String dataName;
|
||||
|
||||
/**
|
||||
* 数据表描述
|
||||
*/
|
||||
private String tableComment;
|
||||
|
||||
/**
|
||||
* 数据表大小(单位:MB)
|
||||
*/
|
||||
private BigDecimal tableSize;
|
||||
|
||||
/**
|
||||
* 数据来源(如:业务系统、文件导入等)
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 记录条数
|
||||
*/
|
||||
private Long dataRows;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 数据标识
|
||||
*/
|
||||
private String dbId;
|
||||
|
||||
/**
|
||||
* 分区日期
|
||||
*/
|
||||
private String ds;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jeesite.modules.app.dao;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TableTree implements Serializable {
|
||||
|
||||
DataTableInfo tableInfo;
|
||||
|
||||
List<DataTableField> tableFields;
|
||||
|
||||
public TableTree() {
|
||||
}
|
||||
|
||||
public TableTree(DataTableInfo tableInfo, List<DataTableField> tableFields) {
|
||||
this.tableInfo = tableInfo;
|
||||
this.tableFields = tableFields;
|
||||
}
|
||||
}
|
||||
@@ -63,16 +63,4 @@ public class DateUtils {
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
return String.format("%d-Q%d", date.getYear(), quarter);
|
||||
}
|
||||
|
||||
public static String dsValue() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// 格式化日期为yyyymmdd
|
||||
return currentDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
|
||||
public static String dsValueDaysAgo(long days) {
|
||||
LocalDate targetDate = LocalDate.now().minusDays(days);
|
||||
return targetDate.format(DATE_FORMATTER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.jeesite.modules.app.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class KeyUtil {
|
||||
|
||||
public static String ObjKey(int length, int type) {
|
||||
Random random = new Random();
|
||||
StringBuffer key = new StringBuffer();
|
||||
if (type == 1) {
|
||||
String str = "0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(10);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else if (type == 2) {
|
||||
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(36);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else if (type == 3) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(36);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
} else {
|
||||
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (int i = 0; i < length; ++i) {
|
||||
//从62个的数字或字母中选择
|
||||
int number = random.nextInt(62);
|
||||
//将产生的数字通过length次承载到key中
|
||||
key.append(str.charAt(number));
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.jeesite.modules.app.utils;
|
||||
|
||||
|
||||
import com.jeesite.modules.app.dao.DataTableField;
|
||||
import com.jeesite.modules.app.dao.DataTableInfo;
|
||||
import com.jeesite.modules.app.dao.TableTree;
|
||||
import com.jeesite.modules.biz.entity.BizDbConfig;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MysqlUtils {
|
||||
|
||||
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
||||
|
||||
// 需要排除的系统数据库
|
||||
private static final List<String> SYSTEM_DATABASES = Arrays.asList(
|
||||
"information_schema", "mysql", "performance_schema", "sys", "test"
|
||||
);
|
||||
|
||||
// 提取字段长度的正则表达式(如varchar(50) -> 50)
|
||||
private static final Pattern LENGTH_PATTERN = Pattern.compile("\\((\\d+)\\)");
|
||||
|
||||
/**
|
||||
* 封装:获取MySQL数据库连接
|
||||
*/
|
||||
private static Connection getConnection(String ip, Integer port, String username, String password) throws Exception {
|
||||
String driver = "com.mysql.cj.jdbc.Driver";
|
||||
String jdbcUrl = String.format(
|
||||
"jdbc:mysql://%s:%d/information_schema?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true",
|
||||
ip, port
|
||||
);
|
||||
Class.forName(driver); // 加载驱动
|
||||
return DriverManager.getConnection(jdbcUrl, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定MySQL连接的所有非系统库表结构信息
|
||||
*
|
||||
* @return 数据库名 -> 表信息列表(包含字段)的映射
|
||||
* @throws Exception 连接或查询异常
|
||||
*/
|
||||
public static Map<String, List<DataTableInfo>> getMysqlSchemaInfo(Connection conn) throws Exception {
|
||||
Map<String, List<DataTableInfo>> result = new HashMap<>();
|
||||
// 1. 获取所有非系统数据库
|
||||
List<String> databases = getNonSystemDatabases(conn);
|
||||
logger.info("获取到非系统数据库数量:", databases.size());
|
||||
// 2. 遍历数据库,获取表和字段信息
|
||||
for (String dbName : databases) {
|
||||
List<DataTableInfo> tableInfos = getTablesByDatabase(conn, dbName);
|
||||
result.put(dbName, tableInfos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有非系统数据库
|
||||
*/
|
||||
private static List<String> getNonSystemDatabases(Connection conn) throws SQLException {
|
||||
List<String> databases = new ArrayList<>();
|
||||
String sql = "SELECT SCHEMA_NAME FROM SCHEMATA WHERE SCHEMA_NAME NOT IN ("
|
||||
+ String.join(",", Collections.nCopies(SYSTEM_DATABASES.size(), "?")) + ")";
|
||||
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||
for (int i = 0; i < SYSTEM_DATABASES.size(); i++) {
|
||||
ps.setString(i + 1, SYSTEM_DATABASES.get(i));
|
||||
}
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
databases.add(rs.getString("SCHEMA_NAME"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return databases;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定数据库下的所有表信息(包含字段)
|
||||
*/
|
||||
private static List<DataTableInfo> getTablesByDatabase(Connection conn, String dbName) throws SQLException {
|
||||
List<DataTableInfo> tableInfos = new ArrayList<>();
|
||||
String tableSql = "SELECT " +
|
||||
"TABLE_NAME, TABLE_COMMENT, CREATE_TIME, UPDATE_TIME, " +
|
||||
"DATA_LENGTH, INDEX_LENGTH, TABLE_ROWS " +
|
||||
"FROM TABLES WHERE TABLE_SCHEMA = ?";
|
||||
try (PreparedStatement tablePs = conn.prepareStatement(tableSql)) {
|
||||
tablePs.setString(1, dbName);
|
||||
try (ResultSet tableRs = tablePs.executeQuery()) {
|
||||
while (tableRs.next()) {
|
||||
DataTableInfo tableInfo = buildDataTableInfo(tableRs, dbName);
|
||||
List<DataTableField> fields = getFieldsByTable(conn, dbName, tableInfo.getDataName());
|
||||
fields.forEach(field -> field.setTableId(tableInfo.getTableId()));
|
||||
tableInfos.add(tableInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tableInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建DataTableInfo实体
|
||||
*/
|
||||
private static DataTableInfo buildDataTableInfo(ResultSet tableRs, String dbName) throws SQLException {
|
||||
DataTableInfo tableInfo = new DataTableInfo();
|
||||
tableInfo.setTableId(vId.getUid());
|
||||
tableInfo.setDataName(tableRs.getString("TABLE_NAME"));
|
||||
tableInfo.setTableComment(tableRs.getString("TABLE_COMMENT"));
|
||||
long dataLength = tableRs.getLong("DATA_LENGTH");
|
||||
long indexLength = tableRs.getLong("INDEX_LENGTH");
|
||||
BigDecimal tableSize = BigDecimal.valueOf((dataLength + indexLength) / 1024.0 / 1024.0)
|
||||
.setScale(2, RoundingMode.HALF_UP);
|
||||
tableInfo.setTableSize(tableSize);
|
||||
tableInfo.setDataSource(dbName);
|
||||
tableInfo.setDataRows(tableRs.getLong("TABLE_ROWS"));
|
||||
String createDate = tableRs.getString("CREATE_TIME");
|
||||
tableInfo.setCreateTime(createDate != null ? createDate : vDate.getNow());
|
||||
String updateDate = tableRs.getString("UPDATE_TIME");
|
||||
tableInfo.setUpdateTime(updateDate != null ? updateDate : vDate.getNow());
|
||||
tableInfo.setDs(vDate.dsValue());
|
||||
return tableInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定表的字段信息
|
||||
*/
|
||||
private static List<DataTableField> getFieldsByTable(Connection conn, String dbName, String tableName) throws SQLException {
|
||||
List<DataTableField> fields = new ArrayList<>();
|
||||
String fieldSql = "SELECT " +
|
||||
"TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE, COLUMN_TYPE, COLUMN_COMMENT, " +
|
||||
"ORDINAL_POSITION, CHARACTER_MAXIMUM_LENGTH " +
|
||||
"FROM COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? " +
|
||||
"ORDER BY ORDINAL_POSITION";
|
||||
try (PreparedStatement fieldPs = conn.prepareStatement(fieldSql)) {
|
||||
fieldPs.setString(1, dbName);
|
||||
fieldPs.setString(2, tableName);
|
||||
try (ResultSet fieldRs = fieldPs.executeQuery()) {
|
||||
while (fieldRs.next()) {
|
||||
fields.add(buildDataTableField(fieldRs));
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建DataTableField实体
|
||||
*/
|
||||
private static DataTableField buildDataTableField(ResultSet fieldRs) throws SQLException {
|
||||
DataTableField field = new DataTableField();
|
||||
field.setFieldId(vId.getUid());
|
||||
field.setDataSource(fieldRs.getString("TABLE_SCHEMA"));
|
||||
field.setDataName(fieldRs.getString("TABLE_NAME"));
|
||||
field.setFieldName(fieldRs.getString("COLUMN_NAME"));
|
||||
field.setFieldType(fieldRs.getString("DATA_TYPE"));
|
||||
field.setFieldOrder(fieldRs.getInt("ORDINAL_POSITION"));
|
||||
field.setFieldRemark(fieldRs.getString("COLUMN_COMMENT"));
|
||||
Long length = fieldRs.getLong("CHARACTER_MAXIMUM_LENGTH");
|
||||
if (length == 0 || fieldRs.wasNull()) {
|
||||
length = extractLengthFromType(fieldRs.getString("COLUMN_TYPE"));
|
||||
}
|
||||
field.setFieldLength(length);
|
||||
field.setCreateTime(LocalDateTime.now());
|
||||
field.setDs(vDate.dsValue());
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从字段类型中提取长度(如int(11) -> 11)
|
||||
*/
|
||||
private static Long extractLengthFromType(String fieldType) {
|
||||
if (fieldType == null) return null;
|
||||
Matcher matcher = LENGTH_PATTERN.matcher(fieldType);
|
||||
if (matcher.find()) {
|
||||
try {
|
||||
return Long.parseLong(matcher.group(1));
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warn("提取字段长度失败,类型", fieldType, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<TableTree> getTableTrees(BizDbConfig dbConfig) {
|
||||
List<TableTree> tableTrees = new ArrayList<>();
|
||||
try {
|
||||
Connection conn = getConnection(dbConfig.getDbIp(), dbConfig.getDbPort(), dbConfig.getDbUsername(), dbConfig.getDbPassword());
|
||||
Map<String, List<DataTableInfo>> schemaInfo = MysqlUtils.getMysqlSchemaInfo(conn);
|
||||
for (Map.Entry<String, List<DataTableInfo>> entry : schemaInfo.entrySet()) {
|
||||
for (DataTableInfo tableInfo : entry.getValue()) {
|
||||
tableInfo.setDbId(dbConfig.getId());
|
||||
List<DataTableField> dataTableFields = getFieldsByTable(conn, entry.getKey(), tableInfo.getDataName());
|
||||
dataTableFields.stream().forEach(tableField -> tableField.setTableId(tableInfo.getTableId()));
|
||||
tableTrees.add(new TableTree(tableInfo, dataTableFields));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return tableTrees;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.jeesite.modules.app.utils;
|
||||
|
||||
|
||||
import com.jeesite.modules.app.dao.DataTableField;
|
||||
import com.jeesite.modules.app.dao.DataTableInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SqlUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 生成CREATE TABLE语句
|
||||
*
|
||||
* @param tableInfo 数据表基础信息
|
||||
* @param fieldList 字段列表
|
||||
* @return CREATE TABLE语句
|
||||
*/
|
||||
public static String CreateTableSql(DataTableInfo tableInfo, List<DataTableField> fieldList) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 表定义开始
|
||||
sb.append("CREATE TABLE ").append(tableInfo.getDataName()).append(" (\n");
|
||||
// 拼接字段定义
|
||||
for (int i = 0; i < fieldList.size(); i++) {
|
||||
DataTableField field = fieldList.get(i);
|
||||
sb.append(" ").append(field.getFieldName()).append(" ");
|
||||
// 处理字段类型和长度
|
||||
if (field.getFieldLength() != null && field.getFieldLength() > 0) {
|
||||
sb.append(field.getFieldType()).append("(").append(field.getFieldLength()).append(") ");
|
||||
} else {
|
||||
sb.append(field.getFieldType()).append(" ");
|
||||
}
|
||||
// 处理主键(简单判断:fieldId为主键字段)
|
||||
if ("field_id".equals(field.getFieldName()) || "table_id".equals(field.getFieldName())) {
|
||||
sb.append("NOT NULL AUTO_INCREMENT ");
|
||||
} else {
|
||||
sb.append("DEFAULT NULL ");
|
||||
}
|
||||
|
||||
// 字段注释
|
||||
if (field.getFieldRemark() != null && !field.getFieldRemark().isEmpty()) {
|
||||
sb.append("COMMENT '").append(field.getFieldRemark()).append("'");
|
||||
}
|
||||
|
||||
// 最后一个字段不加逗号
|
||||
if (i != fieldList.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("\n");
|
||||
}
|
||||
// 表引擎和字符集
|
||||
sb.append(") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ");
|
||||
// 表注释
|
||||
if (tableInfo.getTableComment() != null && !tableInfo.getTableComment().isEmpty()) {
|
||||
sb.append("COMMENT\t'").append(tableInfo.getTableComment()).append("'");
|
||||
}
|
||||
sb.append(";");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成带注释的SELECT语句
|
||||
*
|
||||
* @param tableInfo 数据表基础信息
|
||||
* @param fieldList 字段列表
|
||||
* @return 带注释的SELECT语句
|
||||
*/
|
||||
public static String SelectSqlComments(DataTableInfo tableInfo, List<DataTableField> fieldList) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 表注释
|
||||
sb.append("-- 表名:").append(tableInfo.getDataName()).append("\n");
|
||||
sb.append("-- 描述:").append(tableInfo.getTableComment() != null ? tableInfo.getTableComment() : "无").append("\n");
|
||||
sb.append("-- 数据来源:").append(tableInfo.getDataSource() != null ? tableInfo.getDataSource() : "未知").append("\n");
|
||||
// SELECT语句开始
|
||||
sb.append("SELECT\n");
|
||||
// 拼接字段(带注释)
|
||||
for (int i = 0; i < fieldList.size(); i++) {
|
||||
DataTableField field = fieldList.get(i);
|
||||
// 拼接字段名
|
||||
sb.append(" ").append(field.getFieldName());
|
||||
// 非最后一个字段加逗号(先处理逗号)
|
||||
if (i != fieldList.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
// 处理字段注释(后加注释)
|
||||
if (field.getFieldRemark() != null && !field.getFieldRemark().isEmpty()) {
|
||||
sb.append(" -- ").append(field.getFieldRemark());
|
||||
}
|
||||
// 换行
|
||||
sb.append("\n");
|
||||
}
|
||||
// 表名
|
||||
sb.append("FROM ").append(tableInfo.getDataName()).append("\n;");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
114
web-api/src/main/java/com/jeesite/modules/app/utils/vDate.java
Normal file
114
web-api/src/main/java/com/jeesite/modules/app/utils/vDate.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.jeesite.modules.app.utils;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class vDate {
|
||||
|
||||
|
||||
private static final DateTimeFormatter DEFAULT_FMT =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private static final SimpleDateFormat DEFAULT_SDF =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.ENGLISH);
|
||||
|
||||
|
||||
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE; // yyyy-MM-dd
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM"); // yyyy-MM
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
public static String toStr(LocalDateTime dateTime) {
|
||||
return dateTime.format(DEFAULT_FMT);
|
||||
}
|
||||
|
||||
/**
|
||||
* LocalDateTime → String(自定义格式)
|
||||
*/
|
||||
public static String toStr(LocalDateTime dateTime, String pattern) {
|
||||
return dateTime.format(DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
|
||||
public static String getNow() {
|
||||
Date date = new Date();
|
||||
return DEFAULT_SDF.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取更新时间
|
||||
*/
|
||||
public static Date getUpdateTime(boolean isNew) {
|
||||
if (isNew) {
|
||||
return null;
|
||||
}
|
||||
return new Date();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static String dsValue() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// 格式化日期为yyyymmdd
|
||||
return currentDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
|
||||
public static String dsValueDaysAgo(long days) {
|
||||
LocalDate targetDate = LocalDate.now().minusDays(days);
|
||||
return targetDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getDockerCreate(String createAt) {
|
||||
try {
|
||||
String cleaned = createAt.replace(" CST", "");
|
||||
// 定义格式
|
||||
Date date = sdf.parse(cleaned);
|
||||
return DEFAULT_SDF.format(date);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return getNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getRunTimes(long totalSeconds) {
|
||||
if (totalSeconds < 0) {
|
||||
throw new IllegalArgumentException("输入的秒数不能为负数");
|
||||
}
|
||||
// 定义时间单位换算关系
|
||||
long secondsPerMinute = 60;
|
||||
long secondsPerHour = secondsPerMinute * 60; // 3600秒/小时
|
||||
long secondsPerDay = secondsPerHour * 24; // 86400秒/天
|
||||
|
||||
// 计算各单位数值
|
||||
long days = totalSeconds / secondsPerDay;
|
||||
long remainingSecondsAfterDays = totalSeconds % secondsPerDay;
|
||||
|
||||
long hours = remainingSecondsAfterDays / secondsPerHour;
|
||||
long remainingSecondsAfterHours = remainingSecondsAfterDays % secondsPerHour;
|
||||
|
||||
long minutes = remainingSecondsAfterHours / secondsPerMinute;
|
||||
long seconds = remainingSecondsAfterHours % secondsPerMinute;
|
||||
// 拼接结果字符串
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (days > 0) {
|
||||
result.append(days).append("天");
|
||||
}
|
||||
if (hours > 0) {
|
||||
result.append(hours).append("小时");
|
||||
}
|
||||
if (minutes > 0) {
|
||||
result.append(minutes).append("分");
|
||||
}
|
||||
// 确保至少显示秒数(即使其他单位都为0)
|
||||
result.append(seconds).append("秒");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
35
web-api/src/main/java/com/jeesite/modules/app/utils/vId.java
Normal file
35
web-api/src/main/java/com/jeesite/modules/app/utils/vId.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.jeesite.modules.app.utils;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class vId {
|
||||
|
||||
private static final SecureRandom RAND = new SecureRandom();
|
||||
private static final DateTimeFormatter DF = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
|
||||
|
||||
private vId() {}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 时间戳唯一编号
|
||||
*/
|
||||
public static String getUid() {
|
||||
// 17 位时间
|
||||
String tm = LocalDateTime.now().format(DF);
|
||||
// 25 位随机数字(高位补零)
|
||||
long rand = Math.abs(RAND.nextLong()) % (long) Math.pow(10, 15);
|
||||
return tm + String.format("%015d", rand);
|
||||
}
|
||||
|
||||
|
||||
public static String getCid() {
|
||||
// 17 位时间
|
||||
String tm = LocalDateTime.now().format(DF);
|
||||
// 25 位随机数字(高位补零)
|
||||
long rand = Math.abs(RAND.nextLong()) % (long) Math.pow(3, 6);
|
||||
return tm + String.format("%04d", rand);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.jeesite.modules.app.utils;
|
||||
|
||||
import com.jeesite.common.codec.AesUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class vo {
|
||||
|
||||
@@ -39,16 +38,4 @@ public class vo {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取更新时间
|
||||
*/
|
||||
public static Date getUpdateTime(boolean isNew) {
|
||||
if (isNew) {
|
||||
return null;
|
||||
}
|
||||
return new Date();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jeesite.modules.biz.dao;
|
||||
|
||||
import com.jeesite.common.dao.CrudDao;
|
||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||
import com.jeesite.modules.biz.entity.BizDbConfig;
|
||||
|
||||
/**
|
||||
* 连接信息DAO接口
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@MyBatisDao(dataSourceName="work")
|
||||
public interface BizDbConfigDao extends CrudDao<BizDbConfig> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jeesite.modules.biz.dao;
|
||||
|
||||
import com.jeesite.common.dao.CrudDao;
|
||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||
import com.jeesite.modules.biz.entity.BizTableInfo;
|
||||
|
||||
/**
|
||||
* 数据信息DAO接口
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@MyBatisDao(dataSourceName="work")
|
||||
public interface BizTableInfoDao extends CrudDao<BizTableInfo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.jeesite.modules.biz.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 连接信息Entity
|
||||
*
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = "biz_db_config", alias = "a", label = "连接信息信息", columns = {
|
||||
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdate = false, isUpdateForce = true),
|
||||
@Column(name = "id", attrName = "id", label = "主键ID", isPK = true),
|
||||
@Column(name = "db_type", attrName = "dbType", label = "数据库类型"),
|
||||
@Column(name = "db_name", attrName = "dbName", label = "数据库名称", queryType = QueryType.LIKE),
|
||||
@Column(name = "db_ip", attrName = "dbIp", label = "数据库IP"),
|
||||
@Column(name = "db_port", attrName = "dbPort", label = "数据库端口", isQuery = false),
|
||||
@Column(name = "db_username", attrName = "dbUsername", label = "数据库账号", isQuery = false),
|
||||
@Column(name = "db_password", attrName = "dbPassword", label = "数据库密码", isQuery = false),
|
||||
@Column(name = "description", attrName = "description", label = "数据库描述", queryType = QueryType.LIKE),
|
||||
@Column(name = "is_enabled", attrName = "isEnabled", label = "是否启用"),
|
||||
@Column(name = "db_schema_name", attrName = "dbSchemaName", label = "schema名称", isQuery = false),
|
||||
@Column(name = "update_time", attrName = "updateTime", label = "更新时间", isQuery = false, isUpdateForce = true),
|
||||
@Column(name = "f_tenant_id", attrName = "ftenantId", label = "租户id", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_id", attrName = "fflowId", label = "流程id", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_task_id", attrName = "fflowTaskId", label = "流程任务主键", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_state", attrName = "fflowState", label = "流程任务状态", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||
}, orderBy = "a.id DESC"
|
||||
)
|
||||
@Data
|
||||
public class BizDbConfig extends DataEntity<BizDbConfig> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Date createTime; // 创建时间
|
||||
private String dbType; // 数据库类型
|
||||
private String dbName; // 数据库名称
|
||||
private String dbIp; // 数据库IP
|
||||
private Integer dbPort; // 数据库端口
|
||||
private String dbUsername; // 数据库账号
|
||||
private String dbPassword; // 数据库密码
|
||||
private String description; // 数据库描述
|
||||
private String isEnabled; // 是否启用
|
||||
private String dbSchemaName; // schema名称
|
||||
private Date updateTime; // 更新时间
|
||||
private String ftenantId; // 租户id
|
||||
private String fflowId; // 流程id
|
||||
private String fflowTaskId; // 流程任务主键
|
||||
private Integer fflowState; // 流程任务状态
|
||||
|
||||
@ExcelFields({
|
||||
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
|
||||
@ExcelField(title = "主键ID", attrName = "id", align = Align.CENTER, sort = 20),
|
||||
@ExcelField(title = "数据库类型", attrName = "dbType", align = Align.CENTER, sort = 30),
|
||||
@ExcelField(title = "数据库名称", attrName = "dbName", align = Align.CENTER, sort = 40),
|
||||
@ExcelField(title = "数据库IP", attrName = "dbIp", align = Align.CENTER, sort = 50),
|
||||
@ExcelField(title = "数据库端口", attrName = "dbPort", align = Align.CENTER, sort = 60),
|
||||
@ExcelField(title = "数据库账号", attrName = "dbUsername", align = Align.CENTER, sort = 70),
|
||||
@ExcelField(title = "数据库密码", attrName = "dbPassword", align = Align.CENTER, sort = 80),
|
||||
@ExcelField(title = "数据库描述", attrName = "description", align = Align.CENTER, sort = 90),
|
||||
@ExcelField(title = "是否启用", attrName = "isEnabled", dictType = "is_active", align = Align.CENTER, sort = 100),
|
||||
@ExcelField(title = "schema名称", attrName = "dbSchemaName", align = Align.CENTER, sort = 110),
|
||||
@ExcelField(title = "更新时间", attrName = "updateTime", align = Align.CENTER, sort = 120, dataFormat = "yyyy-MM-dd hh:mm"),
|
||||
})
|
||||
public BizDbConfig() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public BizDbConfig(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public Date getCreateTime_gte() {
|
||||
return sqlMap.getWhere().getValue("create_time", QueryType.GTE);
|
||||
}
|
||||
|
||||
public void setCreateTime_gte(Date createTime) {
|
||||
sqlMap.getWhere().and("create_time", QueryType.GTE, createTime);
|
||||
}
|
||||
|
||||
public Date getCreateTime_lte() {
|
||||
return sqlMap.getWhere().getValue("create_time", QueryType.LTE);
|
||||
}
|
||||
|
||||
public void setCreateTime_lte(Date createTime) {
|
||||
sqlMap.getWhere().and("create_time", QueryType.LTE, createTime);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.jeesite.modules.biz.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 数据信息Entity
|
||||
*
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@Table(name = "biz_table_info", alias = "a", label = "数据信息信息", columns = {
|
||||
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdate = false, isUpdateForce = true),
|
||||
@Column(name = "table_id", attrName = "tableId", label = "唯一标识", isPK = true),
|
||||
@Column(name = "data_name", attrName = "dataName", label = "数据表名称", queryType = QueryType.LIKE),
|
||||
@Column(name = "table_comment", attrName = "tableComment", label = "数据表描述", queryType = QueryType.LIKE),
|
||||
@Column(name = "table_size", attrName = "tableSize", label = "数据表大小", isQuery = false, isUpdateForce = true),
|
||||
@Column(name = "data_source", attrName = "dataSource", label = "数据来源"),
|
||||
@Column(name = "creator", attrName = "creator", label = "创建人员", isQuery = false),
|
||||
@Column(name = "data_rows", attrName = "dataRows", label = "记录条数", isQuery = false, isUpdateForce = true),
|
||||
@Column(name = "update_time", attrName = "updateTime", label = "更新时间", isQuery = false, isUpdateForce = true),
|
||||
@Column(name = "remarks", attrName = "remarks", label = "备注信息", queryType = QueryType.LIKE),
|
||||
@Column(name = "db_id", attrName = "dbId", label = "数据标识"),
|
||||
@Column(name = "ds", attrName = "ds", label = "分区日期"),
|
||||
@Column(name = "f_tenant_id", attrName = "ftenantId", label = "租户id", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_id", attrName = "fflowId", label = "流程id", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_task_id", attrName = "fflowTaskId", label = "流程任务主键", isUpdate = false, isQuery = false),
|
||||
@Column(name = "f_flow_state", attrName = "fflowState", label = "流程任务状态", isUpdate = false, isQuery = false, isUpdateForce = true),
|
||||
}, joinTable = {
|
||||
@JoinTable(type = Type.LEFT_JOIN, entity = BizDbConfig.class, attrName = "this", alias = "b",
|
||||
on = "a.db_id = b.id",
|
||||
columns = {
|
||||
@Column(name = "db_type", attrName = "dbType", label = "数据库类型"),
|
||||
@Column(name = "db_name", attrName = "dbName", label = "数据库名称"),
|
||||
@Column(name = "db_ip", attrName = "dbIp", label = "数据库IP"),
|
||||
}),
|
||||
}, orderBy = "a.create_time DESC"
|
||||
)
|
||||
@Data
|
||||
public class BizTableInfo extends DataEntity<BizTableInfo> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Date createTime; // 创建时间
|
||||
private String tableId; // 唯一标识
|
||||
private String dataName; // 数据表名称
|
||||
private String tableComment; // 数据表描述
|
||||
private Double tableSize; // 数据表大小
|
||||
private String dataSource; // 数据来源
|
||||
private String creator; // 创建人员
|
||||
private Long dataRows; // 记录条数
|
||||
private Date updateTime; // 更新时间
|
||||
private String dbId; // 数据标识
|
||||
private String ds; // 分区日期
|
||||
private String ftenantId; // 租户id
|
||||
private String fflowId; // 流程id
|
||||
private String fflowTaskId; // 流程任务主键
|
||||
private Integer fflowState; // 流程任务状态
|
||||
|
||||
private String dbType;
|
||||
private String dbName;
|
||||
private String dbIp;
|
||||
|
||||
@ExcelFields({
|
||||
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
|
||||
@ExcelField(title = "唯一标识", attrName = "tableId", align = Align.CENTER, sort = 20),
|
||||
@ExcelField(title = "数据表名称", attrName = "dataName", align = Align.CENTER, sort = 30),
|
||||
@ExcelField(title = "数据表描述", attrName = "tableComment", align = Align.CENTER, sort = 40),
|
||||
@ExcelField(title = "数据表大小", attrName = "tableSize", align = Align.CENTER, sort = 50),
|
||||
@ExcelField(title = "数据来源", attrName = "dataSource", align = Align.CENTER, sort = 60),
|
||||
@ExcelField(title = "创建人员", attrName = "creator", align = Align.CENTER, sort = 70),
|
||||
@ExcelField(title = "记录条数", attrName = "dataRows", align = Align.CENTER, sort = 80),
|
||||
@ExcelField(title = "更新时间", attrName = "updateTime", align = Align.CENTER, sort = 90, dataFormat = "yyyy-MM-dd hh:mm"),
|
||||
@ExcelField(title = "备注信息", attrName = "remarks", align = Align.CENTER, sort = 100),
|
||||
@ExcelField(title = "数据库名称", attrName = "dbName", align = Align.CENTER, sort = 110),
|
||||
@ExcelField(title = "分区日期", attrName = "ds", align = Align.CENTER, sort = 120),
|
||||
})
|
||||
public BizTableInfo() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public BizTableInfo(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public Date getCreateTime_gte() {
|
||||
return sqlMap.getWhere().getValue("create_time", QueryType.GTE);
|
||||
}
|
||||
|
||||
public void setCreateTime_gte(Date createTime) {
|
||||
sqlMap.getWhere().and("create_time", QueryType.GTE, createTime);
|
||||
}
|
||||
|
||||
public Date getCreateTime_lte() {
|
||||
return sqlMap.getWhere().getValue("create_time", QueryType.LTE);
|
||||
}
|
||||
|
||||
public void setCreateTime_lte(Date createTime) {
|
||||
sqlMap.getWhere().and("create_time", QueryType.LTE, createTime);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.jeesite.modules.biz.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.biz.entity.BizDbConfig;
|
||||
import com.jeesite.modules.biz.dao.BizDbConfigDao;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.validator.ValidatorUtils;
|
||||
import com.jeesite.common.utils.excel.ExcelImport;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 连接信息Service
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@Service
|
||||
public class BizDbConfigService extends CrudService<BizDbConfigDao, BizDbConfig> {
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param bizDbConfig 主键
|
||||
*/
|
||||
@Override
|
||||
public BizDbConfig get(BizDbConfig bizDbConfig) {
|
||||
return super.get(bizDbConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param bizDbConfig 查询条件
|
||||
* @param bizDbConfig page 分页对象
|
||||
*/
|
||||
@Override
|
||||
public Page<BizDbConfig> findPage(BizDbConfig bizDbConfig) {
|
||||
return super.findPage(bizDbConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
* @param bizDbConfig 查询条件
|
||||
*/
|
||||
@Override
|
||||
public List<BizDbConfig> findList(BizDbConfig bizDbConfig) {
|
||||
return super.findList(bizDbConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据(插入或更新)
|
||||
* @param bizDbConfig 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(BizDbConfig bizDbConfig) {
|
||||
super.save(bizDbConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param file 导入的数据文件
|
||||
*/
|
||||
@Transactional
|
||||
public String importData(MultipartFile file) {
|
||||
if (file == null){
|
||||
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||
}
|
||||
int successNum = 0; int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||
List<BizDbConfig> list = ei.getDataList(BizDbConfig.class);
|
||||
for (BizDbConfig bizDbConfig : list) {
|
||||
try{
|
||||
ValidatorUtils.validateWithException(bizDbConfig);
|
||||
this.save(bizDbConfig);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、编号 " + bizDbConfig.getId() + " 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、编号 " + bizDbConfig.getId() + " 导入失败:";
|
||||
if (e instanceof ConstraintViolationException){
|
||||
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||
}
|
||||
}else{
|
||||
msg += e.getMessage();
|
||||
}
|
||||
failureMsg.append(msg);
|
||||
logger.error(msg, e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
failureMsg.append(e.getMessage());
|
||||
return failureMsg.toString();
|
||||
}
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}else{
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态
|
||||
* @param bizDbConfig 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateStatus(BizDbConfig bizDbConfig) {
|
||||
super.updateStatus(bizDbConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param bizDbConfig 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(BizDbConfig bizDbConfig) {
|
||||
super.delete(bizDbConfig);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.jeesite.modules.biz.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.biz.entity.BizTableInfo;
|
||||
import com.jeesite.modules.biz.dao.BizTableInfoDao;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.validator.ValidatorUtils;
|
||||
import com.jeesite.common.utils.excel.ExcelImport;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 数据信息Service
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@Service
|
||||
public class BizTableInfoService extends CrudService<BizTableInfoDao, BizTableInfo> {
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param bizTableInfo 主键
|
||||
*/
|
||||
@Override
|
||||
public BizTableInfo get(BizTableInfo bizTableInfo) {
|
||||
return super.get(bizTableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param bizTableInfo 查询条件
|
||||
* @param bizTableInfo page 分页对象
|
||||
*/
|
||||
@Override
|
||||
public Page<BizTableInfo> findPage(BizTableInfo bizTableInfo) {
|
||||
return super.findPage(bizTableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
* @param bizTableInfo 查询条件
|
||||
*/
|
||||
@Override
|
||||
public List<BizTableInfo> findList(BizTableInfo bizTableInfo) {
|
||||
return super.findList(bizTableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据(插入或更新)
|
||||
* @param bizTableInfo 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(BizTableInfo bizTableInfo) {
|
||||
super.save(bizTableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
* @param file 导入的数据文件
|
||||
*/
|
||||
@Transactional
|
||||
public String importData(MultipartFile file) {
|
||||
if (file == null){
|
||||
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||
}
|
||||
int successNum = 0; int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||
List<BizTableInfo> list = ei.getDataList(BizTableInfo.class);
|
||||
for (BizTableInfo bizTableInfo : list) {
|
||||
try{
|
||||
ValidatorUtils.validateWithException(bizTableInfo);
|
||||
this.save(bizTableInfo);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、编号 " + bizTableInfo.getId() + " 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、编号 " + bizTableInfo.getId() + " 导入失败:";
|
||||
if (e instanceof ConstraintViolationException){
|
||||
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||
}
|
||||
}else{
|
||||
msg += e.getMessage();
|
||||
}
|
||||
failureMsg.append(msg);
|
||||
logger.error(msg, e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
failureMsg.append(e.getMessage());
|
||||
return failureMsg.toString();
|
||||
}
|
||||
if (failureNum > 0) {
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}else{
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态
|
||||
* @param bizTableInfo 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateStatus(BizTableInfo bizTableInfo) {
|
||||
super.updateStatus(bizTableInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param bizTableInfo 数据对象
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(BizTableInfo bizTableInfo) {
|
||||
super.delete(bizTableInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.jeesite.modules.biz.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jeesite.modules.app.utils.vDate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.utils.excel.ExcelExport;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.biz.entity.BizDbConfig;
|
||||
import com.jeesite.modules.biz.service.BizDbConfigService;
|
||||
|
||||
/**
|
||||
* 连接信息Controller
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/biz/dbConfig")
|
||||
public class BizDbConfigController extends BaseController {
|
||||
|
||||
private final BizDbConfigService bizDbConfigService;
|
||||
|
||||
public BizDbConfigController(BizDbConfigService bizDbConfigService) {
|
||||
this.bizDbConfigService = bizDbConfigService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
*/
|
||||
@ModelAttribute
|
||||
public BizDbConfig get(String id, boolean isNewRecord) {
|
||||
return bizDbConfigService.get(id, isNewRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:view")
|
||||
@RequestMapping(value = {"list", ""})
|
||||
public String list(BizDbConfig bizDbConfig, Model model) {
|
||||
model.addAttribute("bizDbConfig", bizDbConfig);
|
||||
return "modules/biz/bizDbConfigList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:view")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<BizDbConfig> listData(BizDbConfig bizDbConfig, HttpServletRequest request, HttpServletResponse response) {
|
||||
bizDbConfig.setPage(new Page<>(request, response));
|
||||
Page<BizDbConfig> page = bizDbConfigService.findPage(bizDbConfig);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看编辑表单
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:view")
|
||||
@RequestMapping(value = "form")
|
||||
public String form(BizDbConfig bizDbConfig, Model model) {
|
||||
model.addAttribute("bizDbConfig", bizDbConfig);
|
||||
return "modules/biz/bizDbConfigForm";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:edit")
|
||||
@PostMapping(value = "save")
|
||||
@ResponseBody
|
||||
public String save(@Validated BizDbConfig bizDbConfig) {
|
||||
bizDbConfig.setUpdateTime(vDate.getUpdateTime(bizDbConfig.getIsNewRecord()));
|
||||
bizDbConfigService.save(bizDbConfig);
|
||||
return renderResult(Global.TRUE, text("保存连接信息成功!"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:view")
|
||||
@RequestMapping(value = "exportData")
|
||||
public void exportData(BizDbConfig bizDbConfig, HttpServletResponse response) {
|
||||
List<BizDbConfig> list = bizDbConfigService.findList(bizDbConfig);
|
||||
String fileName = "连接信息" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||
try(ExcelExport ee = new ExcelExport("连接信息", BizDbConfig.class)){
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载模板
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:view")
|
||||
@RequestMapping(value = "importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
BizDbConfig bizDbConfig = new BizDbConfig();
|
||||
List<BizDbConfig> list = ListUtils.newArrayList(bizDbConfig);
|
||||
String fileName = "连接信息模板.xlsx";
|
||||
try(ExcelExport ee = new ExcelExport("连接信息", BizDbConfig.class, Type.IMPORT)){
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequiresPermissions("biz:dbConfig:edit")
|
||||
@PostMapping(value = "importData")
|
||||
public String importData(MultipartFile file) {
|
||||
try {
|
||||
String message = bizDbConfigService.importData(file);
|
||||
return renderResult(Global.TRUE, "posfull:"+message);
|
||||
} catch (Exception ex) {
|
||||
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*/
|
||||
@RequiresPermissions("biz:dbConfig:edit")
|
||||
@RequestMapping(value = "delete")
|
||||
@ResponseBody
|
||||
public String delete(BizDbConfig bizDbConfig) {
|
||||
bizDbConfigService.delete(bizDbConfig);
|
||||
return renderResult(Global.TRUE, text("删除连接信息成功!"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.jeesite.modules.biz.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jeesite.modules.app.utils.vo;
|
||||
import com.jeesite.modules.app.utils.vDate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class BizMonitorHostController extends BaseController {
|
||||
@PostMapping(value = "save")
|
||||
@ResponseBody
|
||||
public String save(@Validated BizMonitorHost bizMonitorHost) {
|
||||
bizMonitorHost.setUpdateTime(vo.getUpdateTime(bizMonitorHost.getIsNewRecord()));
|
||||
bizMonitorHost.setUpdateTime(vDate.getUpdateTime(bizMonitorHost.getIsNewRecord()));
|
||||
bizMonitorHostService.save(bizMonitorHost);
|
||||
return renderResult(Global.TRUE, text("保存主机信息成功!"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.jeesite.modules.biz.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jeesite.modules.app.utils.vDate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.utils.excel.ExcelExport;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.biz.entity.BizTableInfo;
|
||||
import com.jeesite.modules.biz.service.BizTableInfoService;
|
||||
|
||||
/**
|
||||
* 数据信息Controller
|
||||
*
|
||||
* @author gaoxq
|
||||
* @version 2025-12-01
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/biz/tableInfo")
|
||||
public class BizTableInfoController extends BaseController {
|
||||
|
||||
private final BizTableInfoService bizTableInfoService;
|
||||
|
||||
public BizTableInfoController(BizTableInfoService bizTableInfoService) {
|
||||
this.bizTableInfoService = bizTableInfoService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
*/
|
||||
@ModelAttribute
|
||||
public BizTableInfo get(String tableId, boolean isNewRecord) {
|
||||
return bizTableInfoService.get(tableId, isNewRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:view")
|
||||
@RequestMapping(value = {"list", ""})
|
||||
public String list(BizTableInfo bizTableInfo, Model model) {
|
||||
model.addAttribute("bizTableInfo", bizTableInfo);
|
||||
return "modules/biz/bizTableInfoList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:view")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<BizTableInfo> listData(BizTableInfo bizTableInfo, HttpServletRequest request, HttpServletResponse response) {
|
||||
bizTableInfo.setDs(vDate.dsValue());
|
||||
bizTableInfo.setPage(new Page<>(request, response));
|
||||
Page<BizTableInfo> page = bizTableInfoService.findPage(bizTableInfo);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看编辑表单
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:view")
|
||||
@RequestMapping(value = "form")
|
||||
public String form(BizTableInfo bizTableInfo, Model model) {
|
||||
model.addAttribute("bizTableInfo", bizTableInfo);
|
||||
return "modules/biz/bizTableInfoForm";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:edit")
|
||||
@PostMapping(value = "save")
|
||||
@ResponseBody
|
||||
public String save(@Validated BizTableInfo bizTableInfo) {
|
||||
bizTableInfoService.save(bizTableInfo);
|
||||
return renderResult(Global.TRUE, text("保存数据信息成功!"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:view")
|
||||
@RequestMapping(value = "exportData")
|
||||
public void exportData(BizTableInfo bizTableInfo, HttpServletResponse response) {
|
||||
List<BizTableInfo> list = bizTableInfoService.findList(bizTableInfo);
|
||||
String fileName = "数据信息" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||
try (ExcelExport ee = new ExcelExport("数据信息", BizTableInfo.class)) {
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载模板
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:view")
|
||||
@RequestMapping(value = "importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
BizTableInfo bizTableInfo = new BizTableInfo();
|
||||
List<BizTableInfo> list = ListUtils.newArrayList(bizTableInfo);
|
||||
String fileName = "数据信息模板.xlsx";
|
||||
try (ExcelExport ee = new ExcelExport("数据信息", BizTableInfo.class, Type.IMPORT)) {
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequiresPermissions("biz:tableInfo:edit")
|
||||
@PostMapping(value = "importData")
|
||||
public String importData(MultipartFile file) {
|
||||
try {
|
||||
String message = bizTableInfoService.importData(file);
|
||||
return renderResult(Global.TRUE, "posfull:" + message);
|
||||
} catch (Exception ex) {
|
||||
return renderResult(Global.FALSE, "posfull:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*/
|
||||
@RequiresPermissions("biz:tableInfo:edit")
|
||||
@RequestMapping(value = "delete")
|
||||
@ResponseBody
|
||||
public String delete(BizTableInfo bizTableInfo) {
|
||||
bizTableInfoService.delete(bizTableInfo);
|
||||
return renderResult(Global.TRUE, text("删除数据信息成功!"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jeesite.modules.biz.dao.BizDbConfigDao">
|
||||
|
||||
<!-- 查询数据
|
||||
<select id="findList" resultType="BizDbConfig">
|
||||
SELECT ${sqlMap.column.toSql()}
|
||||
FROM ${sqlMap.table.toSql()}
|
||||
<where>
|
||||
${sqlMap.where.toSql()}
|
||||
</where>
|
||||
ORDER BY ${sqlMap.order.toSql()}
|
||||
</select> -->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jeesite.modules.biz.dao.BizTableInfoDao">
|
||||
|
||||
<!-- 查询数据
|
||||
<select id="findList" resultType="BizTableInfo">
|
||||
SELECT ${sqlMap.column.toSql()}
|
||||
FROM ${sqlMap.table.toSql()}
|
||||
<where>
|
||||
${sqlMap.where.toSql()}
|
||||
</where>
|
||||
ORDER BY ${sqlMap.order.toSql()}
|
||||
</select> -->
|
||||
|
||||
</mapper>
|
||||
58
web-vue/packages/biz/api/biz/dbConfig.ts
Normal file
58
web-vue/packages/biz/api/biz/dbConfig.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
*/
|
||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
||||
import { UploadFileParams } from '@jeesite/types/axios';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const { ctxPath, adminPath } = useGlobSetting();
|
||||
|
||||
export interface BizDbConfig extends BasicModel<BizDbConfig> {
|
||||
createTime?: string; // 创建时间
|
||||
dbType: string; // 数据库类型
|
||||
dbName: string; // 数据库名称
|
||||
dbIp: string; // 数据库IP
|
||||
dbPort: number; // 数据库端口
|
||||
dbUsername: string; // 数据库账号
|
||||
dbPassword: string; // 数据库密码
|
||||
description?: string; // 数据库描述
|
||||
isEnabled: number; // 是否启用
|
||||
dbSchemaName?: string; // schema名称
|
||||
updateTime?: string; // 更新时间
|
||||
ftenantId?: string; // 租户id
|
||||
fflowId?: string; // 流程id
|
||||
fflowTaskId?: string; // 流程任务主键
|
||||
fflowState?: number; // 流程任务状态
|
||||
}
|
||||
|
||||
export const bizDbConfigList = (params?: BizDbConfig | any) =>
|
||||
defHttp.get<BizDbConfig>({ url: adminPath + '/biz/dbConfig/list', params });
|
||||
|
||||
export const bizDbConfigListData = (params?: BizDbConfig | any) =>
|
||||
defHttp.post<Page<BizDbConfig>>({ url: adminPath + '/biz/dbConfig/listData', params });
|
||||
|
||||
export const bizDbConfigForm = (params?: BizDbConfig | any) =>
|
||||
defHttp.get<BizDbConfig>({ url: adminPath + '/biz/dbConfig/form', params });
|
||||
|
||||
export const bizDbConfigSave = (params?: any, data?: BizDbConfig | any) =>
|
||||
defHttp.postJson<BizDbConfig>({ url: adminPath + '/biz/dbConfig/save', params, data });
|
||||
|
||||
export const bizDbConfigImportData = (
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
||||
) =>
|
||||
defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: ctxPath + adminPath + '/biz/dbConfig/importData',
|
||||
onUploadProgress,
|
||||
},
|
||||
params,
|
||||
);
|
||||
|
||||
export const bizDbConfigDelete = (params?: BizDbConfig | any) =>
|
||||
defHttp.get<BizDbConfig>({ url: adminPath + '/biz/dbConfig/delete', params });
|
||||
58
web-vue/packages/biz/api/biz/tableInfo.ts
Normal file
58
web-vue/packages/biz/api/biz/tableInfo.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
*/
|
||||
import { defHttp } from '@jeesite/core/utils/http/axios';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
|
||||
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
|
||||
import { UploadFileParams } from '@jeesite/types/axios';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const { ctxPath, adminPath } = useGlobSetting();
|
||||
|
||||
export interface BizTableInfo extends BasicModel<BizTableInfo> {
|
||||
createTime?: string; // 创建时间
|
||||
tableId?: string; // 唯一标识
|
||||
dataName: string; // 数据表名称
|
||||
tableComment: string; // 数据表描述
|
||||
tableSize?: number; // 数据表大小
|
||||
dataSource?: string; // 数据来源
|
||||
creator?: string; // 创建人员
|
||||
dataRows?: number; // 记录条数
|
||||
updateTime?: string; // 更新时间
|
||||
dbId?: string; // 数据标识
|
||||
ds?: string; // 分区日期
|
||||
ftenantId?: string; // 租户id
|
||||
fflowId?: string; // 流程id
|
||||
fflowTaskId?: string; // 流程任务主键
|
||||
fflowState?: number; // 流程任务状态
|
||||
}
|
||||
|
||||
export const bizTableInfoList = (params?: BizTableInfo | any) =>
|
||||
defHttp.get<BizTableInfo>({ url: adminPath + '/biz/tableInfo/list', params });
|
||||
|
||||
export const bizTableInfoListData = (params?: BizTableInfo | any) =>
|
||||
defHttp.post<Page<BizTableInfo>>({ url: adminPath + '/biz/tableInfo/listData', params });
|
||||
|
||||
export const bizTableInfoForm = (params?: BizTableInfo | any) =>
|
||||
defHttp.get<BizTableInfo>({ url: adminPath + '/biz/tableInfo/form', params });
|
||||
|
||||
export const bizTableInfoSave = (params?: any, data?: BizTableInfo | any) =>
|
||||
defHttp.postJson<BizTableInfo>({ url: adminPath + '/biz/tableInfo/save', params, data });
|
||||
|
||||
export const bizTableInfoImportData = (
|
||||
params: UploadFileParams,
|
||||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
|
||||
) =>
|
||||
defHttp.uploadFile<UploadApiResult>(
|
||||
{
|
||||
url: ctxPath + adminPath + '/biz/tableInfo/importData',
|
||||
onUploadProgress,
|
||||
},
|
||||
params,
|
||||
);
|
||||
|
||||
export const bizTableInfoDelete = (params?: BizTableInfo | any) =>
|
||||
defHttp.get<BizTableInfo>({ url: adminPath + '/biz/tableInfo/delete', params });
|
||||
164
web-vue/packages/biz/views/biz/dbConfig/form.vue
Normal file
164
web-vue/packages/biz/views/biz/dbConfig/form.vue
Normal file
@@ -0,0 +1,164 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<BasicDrawer
|
||||
v-bind="$attrs"
|
||||
:showFooter="true"
|
||||
:okAuth="'biz:dbConfig:edit'"
|
||||
@register="registerDrawer"
|
||||
@ok="handleSubmit"
|
||||
width="70%"
|
||||
>
|
||||
<template #title>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicDrawer>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsBizDbConfigForm">
|
||||
import { ref, unref, computed } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicForm, FormSchema, useForm } from '@jeesite/core/components/Form';
|
||||
import { BasicDrawer, useDrawerInner } from '@jeesite/core/components/Drawer';
|
||||
import { BizDbConfig, bizDbConfigSave, bizDbConfigForm } from '@jeesite/biz/api/biz/dbConfig';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const { t } = useI18n('biz.dbConfig');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<BizDbConfig>({} as BizDbConfig);
|
||||
|
||||
const getTitle = computed(() => ({
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: record.value.isNewRecord ? t('新增连接信息') : t('编辑连接信息'),
|
||||
}));
|
||||
|
||||
const inputFormSchemas: FormSchema<BizDbConfig>[] = [
|
||||
{
|
||||
label: t('数据库名称'),
|
||||
field: 'dbName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 128,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库类型'),
|
||||
field: 'dbType',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'db_type',
|
||||
allowClear: true,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库IP'),
|
||||
field: 'dbIp',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 64,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库端口'),
|
||||
field: 'dbPort',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
maxlength: 10,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库账号'),
|
||||
field: 'dbUsername',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 128,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库密码'),
|
||||
field: 'dbPassword',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 256,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('数据库描述'),
|
||||
field: 'description',
|
||||
component: 'InputTextArea',
|
||||
colProps: { md: 24, lg: 24 },
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isEnabled',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'is_active',
|
||||
allowClear: true,
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: t('schema名称'),
|
||||
field: 'dbSchemaName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
maxlength: 52,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm<BizDbConfig>({
|
||||
labelWidth: 120,
|
||||
schemas: inputFormSchemas,
|
||||
baseColProps: { md: 24, lg: 12 },
|
||||
});
|
||||
|
||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
||||
setDrawerProps({ loading: true });
|
||||
await resetFields();
|
||||
const res = await bizDbConfigForm(data);
|
||||
record.value = (res.bizDbConfig || {}) as BizDbConfig;
|
||||
record.value.__t = new Date().getTime();
|
||||
await setFieldsValue(record.value);
|
||||
setDrawerProps({ loading: false });
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const data = await validate();
|
||||
setDrawerProps({ confirmLoading: true });
|
||||
const params: any = {
|
||||
isNewRecord: record.value.isNewRecord,
|
||||
id: record.value.id || data.id,
|
||||
};
|
||||
// console.log('submit', params, data, record);
|
||||
const res = await bizDbConfigSave(params, data);
|
||||
showMessage(res.message);
|
||||
setTimeout(closeDrawer);
|
||||
emit('success', data);
|
||||
} catch (error: any) {
|
||||
if (error && error.errorFields) {
|
||||
showMessage(error.message || t('common.validateError'));
|
||||
}
|
||||
console.log('error', error);
|
||||
} finally {
|
||||
setDrawerProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
103
web-vue/packages/biz/views/biz/dbConfig/formImport.vue
Normal file
103
web-vue/packages/biz/views/biz/dbConfig/formImport.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
:title="t('导入连接信息')"
|
||||
:okText="t('导入')"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
:minHeight="120"
|
||||
:width="400"
|
||||
>
|
||||
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
|
||||
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
||||
<span class="ml-4">{{ uploadInfo }}</span>
|
||||
</Upload>
|
||||
<div class="ml-4 mt-4">
|
||||
{{ t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a-button @click="handleDownloadTemplate()" type="text">
|
||||
<Icon icon="i-fa:file-excel-o" />
|
||||
{{ t('下载模板') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { Upload } from 'ant-design-vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
|
||||
import { bizDbConfigImportData } from '@jeesite/biz/api/biz/dbConfig';
|
||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const { t } = useI18n('biz.dbConfig');
|
||||
const { showMessage, showMessageModal } = useMessage();
|
||||
|
||||
const fileList = ref<FileType[]>([]);
|
||||
const uploadInfo = ref('');
|
||||
|
||||
const beforeUpload = (file: FileType) => {
|
||||
fileList.value = [file];
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleRemove = () => {
|
||||
fileList.value = [];
|
||||
};
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
|
||||
fileList.value = [];
|
||||
uploadInfo.value = '';
|
||||
});
|
||||
|
||||
async function handleDownloadTemplate() {
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
downloadByUrl({ url: ctxAdminPath + '/biz/dbConfig/importTemplate' });
|
||||
}
|
||||
|
||||
function onUploadProgress(progressEvent: AxiosProgressEvent) {
|
||||
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
|
||||
if (complete != 100) {
|
||||
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
|
||||
} else {
|
||||
uploadInfo.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
if (fileList.value.length == 0) {
|
||||
showMessage(t('请选择要导入的数据文件'));
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
const params = {
|
||||
file: fileList.value[0],
|
||||
};
|
||||
const { data } = await bizDbConfigImportData(params, onUploadProgress);
|
||||
showMessageModal({ content: data.message });
|
||||
setTimeout(closeModal);
|
||||
emit('success');
|
||||
} catch (error: any) {
|
||||
if (error && error.errorFields) {
|
||||
showMessage(error.message || t('common.validateError'));
|
||||
}
|
||||
console.log('error', error);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
286
web-vue/packages/biz/views/biz/dbConfig/list.vue
Normal file
286
web-vue/packages/biz/views/biz/dbConfig/list.vue
Normal file
@@ -0,0 +1,286 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
||||
</a-button>
|
||||
<a-button type="primary" @click="handleForm({})" v-auth="'biz:dbConfig:edit'">
|
||||
<Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
|
||||
</a-button>
|
||||
</template>
|
||||
<template #slotBizKey="{ record }">
|
||||
<a @click="handleForm({ id: record.id })" :title="record.dbName">
|
||||
{{ record.dbName }}
|
||||
</a>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsBizDbConfigList">
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
||||
import { BizDbConfig, bizDbConfigList } from '@jeesite/biz/api/biz/dbConfig';
|
||||
import { bizDbConfigDelete, bizDbConfigListData } from '@jeesite/biz/api/biz/dbConfig';
|
||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
||||
import { useModal } from '@jeesite/core/components/Modal';
|
||||
import { FormProps } from '@jeesite/core/components/Form';
|
||||
import InputForm from './form.vue';
|
||||
import FormImport from './formImport.vue';
|
||||
|
||||
const { t } = useI18n('biz.dbConfig');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<BizDbConfig>({} as BizDbConfig);
|
||||
|
||||
const getTitle = {
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: meta.title || t('连接信息管理'),
|
||||
};
|
||||
const loading = ref(false);
|
||||
|
||||
const searchForm: FormProps<BizDbConfig> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('创建时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('创建时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库类型'),
|
||||
field: 'dbType',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'db_type',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库名称'),
|
||||
field: 'dbName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库IP'),
|
||||
field: 'dbIp',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库描述'),
|
||||
field: 'description',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isEnabled',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'is_active',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizDbConfig>[] = [
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库类型'),
|
||||
dataIndex: 'dbType',
|
||||
key: 'a.db_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
dictType: 'db_type',
|
||||
},
|
||||
{
|
||||
title: t('数据库名称'),
|
||||
dataIndex: 'dbName',
|
||||
key: 'a.db_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
slot: 'slotBizKey',
|
||||
},
|
||||
{
|
||||
title: t('数据库IP'),
|
||||
dataIndex: 'dbIp',
|
||||
key: 'a.db_ip',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库端口'),
|
||||
dataIndex: 'dbPort',
|
||||
key: 'a.db_port',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('数据库账号'),
|
||||
dataIndex: 'dbUsername',
|
||||
key: 'a.db_username',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库密码'),
|
||||
dataIndex: 'dbPassword',
|
||||
key: 'a.db_password',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库描述'),
|
||||
dataIndex: 'description',
|
||||
key: 'a.description',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('是否启用'),
|
||||
dataIndex: 'isEnabled',
|
||||
key: 'a.is_enabled',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
dictType: 'is_active',
|
||||
},
|
||||
{
|
||||
title: t('schema名称'),
|
||||
dataIndex: 'dbSchemaName',
|
||||
key: 'a.db_schema_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumn: BasicColumn<BizDbConfig> = {
|
||||
width: 160,
|
||||
align: 'center',
|
||||
actions: (record: BizDbConfig) => [
|
||||
{
|
||||
icon: 'i-clarity:note-edit-line',
|
||||
title: t('编辑'),
|
||||
onClick: handleForm.bind(this, { id: record.id }),
|
||||
auth: 'biz:dbConfig:edit',
|
||||
},
|
||||
{
|
||||
icon: 'i-ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除连接信息?'),
|
||||
confirm: handleDelete.bind(this, record),
|
||||
},
|
||||
auth: 'biz:dbConfig:edit',
|
||||
ifShow: record.isEnabled == '0'
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const [registerTable, { reload, getForm }] = useTable<BizDbConfig>({
|
||||
api: bizDbConfigListData,
|
||||
beforeFetch: (params) => {
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
actionColumn: actionColumn,
|
||||
formConfig: searchForm,
|
||||
showTableSetting: true,
|
||||
useSearchForm: true,
|
||||
canResize: true,
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await bizDbConfigList();
|
||||
record.value = (res.bizDbConfig || {}) as BizDbConfig;
|
||||
await getForm().setFieldsValue(record.value);
|
||||
});
|
||||
|
||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||
|
||||
function handleForm(record: Recordable) {
|
||||
openDrawer(true, record);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loading.value = true;
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
await downloadByUrl({
|
||||
url: ctxAdminPath + '/biz/dbConfig/exportData',
|
||||
params: getForm().getFieldsValue(),
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const [registerImportModal, { openModal: importModal }] = useModal();
|
||||
|
||||
function handleImport() {
|
||||
importModal(true, {});
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
const params = { id: record.id };
|
||||
const res = await bizDbConfigDelete(params);
|
||||
showMessage(res.message);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
async function handleSuccess(record: Recordable) {
|
||||
await reload({ record });
|
||||
}
|
||||
</script>
|
||||
172
web-vue/packages/biz/views/biz/dbConfig/select.ts
Normal file
172
web-vue/packages/biz/views/biz/dbConfig/select.ts
Normal file
@@ -0,0 +1,172 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { BizDbConfig, bizDbConfigListData } from '@jeesite/biz/api/biz/dbConfig';
|
||||
|
||||
const { t } = useI18n('biz.dbConfig');
|
||||
|
||||
const modalProps = {
|
||||
title: t('连接信息选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<BizDbConfig> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('创建时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('创建时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库类型'),
|
||||
field: 'dbType',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'db_type',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库名称'),
|
||||
field: 'dbName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库IP'),
|
||||
field: 'dbIp',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库描述'),
|
||||
field: 'description',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isEnabled',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'is_active',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizDbConfig>[] = [
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: t('数据库类型'),
|
||||
dataIndex: 'dbType',
|
||||
key: 'a.db_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
dictType: 'db_type',
|
||||
},
|
||||
{
|
||||
title: t('数据库名称'),
|
||||
dataIndex: 'dbName',
|
||||
key: 'a.db_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库IP'),
|
||||
dataIndex: 'dbIp',
|
||||
key: 'a.db_ip',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库端口'),
|
||||
dataIndex: 'dbPort',
|
||||
key: 'a.db_port',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('数据库账号'),
|
||||
dataIndex: 'dbUsername',
|
||||
key: 'a.db_username',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库描述'),
|
||||
dataIndex: 'description',
|
||||
key: 'a.description',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('是否启用'),
|
||||
dataIndex: 'isEnabled',
|
||||
key: 'a.is_enabled',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
dictType: 'is_active',
|
||||
},
|
||||
{
|
||||
title: t('schema名称'),
|
||||
dataIndex: 'dbSchemaName',
|
||||
key: 'a.db_schema_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: bizDbConfigListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'id',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'id',
|
||||
itemName: 'dbName',
|
||||
isShowCode: true,
|
||||
};
|
||||
@@ -16,7 +16,6 @@
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { bizDeviceInfoListData } from '@jeesite/biz/api/biz/deviceInfo';
|
||||
|
||||
const { t } = useI18n('biz.deviceInfo');
|
||||
|
||||
const modalProps = {
|
||||
title: t('磁盘信息选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<BizDeviceInfo> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('记录时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('记录时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('主机标识'),
|
||||
field: 'hostId',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizDeviceInfo>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 230,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
},
|
||||
{
|
||||
title: t('设备名称'),
|
||||
dataIndex: 'device',
|
||||
key: 'a.device',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('挂载点'),
|
||||
dataIndex: 'mountPoint',
|
||||
key: 'a.mount_point',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('总容量'),
|
||||
dataIndex: 'totalSize',
|
||||
key: 'a.total_size',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('已使用容量'),
|
||||
dataIndex: 'usedSize',
|
||||
key: 'a.used_size',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('使用率'),
|
||||
dataIndex: 'usageRate',
|
||||
key: 'a.usage_rate',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('最后一次检测时间'),
|
||||
dataIndex: 'lastOnlineTime',
|
||||
key: 'a.last_online_time',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('主机标识'),
|
||||
dataIndex: 'hostId',
|
||||
key: 'a.host_id',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: bizDeviceInfoListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'id',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'id',
|
||||
itemName: 'id',
|
||||
isShowCode: false,
|
||||
};
|
||||
@@ -16,7 +16,6 @@
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { bizServerInfoListData } from '@jeesite/biz/api/biz/serverInfo';
|
||||
|
||||
const { t } = useI18n('biz.serverInfo');
|
||||
|
||||
const modalProps = {
|
||||
title: t('运行信息选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<BizServerInfo> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('记录时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('记录时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('内核版本'),
|
||||
field: 'kernelVersion',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('主机名称'),
|
||||
field: 'hostname',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('主机地址'),
|
||||
field: 'ipAddress',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('CPU型号'),
|
||||
field: 'cpuModel',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('主机标识'),
|
||||
field: 'hostId',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizServerInfo>[] = [
|
||||
{
|
||||
title: t('记录时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 230,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
},
|
||||
{
|
||||
title: t('主机运行时间'),
|
||||
dataIndex: 'uptime',
|
||||
key: 'a.uptime',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('操作系统'),
|
||||
dataIndex: 'os',
|
||||
key: 'a.os',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('内核版本'),
|
||||
dataIndex: 'kernelVersion',
|
||||
key: 'a.kernel_version',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('主机名称'),
|
||||
dataIndex: 'hostname',
|
||||
key: 'a.hostname',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('主机地址'),
|
||||
dataIndex: 'ipAddress',
|
||||
key: 'a.ip_address',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('CPU型号'),
|
||||
dataIndex: 'cpuModel',
|
||||
key: 'a.cpu_model',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('内存总量'),
|
||||
dataIndex: 'memoryTotal',
|
||||
key: 'a.memory_total',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('CPU使用率'),
|
||||
dataIndex: 'cpuUsage',
|
||||
key: 'a.cpu_usage',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('内存使用率'),
|
||||
dataIndex: 'memoryUsage',
|
||||
key: 'a.memory_usage',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('最后一次检测时间'),
|
||||
dataIndex: 'lastOnlineTime',
|
||||
key: 'a.last_online_time',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('主机标识'),
|
||||
dataIndex: 'hostId',
|
||||
key: 'a.host_id',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: bizServerInfoListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'id',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'id',
|
||||
itemName: 'id',
|
||||
isShowCode: false,
|
||||
};
|
||||
103
web-vue/packages/biz/views/biz/tableInfo/formImport.vue
Normal file
103
web-vue/packages/biz/views/biz/tableInfo/formImport.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
:title="t('导入数据信息')"
|
||||
:okText="t('导入')"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
:minHeight="120"
|
||||
:width="400"
|
||||
>
|
||||
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
|
||||
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
||||
<span class="ml-4">{{ uploadInfo }}</span>
|
||||
</Upload>
|
||||
<div class="ml-4 mt-4">
|
||||
{{ t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a-button @click="handleDownloadTemplate()" type="text">
|
||||
<Icon icon="i-fa:file-excel-o" />
|
||||
{{ t('下载模板') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { Upload } from 'ant-design-vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicModal, useModalInner } from '@jeesite/core/components/Modal';
|
||||
import { bizTableInfoImportData } from '@jeesite/biz/api/biz/tableInfo';
|
||||
import { FileType } from 'ant-design-vue/es/upload/interface';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
|
||||
const { t } = useI18n('biz.tableInfo');
|
||||
const { showMessage, showMessageModal } = useMessage();
|
||||
|
||||
const fileList = ref<FileType[]>([]);
|
||||
const uploadInfo = ref('');
|
||||
|
||||
const beforeUpload = (file: FileType) => {
|
||||
fileList.value = [file];
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleRemove = () => {
|
||||
fileList.value = [];
|
||||
};
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {
|
||||
fileList.value = [];
|
||||
uploadInfo.value = '';
|
||||
});
|
||||
|
||||
async function handleDownloadTemplate() {
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
downloadByUrl({ url: ctxAdminPath + '/biz/tableInfo/importTemplate' });
|
||||
}
|
||||
|
||||
function onUploadProgress(progressEvent: AxiosProgressEvent) {
|
||||
const complete = ((progressEvent.loaded / (progressEvent.total || 1)) * 100) | 0;
|
||||
if (complete != 100) {
|
||||
uploadInfo.value = t('正在导入,请稍候') + ' ' + complete + '%...';
|
||||
} else {
|
||||
uploadInfo.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
if (fileList.value.length == 0) {
|
||||
showMessage(t('请选择要导入的数据文件'));
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
const params = {
|
||||
file: fileList.value[0],
|
||||
};
|
||||
const { data } = await bizTableInfoImportData(params, onUploadProgress);
|
||||
showMessageModal({ content: data.message });
|
||||
setTimeout(closeModal);
|
||||
emit('success');
|
||||
} catch (error: any) {
|
||||
if (error && error.errorFields) {
|
||||
showMessage(error.message || t('common.validateError'));
|
||||
}
|
||||
console.log('error', error);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
271
web-vue/packages/biz/views/biz/tableInfo/list.vue
Normal file
271
web-vue/packages/biz/views/biz/tableInfo/list.vue
Normal file
@@ -0,0 +1,271 @@
|
||||
<!--
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author gaoxq
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<Icon :icon="getTitle.icon" class="m-1 pr-1" />
|
||||
<span> {{ getTitle.value }} </span>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<a-button type="default" :loading="loading" @click="handleExport()">
|
||||
<Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="ViewsBizTableInfoList">
|
||||
import { onMounted, ref, unref } from 'vue';
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { useMessage } from '@jeesite/core/hooks/web/useMessage';
|
||||
import { useGlobSetting } from '@jeesite/core/hooks/setting';
|
||||
import { downloadByUrl } from '@jeesite/core/utils/file/download';
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
||||
import { BizTableInfo, bizTableInfoList } from '@jeesite/biz/api/biz/tableInfo';
|
||||
import { bizTableInfoDelete, bizTableInfoListData } from '@jeesite/biz/api/biz/tableInfo';
|
||||
import { useDrawer } from '@jeesite/core/components/Drawer';
|
||||
import { useModal } from '@jeesite/core/components/Modal';
|
||||
import { FormProps } from '@jeesite/core/components/Form';
|
||||
import FormImport from './formImport.vue';
|
||||
|
||||
const { t } = useI18n('biz.tableInfo');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<BizTableInfo>({} as BizTableInfo);
|
||||
|
||||
const getTitle = {
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
value: meta.title || t('数据信息管理'),
|
||||
};
|
||||
const loading = ref(false);
|
||||
|
||||
const searchForm: FormProps<BizTableInfo> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('创建时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('创建时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据表名称'),
|
||||
field: 'dataName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据表描述'),
|
||||
field: 'tableComment',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库名称'),
|
||||
field: 'dbId',
|
||||
fieldLabel: 'dbName',
|
||||
component: 'ListSelect',
|
||||
componentProps: {
|
||||
selectType: 'bizDbSelect',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据来源'),
|
||||
field: 'dataSource',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('备注信息'),
|
||||
field: 'remarks',
|
||||
component: 'Input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizTableInfo>[] = [
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库名称'),
|
||||
dataIndex: 'dbName',
|
||||
key: 'b.db_name',
|
||||
sorter: true,
|
||||
width: 200,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库IP'),
|
||||
dataIndex: 'dbIp',
|
||||
key: 'b.db_ip',
|
||||
sorter: true,
|
||||
width: 200,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据表名称'),
|
||||
dataIndex: 'dataName',
|
||||
key: 'a.data_name',
|
||||
sorter: true,
|
||||
width: 200,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据表描述'),
|
||||
dataIndex: 'tableComment',
|
||||
key: 'a.table_comment',
|
||||
sorter: true,
|
||||
width: 225,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据表大小'),
|
||||
dataIndex: 'tableSize',
|
||||
key: 'a.table_size',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('数据来源'),
|
||||
dataIndex: 'dataSource',
|
||||
key: 'a.data_source',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('创建人员'),
|
||||
dataIndex: 'creator',
|
||||
key: 'a.creator',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('记录条数'),
|
||||
dataIndex: 'dataRows',
|
||||
key: 'a.data_rows',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('备注信息'),
|
||||
dataIndex: 'remarks',
|
||||
key: 'a.remarks',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('分区日期'),
|
||||
dataIndex: 'ds',
|
||||
key: 'a.ds',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumn: BasicColumn<BizTableInfo> = {
|
||||
width: 160,
|
||||
align: 'center',
|
||||
actions: (record: BizTableInfo) => [
|
||||
{
|
||||
icon: 'i-ant-design:delete-outlined',
|
||||
color: 'error',
|
||||
title: t('删除'),
|
||||
popConfirm: {
|
||||
title: t('是否确认删除数据信息?'),
|
||||
confirm: handleDelete.bind(this, record),
|
||||
},
|
||||
auth: 'biz:tableInfo:edit',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const [registerTable, { reload, getForm }] = useTable<BizTableInfo>({
|
||||
api: bizTableInfoListData,
|
||||
beforeFetch: (params) => {
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
actionColumn: actionColumn,
|
||||
formConfig: searchForm,
|
||||
showTableSetting: true,
|
||||
useSearchForm: true,
|
||||
canResize: true,
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await bizTableInfoList();
|
||||
record.value = (res.bizTableInfo || {}) as BizTableInfo;
|
||||
await getForm().setFieldsValue(record.value);
|
||||
});
|
||||
|
||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||
|
||||
function handleForm(record: Recordable) {
|
||||
openDrawer(true, record);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loading.value = true;
|
||||
const { ctxAdminPath } = useGlobSetting();
|
||||
await downloadByUrl({
|
||||
url: ctxAdminPath + '/biz/tableInfo/exportData',
|
||||
params: getForm().getFieldsValue(),
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const [registerImportModal, { openModal: importModal }] = useModal();
|
||||
|
||||
function handleImport() {
|
||||
importModal(true, {});
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
const params = { tableId: record.tableId };
|
||||
const res = await bizTableInfoDelete(params);
|
||||
showMessage(res.message);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
async function handleSuccess(record: Recordable) {
|
||||
await reload({ record });
|
||||
}
|
||||
</script>
|
||||
@@ -70,7 +70,7 @@ const tableColumns: BasicColumn<BizCompany>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('公司名称'),
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
|
||||
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
|
||||
import { BizDbConfig, bizDbConfigListData } from '@jeesite/biz/api/biz/dbConfig';
|
||||
|
||||
const { t } = useI18n('biz.dbConfig');
|
||||
|
||||
const modalProps = {
|
||||
title: t('连接信息选择'),
|
||||
};
|
||||
|
||||
const searchForm: FormProps<BizDbConfig> = {
|
||||
baseColProps: { md: 8, lg: 6 },
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: t('创建时间起'),
|
||||
field: 'createTime_gte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('创建时间止'),
|
||||
field: 'createTime_lte',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm',
|
||||
showTime: { format: 'HH:mm' },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库类型'),
|
||||
field: 'dbType',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'db_type',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('数据库名称'),
|
||||
field: 'dbName',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库IP'),
|
||||
field: 'dbIp',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('数据库描述'),
|
||||
field: 'description',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: t('是否启用'),
|
||||
field: 'isEnabled',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
dictType: 'is_active',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn<BizDbConfig>[] = [
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'createTime',
|
||||
key: 'a.create_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: t('数据库类型'),
|
||||
dataIndex: 'dbType',
|
||||
key: 'a.db_type',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
dictType: 'db_type',
|
||||
},
|
||||
{
|
||||
title: t('数据库名称'),
|
||||
dataIndex: 'dbName',
|
||||
key: 'a.db_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库IP'),
|
||||
dataIndex: 'dbIp',
|
||||
key: 'a.db_ip',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库端口'),
|
||||
dataIndex: 'dbPort',
|
||||
key: 'a.db_port',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('数据库账号'),
|
||||
dataIndex: 'dbUsername',
|
||||
key: 'a.db_username',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('数据库描述'),
|
||||
dataIndex: 'description',
|
||||
key: 'a.description',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('是否启用'),
|
||||
dataIndex: 'isEnabled',
|
||||
key: 'a.is_enabled',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'center',
|
||||
dictType: 'is_active',
|
||||
},
|
||||
{
|
||||
title: t('schema名称'),
|
||||
dataIndex: 'dbSchemaName',
|
||||
key: 'a.db_schema_name',
|
||||
sorter: true,
|
||||
width: 130,
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
title: t('更新时间'),
|
||||
dataIndex: 'updateTime',
|
||||
key: 'a.update_time',
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: BasicTableProps = {
|
||||
api: bizDbConfigListData,
|
||||
beforeFetch: (params) => {
|
||||
params['isAll'] = true;
|
||||
return params;
|
||||
},
|
||||
columns: tableColumns,
|
||||
formConfig: searchForm,
|
||||
rowKey: 'id',
|
||||
};
|
||||
|
||||
export default {
|
||||
modalProps,
|
||||
tableProps,
|
||||
itemCode: 'id',
|
||||
itemName: 'dbName',
|
||||
isShowCode: true,
|
||||
};
|
||||
@@ -73,7 +73,7 @@ const tableColumns: BasicColumn<BizResumeEmployee>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('员工姓名'),
|
||||
|
||||
@@ -74,6 +74,7 @@ const tableColumns: BasicColumn<BizMonitorHost>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('主机名称'),
|
||||
|
||||
@@ -42,7 +42,7 @@ const tableColumns: BasicColumn<BizProjectInfo>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('项目编码'),
|
||||
|
||||
@@ -42,6 +42,7 @@ const tableColumns: BasicColumn<BizProvince>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('省份名称'),
|
||||
|
||||
@@ -82,7 +82,7 @@ const tableColumns: BasicColumn[] = [
|
||||
key: 'a.login_code',
|
||||
sorter: true,
|
||||
width: 100,
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('用户昵称'),
|
||||
|
||||
@@ -42,6 +42,7 @@ const tableColumns: BasicColumn<ErpAccount>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('账户名称'),
|
||||
|
||||
@@ -46,6 +46,7 @@ const tableColumns: BasicColumn<ErpCategory>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('分类名称'),
|
||||
|
||||
@@ -46,7 +46,7 @@ const tableColumns: BasicColumn<ErpTransactionFlow>[] = [
|
||||
sorter: true,
|
||||
width: 180,
|
||||
align: 'left',
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('交易名称'),
|
||||
|
||||
@@ -60,7 +60,7 @@ const tableColumns: BasicColumn[] = [
|
||||
key: 'a.login_code',
|
||||
sorter: true,
|
||||
width: 100,
|
||||
slot: 'firstColumn',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: t('用户昵称'),
|
||||
|
||||
Reference in New Issue
Block a user