yanderong
2026-09-15 8061172c77799e83893fef00848a48a0d148a0eb
feat:bug修改
1个文件已添加
10个文件已修改
74 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/BaseDataApiUtil.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/sql/alter_t_visitor_config.sql 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysVisitorConfig.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/SysVisitorConfigSaveRequest.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysVisitorConfigServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/SysVisitorConfigVO.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/SysVisitorConfigMapper.xml 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
visitor-admin-ui/js/system-config.js 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
visitor-admin-ui/pages/system-config.html 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -96,6 +96,7 @@
        }
        catch (Exception e)
        {
            log.error("上传文件图片报错:", e);
            return AjaxResult.error(e.getMessage());
        }
    }
@@ -133,6 +134,7 @@
        }
        catch (Exception e)
        {
            log.error("上传文件图片报错:", e);
            return AjaxResult.error(e.getMessage());
        }
    }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/BaseDataApiUtil.java
@@ -5,6 +5,9 @@
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.service.ISysVisitorConfigService;
import com.ruoyi.system.vo.SysVisitorConfigVO;
import okhttp3.FormBody;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
@@ -168,9 +171,19 @@
    }
    /**
     * 目的:统一解析中台基础地址,优先使用系统属性,其次环境变量,最后使用默认地址。
     * 目的:统一解析中台基础地址,优先使用数据库访客配置中的 centerPath,
     * 其次使用系统属性和环境变量,最后使用默认地址。
     */
    public static String getDefaultBaseUrl() {
        try {
            ISysVisitorConfigService service = SpringUtils.getBean(ISysVisitorConfigService.class);
            SysVisitorConfigVO config = service == null ? null : service.selectConfig();
            if (config != null && isNotBlank(config.getCenterPath())) {
                return config.getCenterPath().trim();
            }
        } catch (Exception ignored) {
            // Spring 容器尚未初始化或配置查询失败时继续使用本地覆盖配置。
        }
        String propertyUrl = System.getProperty(BASE_URL_PROPERTY);
        if (isNotBlank(propertyUrl)) {
            return propertyUrl.trim();
ruoyi-admin/src/main/resources/sql/alter_t_visitor_config.sql
New file
@@ -0,0 +1 @@
alter table t_visitor_config  add column center_path  varchar(255) default null comment '中台地址';
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -135,14 +136,27 @@
    public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
    {
        File desc = new File(uploadDir + File.separator + fileName);
        if (!desc.exists())
        if (StringUtils.isEmpty(uploadDir))
        {
            if (!desc.getParentFile().exists())
            {
                desc.getParentFile().mkdirs();
            throw new IOException("上传目录未配置");
            }
        File desc = new File(uploadDir, fileName);
        File parent = desc.getParentFile();
        if (parent == null)
        {
            throw new IOException("上传目录无效: " + uploadDir);
        }
        try
        {
            Files.createDirectories(parent.toPath());
        }
        catch (IOException e)
        {
            throw new IOException("无法创建上传目录: " + parent.getAbsolutePath(), e);
        }
        if (!parent.isDirectory() || !parent.canWrite())
        {
            throw new IOException("上传目录不可写: " + parent.getAbsolutePath());
        }
        return desc;
    }
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysVisitorConfig.java
@@ -62,4 +62,9 @@
    /** 删除标志:0正常 1删除 */
    private String delFlag;
    /**
     * 中台地址
     */
    private String centerPath;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/SysVisitorConfigSaveRequest.java
@@ -68,4 +68,9 @@
    /** 是否显示访客机管理入口 */
    @ApiModelProperty("是否显示访客机管理入口")
    private Boolean visitorMachineEntryEnabled;
    /**
     * 中台地址
     */
    private String centerPath;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysVisitorConfigServiceImpl.java
@@ -152,6 +152,10 @@
        {
            config.setVisitorMachineEntryEnabled(request.getVisitorMachineEntryEnabled());
        }
        if (StringUtils.isNotEmpty(request.getCenterPath()))
        {
            config.setCenterPath(request.getCenterPath());
        }
    }
    private String joinPrintFields(List<String> printFields)
@@ -224,6 +228,7 @@
        vo.setServiceProvider(config.getServiceProvider());
        vo.setSupportPhone(config.getSupportPhone());
        vo.setVisitorMachineEntryEnabled(config.getVisitorMachineEntryEnabled());
        vo.setCenterPath(config.getCenterPath());
        return vo;
    }
ruoyi-system/src/main/java/com/ruoyi/system/vo/SysVisitorConfigVO.java
@@ -63,4 +63,7 @@
    @ApiModelProperty(value = "访客机管理入口开关", example = "true", allowableValues = "true,false")
    private Boolean visitorMachineEntryEnabled;
    @ApiModelProperty(value = "中台地址", example = "http://192.168.1.146:18888")
    private String centerPath;
}
ruoyi-system/src/main/resources/mapper/system/SysVisitorConfigMapper.xml
@@ -25,6 +25,7 @@
        <result property="createTime"                         column="create_time" />
        <result property="updateBy"                           column="update_by" />
        <result property="updateTime"                         column="update_time" />
        <result property="centerPath"                         column="center_path" />
        <result property="remark"                             column="remark" />
    </resultMap>
@@ -49,6 +50,7 @@
               create_time,
               update_by,
               update_time,
               center_path,
               remark
        from t_visitor_config
    </sql>
@@ -78,6 +80,7 @@
            visitor_machine_entry_enabled,
            create_by,
            create_time,
            center_path,
            remark
        ) values (
            #{onsiteRegistrationEnabled},
@@ -96,6 +99,7 @@
            #{visitorMachineEntryEnabled},
            #{createBy},
            sysdate(),
            #{centerPath},
            #{remark}
        )
    </insert>
visitor-admin-ui/js/system-config.js
@@ -164,6 +164,7 @@
    document.getElementById("systemName").value = data.systemName || "自主访客登记管理平台";
    document.getElementById("serviceProvider").value = data.serviceProvider || "XXX";
    document.getElementById("supportPhone").value = data.supportPhone || "XXX";
    document.getElementById("centerPath").value = data.centerPath || "";
    state.logoUrl = data.logoUrl || "";
    state.logoFile = null;
@@ -384,7 +385,8 @@
      logoUrl: state.logoUrl,
      serviceProvider: valueOf("serviceProvider"),
      supportPhone: valueOf("supportPhone"),
      visitorMachineEntryEnabled: checkedOf("visitorMachineEntryEnabled")
      visitorMachineEntryEnabled: checkedOf("visitorMachineEntryEnabled"),
      centerPath: valueOf("centerPath")
    };
  }
visitor-admin-ui/pages/system-config.html
@@ -258,6 +258,10 @@
                    <input id="visitorMachineEntryEnabled" type="checkbox">
                    <span class="switch-control"></span>
                  </label>
                  <label class="input-field entry-center-path">
                    <span>中台地址</span>
                    <input id="centerPath" type="text" placeholder="请输入中台地址(可为空)">
                  </label>
                </div>
              </div>
            </section>