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