refactor: 系统配置支持上传自定义css
This commit is contained in:
parent
dbe3df5099
commit
3e4e4a7b84
|
@ -109,6 +109,13 @@ public class LoginController {
|
|||
return Mono.just(image);
|
||||
}
|
||||
|
||||
@GetMapping("display/file/css")
|
||||
public Mono<ResponseEntity<byte[]>> cssFile() throws IOException {
|
||||
ResponseEntity<byte[]> css = baseDisplayService.getCss();
|
||||
return Mono.just(css);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("display/info")
|
||||
public Mono<ResultHolder> uiInfo() {
|
||||
return Mono.just(ResultHolder.success(baseDisplayService.uiInfo("ui")));
|
||||
|
|
|
@ -96,4 +96,21 @@ public class BaseDisplayService {
|
|||
dtoList.sort(Comparator.comparingInt(SystemParameter::getSort));
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getCss() {
|
||||
byte[] bytes = new byte[0];
|
||||
List<SystemParameter> paramList = getParamList("ui.css");
|
||||
if (!CollectionUtils.isEmpty(paramList)) {
|
||||
SystemParameter sp = paramList.get(0);
|
||||
String paramValue = sp.getParamValue();
|
||||
if (StringUtils.isNotBlank(paramValue)) {
|
||||
bytes = loadFileAsBytes(paramValue);
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType("text/css"))
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=css")
|
||||
.body(bytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,11 @@ public class LoginController {
|
|||
return baseDisplayService.getImage(imageName);
|
||||
}
|
||||
|
||||
@GetMapping("display/file/css")
|
||||
public ResponseEntity<byte[]> cssFile() throws IOException {
|
||||
return baseDisplayService.getCss();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/services")
|
||||
public List<ServiceDTO> services() {
|
||||
return List.of(new ServiceDTO(serviceId, port));
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.base.domain.SystemParameter;
|
|||
import io.metersphere.base.domain.SystemParameterExample;
|
||||
import io.metersphere.base.mapper.SystemParameterMapper;
|
||||
import io.metersphere.metadata.service.FileMetadataService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -14,7 +15,6 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -77,4 +77,21 @@ public class BaseDisplayService {
|
|||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + imageName + "\"")
|
||||
.body(bytes);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getCss() {
|
||||
byte[] bytes = new byte[0];
|
||||
List<SystemParameter> paramList = getParamList("ui.css");
|
||||
if (!CollectionUtils.isEmpty(paramList)) {
|
||||
SystemParameter sp = paramList.get(0);
|
||||
String paramValue = sp.getParamValue();
|
||||
if (StringUtils.isNotBlank(paramValue)) {
|
||||
bytes = loadFileAsBytes(paramValue);
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType("text/css"))
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=css")
|
||||
.body(bytes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue