Skip to content

Commit

Permalink
Merge pull request #111 from KAKAO-TOUR-API-CONTEST/devyj
Browse files Browse the repository at this point in the history
fix : 프로필변경 수정
  • Loading branch information
yyujin1231 authored Sep 29, 2024
2 parents 86461c3 + 6fce2fe commit c0c3675
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
27 changes: 23 additions & 4 deletions src/main/java/com/example/ai_jeju/controller/MyJejuController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.example.ai_jeju.util.ResponseDto;
import com.example.ai_jeju.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -95,12 +96,30 @@ public ResponseDto myPageAddChild(@RequestHeader("Authorization") String token,

// 마이제주 : 마이페이지 프로필 이미지 변경
@PutMapping("/myjeju/mypage/profileimg")
public ResponseEntity<String> updateProfileImage(@RequestParam Long userId, @RequestBody Map<String, String> request) {
String profileimg = request.get("profileimg");
myJejuService.updateProfile(userId, profileimg);
return ResponseEntity.ok("success");
public ResponseEntity<String> updateProfileImage(@RequestHeader("Authorization") String token, @RequestBody Map<String, String> request) {
// JWT 토큰에서 "Bearer "를 제거하여 순수한 토큰 값만 추출
String accessToken = token.replace("Bearer ", "");

// 토큰이 유효한지 확인
if (tokenProvider.validToken(accessToken)) {
// 유효한 토큰에서 userId 추출
Long userId = tokenProvider.getUserId(accessToken);

// 요청 바디에서 프로필 이미지 URL 추출
String profileimg = request.get("profileimg");

// 서비스 메서드를 호출하여 프로필 이미지 업데이트
myJejuService.updateProfile(userId, profileimg);

// 성공 메시지 반환
return ResponseEntity.ok("success");
} else {
// 유효하지 않은 토큰일 경우 401 Unauthorized 반환
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("유효하지않은토큰");
}
}


// 마이제주 : 마이페이지 프로필 이미지 삭제
@DeleteMapping("/myjeju/mypage/profileimg")
public ResponseEntity<String> deleteProfileImage(@RequestParam Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ ResponseDto getSpecialRcmd(@RequestHeader(value = "Authorization", required = fa
}
}

}


}
10 changes: 10 additions & 0 deletions src/main/java/com/example/ai_jeju/service/MainVIewService.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,19 @@ public List<MainListResponse> getMainList(Long userId){
public List<MainListResponse> getMainList(){

List<Store> storeList= storeRepository.findAllOrderByRandomNative();

System.out.println("Store List Size: " + storeList.size()); // 로그 확인
//Optional<User> user = userRepository.findById(userId);
List<MainListResponse> mainListResponses= new ArrayList<>();

for (Store store : storeList) {
if (store == null) {
System.out.println("Store is null");
} else {
System.out.println("Store ID: " + store.getStoreId());
}
}

for(Store store : storeList){

List<Bookmark> bmks = bookmarkRepository.findByStoreId(store.getStoreId());
Expand Down

0 comments on commit c0c3675

Please sign in to comment.