fixed address for map
This commit is contained in:
@@ -72,6 +72,8 @@ public class PostService {
|
||||
post.setStatus(PostStatus.MODERATION);
|
||||
post.setUser(currentUser);
|
||||
post.setIsReward(request.getReward());
|
||||
// Адрес из формы сохраняем как есть; геокодер заполняет только city/district
|
||||
post.setAddress(normalizeAddress(request.getAddress()));
|
||||
if (request.getLatitude() == null || request.getLongitude() == null) {
|
||||
post.setCity(request.getAddress());
|
||||
} else {
|
||||
@@ -199,6 +201,7 @@ public class PostService {
|
||||
post.setType(request.getType());
|
||||
post.setIsReward(request.getReward());
|
||||
post.setReward(request.getRewardText());
|
||||
post.setAddress(normalizeAddress(request.getAddress()));
|
||||
|
||||
if (request.getLatitude() != null && request.getLongitude() != null) {
|
||||
post.setLatitude(request.getLatitude());
|
||||
@@ -410,4 +413,8 @@ public class PostService {
|
||||
|
||||
return toResponse(post, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static String normalizeAddress(String address) {
|
||||
return StringUtils.hasText(address) ? address.trim() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,9 @@ public class AdminPostService {
|
||||
if (StringUtils.hasText(category)) {
|
||||
post.setCategory(PostCategory.fromDisplayName(category));
|
||||
}
|
||||
if (StringUtils.hasText(address)) {
|
||||
post.setAddress(address.trim());
|
||||
}
|
||||
if (latitude != null && longitude != null) {
|
||||
post.setLatitude(latitude);
|
||||
post.setLongitude(longitude);
|
||||
@@ -303,6 +306,7 @@ public class AdminPostService {
|
||||
.category(post.getCategory() == null ? null : post.getCategory().getDisplayName())
|
||||
.city(post.getCity())
|
||||
.district(post.getDistrict())
|
||||
.address(post.getAddress())
|
||||
.latitude(post.getLatitude())
|
||||
.longitude(post.getLongitude())
|
||||
.phone(post.getPhone())
|
||||
|
||||
Reference in New Issue
Block a user