Skip to content

Commit

Permalink
Merge pull request #111 from Gseungmin/main
Browse files Browse the repository at this point in the history
[feat]: 회원 이미지 조회 기능 구현
  • Loading branch information
Gseungmin authored Aug 16, 2023
2 parents 9560d03 + 9226b47 commit 8a5fc88
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/umc/refit/domain/dto/chat/OtherImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.umc.refit.domain.dto.chat;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
public class OtherImage {
private String otherImage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
, "/static/**" //카카오 주소 api
, "/*.html" //카카오 주소 api
, "/oauth2/fcm"
, "/oauth2/image"
, "/auth/join/name"
// , "/**" //임시로 모든 인증 처리 제외
).permitAll()
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/com/umc/refit/web/controller/OauthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.umc.refit.domain.dto.chat.FCM;
import com.umc.refit.domain.dto.chat.OAuth2;
import com.umc.refit.domain.dto.chat.OtherImage;
import com.umc.refit.domain.entity.Member;
import com.umc.refit.exception.ExceptionType;
import com.umc.refit.exception.member.TokenException;
Expand All @@ -10,6 +11,7 @@
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -44,9 +46,15 @@ public FCM getFcm(@RequestHeader("otherId") String otherId) throws UnsupportedEn
String decodedValue = URLDecoder.decode(otherId, "UTF-8");
Optional<Member> other = memberService.findMemberByName(decodedValue);

System.out.println("=====================================");
System.out.println(otherId);

return new FCM(other.get().getFcm());
}

@GetMapping("/oauth2/image")
public OtherImage getImage(@RequestParam("otherId") String otherId) throws UnsupportedEncodingException {

String decodedValue = URLDecoder.decode(otherId, "UTF-8");
Optional<Member> other = memberService.findMemberByName(decodedValue);

return new OtherImage(other.get().getImageUrl());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected boolean shouldNotFilter(HttpServletRequest request) {
|| pathMatcher.match("/auth/login", path) //일반 로그인
|| pathMatcher.match("/*.html", path)
|| pathMatcher.match("/oauth2/fcm", path)
|| pathMatcher.match("/oauth2/image", path)
|| pathMatcher.match("/auth/join/name", path)
// || pathMatcher.match("/**", path) //API 테스트를 위해 모든 로직에 대해 인가 제외
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spring:

jpa:
hibernate:
ddl-auto: create
ddl-auto: update

properties:
hibernate:
Expand Down

0 comments on commit 8a5fc88

Please sign in to comment.