fixed web-socket and add rewards on post

This commit is contained in:
SlimusMinus
2026-08-12 00:41:31 +03:00
parent f3ba7e6512
commit 13ed934c60
12 changed files with 107 additions and 52 deletions

View File

@@ -64,6 +64,7 @@ public class PostService {
post.setCreatedAt(LocalDateTime.now());
post.setStatus(PostStatus.MODERATION);
post.setUser(currentUser);
post.setIsReward(request.getReward());
if (request.getLatitude() == null || request.getLongitude() == null) {
post.setCity(request.getAddress());
} else {
@@ -134,7 +135,7 @@ public class PostService {
*/
@Transactional
public PostResponse update(Long id, String type, String title, String address, Double latitude,
Double longitude, String description, String category, String phone, List<MultipartFile> images, String existingImagesJson) {
Double longitude, String description, String category, String phone, Boolean reward, List<MultipartFile> images, String existingImagesJson) {
PostRequest request = new PostRequest();
request.setType(PostType.from(type));
@@ -145,6 +146,7 @@ public class PostService {
request.setLatitude(latitude);
request.setLongitude(longitude);
request.setAddress(address);
request.setReward(reward);
List<String> existingUrls = parseExistingImages(existingImagesJson);
@@ -163,6 +165,7 @@ public class PostService {
}
post.setPhone(request.getPhone());
post.setType(request.getType());
post.setIsReward(request.getReward());
if (request.getLatitude() != null && request.getLongitude() != null) {
post.setLatitude(request.getLatitude());
@@ -361,6 +364,7 @@ public class PostService {
PostResponse response = mapper.toResponse(post);
response.setLikeCount(likeCounts.getOrDefault(post.getId(), 0L));
response.setFavorite(userFavoriteIds.contains(post.getId()));
response.setReward(post.getIsReward());
if (includeUserRole) {
response.setUserRole(post.getUser().getRole());
}