Implement score table functionality with ScoreTable, ScoreEntry, and ScoreTableService; add Timeframe and ScoreType enums; enhance User and StatsList models for better stats management
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
@@ -270,4 +271,45 @@ public class FriendshipService {
|
||||
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public record NameWithFriendship(
|
||||
Long id,
|
||||
String name,
|
||||
boolean friendship
|
||||
) {}
|
||||
|
||||
public List<NameWithFriendship> getPrivateNameIfFriendshipAccepted(User user, List<Long> otherUserIds) {
|
||||
List<NameWithFriendship> result = new ArrayList<>();
|
||||
|
||||
for (Long otherUserId : otherUserIds) {
|
||||
|
||||
Friendship friendship =
|
||||
friendshipRepository.findByUserIdAndFriendIdAndStatus(
|
||||
user.getId(),
|
||||
otherUserId,
|
||||
FriendShipStatus.ACCEPTED
|
||||
);
|
||||
|
||||
if (friendship != null) {
|
||||
User target = friendship.getFriend();
|
||||
result.add(new NameWithFriendship(
|
||||
target.getId(),
|
||||
target.getPrivateName(),
|
||||
true
|
||||
));
|
||||
} else {
|
||||
User target = userRepository.findById(otherUserId)
|
||||
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||
result.add(new NameWithFriendship(
|
||||
target.getId(),
|
||||
target.getPublicName(),
|
||||
false
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user