Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: 회원 이미지 조회 기능 구현 #111

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading