-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: XXX
- Loading branch information
Showing
26 changed files
with
197 additions
and
350 deletions.
There are no files selected for viewing
52 changes: 0 additions & 52 deletions
52
backend/src/main/java/meowhub/backend/jpa_buddy/ProfileData.java
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
backend/src/main/java/meowhub/backend/jpa_buddy/ProfileUserData.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
backend/src/main/java/meowhub/backend/profiles/dtos/ProfileDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package meowhub.backend.profiles.dtos; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class ProfileDto { | ||
private String profilePicture; | ||
private String content; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
backend/src/main/java/meowhub/backend/profiles/repositories/ProfilePictureRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package meowhub.backend.profiles.repositories; | ||
|
||
import meowhub.backend.jpa_buddy.ProfilePicture; | ||
import meowhub.backend.profiles.models.ProfilePicture; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ProfilePictureRepository extends JpaRepository<ProfilePicture, String> { | ||
Optional<ProfilePicture> findByProfileIdAndCurrentProfilePicture(String profileId, boolean currentProfilePicture); | ||
} |
43 changes: 42 additions & 1 deletion
43
backend/src/main/java/meowhub/backend/profiles/repositories/ProfileRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
package meowhub.backend.profiles.repositories; | ||
|
||
import meowhub.backend.jpa_buddy.Profile; | ||
import meowhub.backend.profiles.dtos.ProfileDto; | ||
import meowhub.backend.profiles.models.Profile; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ProfileRepository extends JpaRepository<Profile, String> { | ||
|
||
@Query(""" | ||
SELECT new meowhub.backend.profiles.dtos.ProfileDto(pp.ociUrl, p.profileDetailsHtml) | ||
FROM Profile p | ||
LEFT JOIN ProfilePicture pp ON pp.profile.id = p.id AND pp.isCurrentProfilePicture = true | ||
WHERE p.user.login = :login | ||
""") | ||
ProfileDto getOwnProfile(@Param("login") String login); | ||
|
||
@Query(""" | ||
SELECT new meowhub.backend.profiles.dtos.ProfileDto(pp.ociUrl, p.profileDetailsHtml) | ||
FROM Profile p | ||
LEFT JOIN ProfilePicture pp ON pp.profile.id = p.id AND pp.isCurrentProfilePicture = true | ||
JOIN User u ON u.id = p.user.id | ||
JOIN u.profilePrivacy profilePrivacy | ||
WHERE u.login = :login | ||
AND (profilePrivacy.code = 'PUBLIC' | ||
OR (profilePrivacy.code = 'FRIENDS_ONLY' AND u.id IN ( | ||
SELECT r.receiver.id | ||
FROM User sender | ||
JOIN sender.userRelationsSender r | ||
JOIN r.relationType relType | ||
WHERE relType.code = 'FRIENDS' | ||
AND sender.login = :requestedBy | ||
UNION | ||
SELECT r.sender.id | ||
FROM User receiver | ||
JOIN receiver.userRelationsReceiver r | ||
JOIN r.relationType relType | ||
WHERE relType.code = 'FRIENDS' | ||
AND receiver.login = :requestedBy) | ||
)) ORDER BY p.createdAt DESC | ||
""") | ||
ProfileDto getProfileIfPublicOrFriends(@Param("login") String login, @Param("requestedBy") String requestedBy); | ||
|
||
Optional<Profile> findByUserLogin(String login); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...end/src/main/java/meowhub/backend/profiles/services/facades/ProfileAuthServiceFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package meowhub.backend.profiles.services.facades; | ||
|
||
import meowhub.backend.security.requests.SignUpRequest; | ||
|
||
public interface ProfileAuthServiceFacade { | ||
void createProfile(SignUpRequest signUpRequest); | ||
} |
17 changes: 17 additions & 0 deletions
17
...src/main/java/meowhub/backend/profiles/services/facades/ProfileAuthServiceFacadeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package meowhub.backend.profiles.services.facades; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import meowhub.backend.profiles.services.ProfileService; | ||
import meowhub.backend.security.requests.SignUpRequest; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ProfileAuthServiceFacadeImpl implements ProfileAuthServiceFacade { | ||
private final ProfileService profileService; | ||
|
||
@Override | ||
public void createProfile(SignUpRequest signUpRequest) { | ||
profileService.createProfile(signUpRequest); | ||
} | ||
} |
Oops, something went wrong.