분류 전체보기(11)
-
JWT 그런데 OAuth2.0 곁들인
이전 2인 프로젝트 Sniff-Step [https://github.com/Minthug/Sniff-Step] 에서했던 JWT 구조와 다른 구조이며, OAuth2.0 또한 Kakao, Naver, Google 세 가지를 모두 사용할 수 있게 설정 했습니다.현 프로젝트를 해보고 있기 때문에 글을 작성했습니다.가장 큰 차이는 Record Class로 프로젝트의 구조에 큰 변화가 생겼다고 해야할까?저의 이해를 위해 쉽게 풀어서 글을 정리 해보겠습니다.Components:- TokenProvider: JWT 토큰 생성/검증 인터페이스 - JwtTokenProvider: 실제 JWT 토큰 처리 구현체 - JwtAuthenticationFilter: JWT 인증 필터 - JwtAuthenticationProv..
2024.11.08 -
SSE(Server-Sent Events)
SSE 개념서버 -> 클라이언트 단방향 실시간 통신WebSocket과 달리 서버에서 클라이언트로만 데이터를 보냄HTTP 프로토콜 사용으로 별도 프로토콜 필요 없음자동 재접속 지원Repository 구조Key-Value 구조Key(String): "memberId_timeStamp" // 예: "123_1698985544"Value: SseEmitter 객체public interface EmitterRepository { void save(String emitterId, SseEmitter sseEmitter); void deleteById(String emitterId); Map findAllByIdStartWith(Long memberId);}@Repositorypublic class..
2024.11.06 -
정적 팩토리 메서드 네이밍의 차이 (of vs from)
public record FindCouponsResponse(List coupons) { public static FindCouponsResponse from(final List coupons) { return coupons.stream() .map(FindCouponResponse::from) .collect(Collectors.collectingAndThen(Collectors.toList(), FindCouponsResponse::new)); } public record FindCouponResponse(Long couponId, String name, String description, Integer discount..
2024.11.04 -
QueryDSL 아이템 목록 페이징 처리
private Predicate getHavingCondition(Long lastIdx, Long lastItemId, ItemSortType itemSortType) { return switch (itemSortType) { case NEW -> item.id.lt(lastIdx); case HIGHEST_AMOUNT -> item.price.lt(lastIdx) .or(item.price.eq(lastIdx.intValue()).and(item.id.gt(lastItemId))); case LOWEST_AMOUNT -> item.price.gt(lastIdx) .or(item.price.eq(lastId..
2024.10.31 -
StringUtils 라이브러리
프로젝트를 하면서 StringUtils 라이브러리를 골라해야했는데이전에 프로젝트를 하면서는 lang3를 사용했지만이번엔 대체 해보고싶어서 Sprignframwork.util을 사용했다org.springframework.util.StringUtils;org.apache.commons.lang3.StringUtils;.isEmpty() 메서드를 써야했는데둘이 기능은 비슷하게 하고 있었다.물론 lang3가 조금 더 많은 메서드를 제공해준다 org.springframework.util.StringUtils:null이거나 길이가 0인 문자열일 경우 true를 반환합니다.공백 문자만 있는 문자열(예: " ")은 비어있지 않은 것으로 간주합니다.b) Apache Commons Lang의 org.apache.commo..
2024.10.29