From c6e04f6860c8ac188d76ee9ee7e33c2c3dce55a6 Mon Sep 17 00:00:00 2001 From: KinTrae Date: Thu, 9 Jan 2025 21:27:14 +0100 Subject: [PATCH] feature: temp-for rebasing task: XXX --- .../controllers/ProfileController.java | 39 +++++++++++++++++++ .../backend/profiles/dtos/ProfileDto.java | 12 ++++++ .../ProfilePictureRepository.java | 2 +- .../repositories/ProfileRepository.java | 2 +- .../profiles/services/ProfileService.java | 14 +++++++ .../services/impl/ProfileServiceImpl.java | 32 +++++++++++++++ .../repositories/ProfileDataRepository.java | 7 ---- .../ProfileUserDataRepository.java | 7 ---- .../meowhub/backend/InitDataTestConfig.java | 30 +------------- 9 files changed, 101 insertions(+), 44 deletions(-) create mode 100644 backend/src/main/java/meowhub/backend/profiles/controllers/ProfileController.java create mode 100644 backend/src/main/java/meowhub/backend/profiles/dtos/ProfileDto.java rename backend/src/main/java/meowhub/backend/{ => profiles}/repositories/ProfilePictureRepository.java (81%) rename backend/src/main/java/meowhub/backend/{ => profiles}/repositories/ProfileRepository.java (79%) create mode 100644 backend/src/main/java/meowhub/backend/profiles/services/ProfileService.java create mode 100644 backend/src/main/java/meowhub/backend/profiles/services/impl/ProfileServiceImpl.java delete mode 100644 backend/src/main/java/meowhub/backend/repositories/ProfileDataRepository.java delete mode 100644 backend/src/main/java/meowhub/backend/repositories/ProfileUserDataRepository.java diff --git a/backend/src/main/java/meowhub/backend/profiles/controllers/ProfileController.java b/backend/src/main/java/meowhub/backend/profiles/controllers/ProfileController.java new file mode 100644 index 0000000..2629b9b --- /dev/null +++ b/backend/src/main/java/meowhub/backend/profiles/controllers/ProfileController.java @@ -0,0 +1,39 @@ +package meowhub.backend.profiles.controllers; + +import lombok.RequiredArgsConstructor; +import meowhub.backend.profiles.dtos.ProfileDto; +import meowhub.backend.profiles.services.ProfileService; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@RestController +@RequestMapping(path ="/api/profiles") +@RequiredArgsConstructor +public class ProfileController { + private final ProfileService profileService; + + @GetMapping("/{login}") + public ProfileDto getProfile(@PathVariable String login, @AuthenticationPrincipal UserDetails userDetails) { + return profileService.getProfile(login, userDetails.getUsername()); + } + + @PostMapping("") + public ProfileDto updateProfile(@RequestParam String content, @AuthenticationPrincipal UserDetails userDetails) { + return profileService.updateProfile(content, userDetails.getUsername()); + } + + @PostMapping("/pictures") + public ProfileDto addPictures(@RequestPart List files, @AuthenticationPrincipal UserDetails userDetails) { + return profileService.addPictures(files, userDetails.getUsername()); + } +} diff --git a/backend/src/main/java/meowhub/backend/profiles/dtos/ProfileDto.java b/backend/src/main/java/meowhub/backend/profiles/dtos/ProfileDto.java new file mode 100644 index 0000000..dd08188 --- /dev/null +++ b/backend/src/main/java/meowhub/backend/profiles/dtos/ProfileDto.java @@ -0,0 +1,12 @@ +package meowhub.backend.profiles.dtos; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ProfileDto { + private String profilePicture; + private String content; + +} diff --git a/backend/src/main/java/meowhub/backend/repositories/ProfilePictureRepository.java b/backend/src/main/java/meowhub/backend/profiles/repositories/ProfilePictureRepository.java similarity index 81% rename from backend/src/main/java/meowhub/backend/repositories/ProfilePictureRepository.java rename to backend/src/main/java/meowhub/backend/profiles/repositories/ProfilePictureRepository.java index 48b5c0b..afc8320 100644 --- a/backend/src/main/java/meowhub/backend/repositories/ProfilePictureRepository.java +++ b/backend/src/main/java/meowhub/backend/profiles/repositories/ProfilePictureRepository.java @@ -1,4 +1,4 @@ -package meowhub.backend.repositories; +package meowhub.backend.profiles.repositories; import meowhub.backend.jpa_buddy.ProfilePicture; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/backend/src/main/java/meowhub/backend/repositories/ProfileRepository.java b/backend/src/main/java/meowhub/backend/profiles/repositories/ProfileRepository.java similarity index 79% rename from backend/src/main/java/meowhub/backend/repositories/ProfileRepository.java rename to backend/src/main/java/meowhub/backend/profiles/repositories/ProfileRepository.java index 3774d1a..d1a042f 100644 --- a/backend/src/main/java/meowhub/backend/repositories/ProfileRepository.java +++ b/backend/src/main/java/meowhub/backend/profiles/repositories/ProfileRepository.java @@ -1,4 +1,4 @@ -package meowhub.backend.repositories; +package meowhub.backend.profiles.repositories; import meowhub.backend.jpa_buddy.Profile; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/backend/src/main/java/meowhub/backend/profiles/services/ProfileService.java b/backend/src/main/java/meowhub/backend/profiles/services/ProfileService.java new file mode 100644 index 0000000..b7a4149 --- /dev/null +++ b/backend/src/main/java/meowhub/backend/profiles/services/ProfileService.java @@ -0,0 +1,14 @@ +package meowhub.backend.profiles.services; + +import meowhub.backend.profiles.dtos.ProfileDto; +import meowhub.backend.security.requests.SignUpRequest; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +public interface ProfileService { + void createProfile(SignUpRequest signUpRequest); + ProfileDto updateProfile(String content, String login); + ProfileDto getProfile(String login, String requesterLogin); + ProfileDto addPictures(List file, String login); +} diff --git a/backend/src/main/java/meowhub/backend/profiles/services/impl/ProfileServiceImpl.java b/backend/src/main/java/meowhub/backend/profiles/services/impl/ProfileServiceImpl.java new file mode 100644 index 0000000..e64ad3c --- /dev/null +++ b/backend/src/main/java/meowhub/backend/profiles/services/impl/ProfileServiceImpl.java @@ -0,0 +1,32 @@ +package meowhub.backend.profiles.services.impl; + +import meowhub.backend.profiles.dtos.ProfileDto; +import meowhub.backend.profiles.services.ProfileService; +import meowhub.backend.security.requests.SignUpRequest; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@Service +public class ProfileServiceImpl implements ProfileService { + @Override + public void createProfile(SignUpRequest signUpRequest) { + + } + + @Override + public ProfileDto updateProfile(String content, String login) { + return null; + } + + @Override + public ProfileDto getProfile(String login, String requesterLogin) { + return null; + } + + @Override + public ProfileDto addPictures(List file, String login) { + return null; + } +} diff --git a/backend/src/main/java/meowhub/backend/repositories/ProfileDataRepository.java b/backend/src/main/java/meowhub/backend/repositories/ProfileDataRepository.java deleted file mode 100644 index f6232c4..0000000 --- a/backend/src/main/java/meowhub/backend/repositories/ProfileDataRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package meowhub.backend.repositories; - -import meowhub.backend.jpa_buddy.ProfileData; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface ProfileDataRepository extends JpaRepository { -} \ No newline at end of file diff --git a/backend/src/main/java/meowhub/backend/repositories/ProfileUserDataRepository.java b/backend/src/main/java/meowhub/backend/repositories/ProfileUserDataRepository.java deleted file mode 100644 index d74d11e..0000000 --- a/backend/src/main/java/meowhub/backend/repositories/ProfileUserDataRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package meowhub.backend.repositories; - -import meowhub.backend.jpa_buddy.ProfileUserData; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface ProfileUserDataRepository extends JpaRepository { -} \ No newline at end of file diff --git a/backend/src/test/java/meowhub/backend/InitDataTestConfig.java b/backend/src/test/java/meowhub/backend/InitDataTestConfig.java index 3f05f42..734cd0a 100644 --- a/backend/src/test/java/meowhub/backend/InitDataTestConfig.java +++ b/backend/src/test/java/meowhub/backend/InitDataTestConfig.java @@ -16,10 +16,8 @@ import meowhub.backend.user_relations.models.UserRelation; import meowhub.backend.posts.repositories.CommentRepository; import meowhub.backend.posts.repositories.PostRepository; -import meowhub.backend.repositories.ProfileDataRepository; -import meowhub.backend.repositories.ProfilePictureRepository; -import meowhub.backend.repositories.ProfileRepository; -import meowhub.backend.repositories.ProfileUserDataRepository; +import meowhub.backend.profiles.repositories.ProfilePictureRepository; +import meowhub.backend.profiles.repositories.ProfileRepository; import meowhub.backend.user_relations.repositories.RelationTypeRepository; import meowhub.backend.user_relations.repositories.UserRelationRepository; import meowhub.backend.users.models.Gender; @@ -64,10 +62,6 @@ public class InitDataTestConfig { private UserRelationRepository userRelationRepository; @Autowired private CommentRepository commentRepository; - @Autowired - private ProfileUserDataRepository profileUserDataRepository; - @Autowired - private ProfileDataRepository profileDataRepository; private User user1; private User user2; @@ -196,26 +190,6 @@ private void initProfiles() { profilePicture.setPicture(picture); profilePicture.setIndex(0L); profilePictureRepository.save(profilePicture); - - ProfileData profileDataBirthPlace = new ProfileData(); - profileDataBirthPlace.setCode("Urodzony w: "); - profileDataRepository.save(profileDataBirthPlace); - - ProfileData profileDataRelationshipStatus = new ProfileData(); - profileDataRelationshipStatus.setCode("W relacji: "); - profileDataRepository.save(profileDataRelationshipStatus); - - ProfileUserData profileUserDataBirthPlace = new ProfileUserData(); - profileUserDataBirthPlace.setProfile(profile); - profileUserDataBirthPlace.setProfileData(profileDataBirthPlace); - profileUserDataBirthPlace.setContent("Warszawa"); - profileUserDataRepository.save(profileUserDataBirthPlace); - - ProfileUserData profileUserDataRelationshipStatus = new ProfileUserData(); - profileUserDataRelationshipStatus.setProfile(profile); - profileUserDataRelationshipStatus.setProfileData(profileDataBirthPlace); - profileUserDataRelationshipStatus.setContent("Wolny"); - profileUserDataRepository.save(profileUserDataRelationshipStatus); } private void initUserRelations() {