Skip to content

Commit

Permalink
feature: temp-for rebasing
Browse files Browse the repository at this point in the history
task:  XXX
  • Loading branch information
KinTrae committed Jan 9, 2025
1 parent 6bf5663 commit c6e04f6
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -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<MultipartFile> files, @AuthenticationPrincipal UserDetails userDetails) {
return profileService.addPictures(files, userDetails.getUsername());
}
}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MultipartFile> file, String login);
}
Original file line number Diff line number Diff line change
@@ -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<MultipartFile> file, String login) {
return null;
}
}

This file was deleted.

This file was deleted.

30 changes: 2 additions & 28 deletions backend/src/test/java/meowhub/backend/InitDataTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit c6e04f6

Please sign in to comment.