APP上传时,若指定参数不存在,则给予默认值

This commit is contained in:
cuizhibin 2025-06-06 14:01:52 +08:00
parent 9b01a78789
commit af4c318a10
1 changed files with 10 additions and 12 deletions

View File

@ -166,15 +166,11 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String path_prefix = permPath.concat(imageSource).concat(FileUtil.FILE_SEPARATOR).concat(dateStr).concat(FileUtil.FILE_SEPARATOR);
if (Objects.nonNull(imageWorkReq)) {
if (StrUtil.isNotBlank(imageWorkReq.getUploadUser())) {
path_prefix = path_prefix.concat(imageWorkReq.getUploadUser()).concat(FileUtil.FILE_SEPARATOR);
}
if (StrUtil.isNotBlank(imageWorkReq.getLongitude())) {
path_prefix = path_prefix.concat(imageWorkReq.getLongitude())
.concat(" ").concat(StrUtil.nullToDefault(imageWorkReq.getLatitude(), "0"))
.concat(" ").concat(StrUtil.nullToDefault(imageWorkReq.getAltitude(), "0"))
.concat(FileUtil.FILE_SEPARATOR);
}
path_prefix = path_prefix.concat(StrUtil.nullToDefault(imageWorkReq.getUploadUser(), "默认用户")).concat(FileUtil.FILE_SEPARATOR)
.concat(StrUtil.nullToDefault(imageWorkReq.getLongitude(), "0"))
.concat(" ").concat(StrUtil.nullToDefault(imageWorkReq.getLatitude(), "0"))
.concat(" ").concat(StrUtil.nullToDefault(imageWorkReq.getAltitude(), "0"))
.concat(FileUtil.FILE_SEPARATOR);
}
if (!FileUtil.exist(path_prefix)) {
FileUtil.mkdir(path_prefix);
@ -344,9 +340,11 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
}
} else {
List<String> gps = StrUtil.split(split.get(5), " ");
resp.setLongitude(gps.get(0));
resp.setLatitude(gps.get(1));
resp.setAltitude(gps.get(2));
if (gps.size() > 1) {
resp.setLongitude(gps.get(0));
resp.setLatitude(gps.get(1));
resp.setAltitude(gps.get(2));
}
}
resp.setUploadUser(split.get(4));
resp.setImageSource(split.get(2));