zhou zhou
2 天以前 1dcfa3702505f0c431757312b5304531029f90f6
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/ProjectLogoController.java
@@ -17,6 +17,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.vincent.rsf.server.manager.utils.buildPageRowsUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -81,7 +82,12 @@
                .eq(Config::getFlag, flag)
                .eq(Config::getStatus, StatusType.ENABLE.val)
                .last("limit 1"));
        return R.ok().add(configs.stream().findFirst().orElse(null));
        Config config = configs.stream().findFirst().orElse(null);
        if (config != null && PROJECT_LOGO_FLAG.equals(flag)) {
            config.setVal(resolveProjectLogoValue(config.getVal()));
        }
        return R.ok().add(buildPageRowsUtils.rowsMap(config));
    }
    @PreAuthorize("hasAnyAuthority('system:config:save','system:config:update')")
@@ -98,7 +104,7 @@
        payload.put("name", savedFile.getName());
        payload.put("path", relativePath);
        payload.put("url", url);
        return R.ok().add(payload);
        return R.ok().add(buildPageRowsUtils.rowsMap(payload));
    }
    @GetMapping("/file/logo")
@@ -155,6 +161,22 @@
        return resolvedPath;
    }
    private String resolveProjectLogoValue(String value) {
        if (!StringUtils.hasText(value)) {
            return "";
        }
        int pathIndex = value.indexOf("?path=");
        if (pathIndex < 0) {
            return value;
        }
        String relativePath = value.substring(pathIndex + 6);
        if (!StringUtils.hasText(relativePath)) {
            return "";
        }
        File file = resolveLogoPath(relativePath).toFile();
        return file.exists() && file.isFile() ? value : "";
    }
    private String resolveImageContentType(String fileName) {
        String normalizedName = StringUtils.hasText(fileName) ? fileName.toLowerCase(Locale.ROOT) : "";
        if (normalizedName.endsWith(".png")) {