This commit is contained in:
2025-11-30 00:14:48 +08:00
parent c881640667
commit fcb335726d
19 changed files with 73 additions and 281 deletions

View File

@@ -17,23 +17,47 @@ public class IpUtils {
* @return 本地IP地址获取失败返回null
*/
public static String getLocalIp() {
// 1. 优先读取宿主机注入的环境变量
String hostIp = System.getenv("HOST_MACHINE_IP");
if (isValidIp(hostIp)) {
return hostIp;
}
// 2. 尝试解析Docker网关宿主机IP
try {
InetAddress gatewayAddr = InetAddress.getByName("gateway");
if (gatewayAddr.isReachable(1000)) {
String gatewayIp = gatewayAddr.getHostAddress();
if (isValidIp(gatewayIp)) {
return gatewayIp;
}
}
} catch (Exception e) {
System.out.print(e.getMessage());
}
// 3. 过滤容器网卡获取宿主机IP
try {
// 遍历所有网络接口
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface ni = interfaces.nextElement();
// 跳过虚拟网卡、未启用的网卡
if (ni.isLoopback() || ni.isVirtual() || !ni.isUp()) {
if (ni.isLoopback() || ni.isVirtual() || !ni.isUp()
|| ni.getName().startsWith("docker")
|| ni.getName().startsWith("veth")
|| ni.getName().startsWith("cni0")) {
continue;
}
// 遍历该网卡下的所有IP地址
Enumeration<InetAddress> addresses = ni.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
// 仅保留IPv4地址且排除回环地址
if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) {
String ip = addr.getHostAddress();
if (!ip.startsWith("172.") && !ip.startsWith("192.168.31.")) {
// 过滤容器内网段
if (!ip.startsWith("172.")
&& !ip.startsWith("192.168.99.")
&& !ip.startsWith("10.0.")
&& isValidIp(ip)) {
return ip;
}
}
@@ -42,9 +66,36 @@ public class IpUtils {
} catch (SocketException e) {
e.printStackTrace();
}
// 4. 兜底返回回环地址
return getLoopbackIp();
}
/**
* 验证是否为合法IPv4地址
*/
private static boolean isValidIp(String ip) {
if (ip == null || ip.isEmpty()) {
return false;
}
String[] parts = ip.split("\\.");
if (parts.length != 4) {
return false;
}
for (String part : parts) {
try {
int num = Integer.parseInt(part);
if (num < 0 || num > 255) {
return false;
}
} catch (NumberFormatException e) {
return false;
}
}
return true;
}
/**
* 获取回环地址127.0.0.1
*

View File

@@ -126,6 +126,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('省份编码'),

View File

@@ -118,6 +118,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('公司名称'),

View File

@@ -129,6 +129,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('头像图标'),

View File

@@ -158,6 +158,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('省份名称'),

View File

@@ -126,6 +126,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('项目编码'),

View File

@@ -1,132 +0,0 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { BizProjectInfo, bizProjectInfoListData } from '@jeesite/biz/api/biz/projectInfo';
const { t } = useI18n('biz.projectInfo');
const modalProps = {
title: t('项目信息选择'),
};
const searchForm: FormProps<BizProjectInfo> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
{
label: t('项目编码'),
field: 'projectCode',
component: 'Input',
},
{
label: t('项目名称'),
field: 'projectName',
component: 'Input',
},
{
label: t('项目状态'),
field: 'projectStatus',
component: 'Select',
componentProps: {
dictType: 'project_status',
allowClear: true,
},
},
],
};
const tableColumns: BasicColumn<BizProjectInfo>[] = [
{
title: t('记录时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 180,
align: 'left',
slot: 'firstColumn',
},
{
title: t('项目编码'),
dataIndex: 'projectCode',
key: 'a.project_code',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('项目名称'),
dataIndex: 'projectName',
key: 'a.project_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('项目描述'),
dataIndex: 'projectDesc',
key: 'a.project_desc',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('开始日期'),
dataIndex: 'startDate',
key: 'a.start_date',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('预计结束日期'),
dataIndex: 'endDate',
key: 'a.end_date',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('实际结束日期'),
dataIndex: 'actualEndDate',
key: 'a.actual_end_date',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('项目类型'),
dataIndex: 'projectType',
key: 'a.project_type',
sorter: true,
width: 130,
align: 'left',
dictType: 'project_type',
},
{
title: t('项目状态'),
dataIndex: 'projectStatus',
key: 'a.project_status',
sorter: true,
width: 130,
align: 'left',
dictType: 'project_status',
},
];
const tableProps: BasicTableProps = {
api: bizProjectInfoListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'projectId',
};
export default {
modalProps,
tableProps,
itemCode: 'projectId',
itemName: 'projectName',
isShowCode: true,
};

View File

@@ -130,6 +130,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('汇报主题'),

View File

@@ -154,6 +154,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('需求名称'),

View File

@@ -122,6 +122,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('省份名称'),

View File

@@ -85,6 +85,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('系统名称'),

View File

@@ -1,143 +0,0 @@
import { useI18n } from '@jeesite/core/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '@jeesite/core/components/Table';
import { BizQuickLogin, bizQuickLoginListData } from '@jeesite/biz/api/biz/quickLogin';
const { t } = useI18n('biz.quickLogin');
const modalProps = {
title: t('系统信息选择'),
};
const searchForm: FormProps<BizQuickLogin> = {
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: 'systemName',
component: 'Input',
},
],
};
const tableColumns: BasicColumn<BizQuickLogin>[] = [
{
title: t('创建时间'),
dataIndex: 'createTime',
key: 'a.create_time',
sorter: true,
width: 230,
align: 'left',
slot: 'firstColumn',
},
{
title: t('系统名称'),
dataIndex: 'systemName',
key: 'a.system_name',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('首页地址'),
dataIndex: 'homepageUrl',
key: 'a.homepage_url',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('图标类名'),
dataIndex: 'iconClass',
key: 'a.icon_class',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('图标颜色'),
dataIndex: 'iconColor',
key: 'a.icon_color',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('排序序号'),
dataIndex: 'sortOrder',
key: 'a.sort_order',
sorter: true,
width: 130,
align: 'center',
},
{
title: t('图标背景色'),
dataIndex: 'bgColor',
key: 'a.bg_color',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('悬浮遮罩色'),
dataIndex: 'maskColor',
key: 'a.mask_color',
sorter: true,
width: 130,
align: 'left',
},
{
title: t('是否启用'),
dataIndex: 'isEnabled',
key: 'a.is_enabled',
sorter: true,
width: 130,
align: 'center',
dictType: '',
},
{
title: t('更新时间'),
dataIndex: 'updateTime',
key: 'a.update_time',
sorter: true,
width: 130,
align: 'center',
},
];
const tableProps: BasicTableProps = {
api: bizQuickLoginListData,
beforeFetch: (params) => {
params['isAll'] = true;
return params;
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'id',
};
export default {
modalProps,
tableProps,
itemCode: 'id',
itemName: 'id',
isShowCode: false,
};

View File

@@ -121,6 +121,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('员工姓名'),

View File

@@ -126,6 +126,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('网站地址'),

View File

@@ -94,6 +94,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('账户名称'),

View File

@@ -94,6 +94,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('分类名称'),

View File

@@ -89,6 +89,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('交易账号'),

View File

@@ -89,6 +89,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('交易账号'),

View File

@@ -125,6 +125,7 @@
sorter: true,
width: 180,
align: 'left',
fixed: 'left',
},
{
title: t('交易名称'),