전체 글

개발자 이우진의 기술 블로그입니다
요약Spring Web은 HTTP Request Parameter(?property=vale)를 개발자가 정의한 클래스 객체로 바인딩하기 위해서 생성자, getter, setter 메소드를 호출한다배경Request Param 클래스를 만들다가 페이지네이션을 할 때 쓰는 속성 page와 size를 인터페이스화 해서 api에서 공통으로 관리하면 좋겠다는 생각을 했다./** * 목록 조회 API - 페이지네이션 기능을 사용할 때 쓰는 Request Param 속성. */public interface PaginationRequestParam { /** * 페이지 번호 */ Integer getPage(); /** * 페이지 당 데이터 수 */ Integer ge..
요약String -> Enum converter 인터페이스를 구현하고 추가한다enum class에는 String -> Enum 형태의 팩토리 메서드를 추가한다 (.of()) 출처https://www.baeldung.com/spring-enum-request-param Using Enums as Request Parameters in Spring | BaeldungLearn how to use enums as request parameters in Spring REST controllers and how to handle exceptions triggered by invalid input.www.baeldung.com
정리JPA의 메소드 deleteBy는 삭제되는 엔티티 개수만큼의 DELETE 문으로 실행횐다이는 성능 저하의 원인이 될 수 있다SELECT로 조건에 맞는 엔티티를 조회하고, id 조건으로 하나씩 삭제한다해결법@Query로 직접 JPQL 쿼리를 생성한다지금 프로젝트에서는 더 편하게 QueryDsl custom repository를 사용했다@Repository@RequiredArgsConstructorpublic class HabitAlertRepositoryCustomImpl implements HabitAlertRepositoryCustom { private final JPAQueryFactory queryFactory; @Override public void deleteByRunHabi..
· misc
요약Skip list와 Hash table이 포함된 dual ported 자료구조시간 복잡도Skip List를 써서 ZRANGE의 시간 복잡도는 O(log(n) + m) 이다. 시작하는 값을 log(n) 시간에 찾고, 찾는 노드 개수 m만큼 추가로 탐색하기 때문이다.대대수 연산의 시간 복잡도는 log(n)이다. Skip List이기 때문으로 추정된다Hash table은 왜 쓰는가?The hash table provides fast access to elements based on their value, while the skip list maintains the sorted order of the elements based on their scores.hash table은 value로 요소 접근, ski..
상황UserDto.unlockingConstellation을 매핑할 때 UserConstellationMapper.toDto(UserConstellation)를 사용해서 매핑하려고 한다. 자동으로 생성된 코드에서는 UserDto.unlockingConstellation.constellation까지 .get()하여 의도하지 않은 SELECT가 발생하기 때문이다.public class UserDto {.../** * 현재 해금중인 유저 별자리 상태 */ private UserConstellationDto unlockingConstellation;}@Mapper(componentModel = "spring", uses={UserConstellationMapper.class})public i..
Jira의 REST API 문서를 읽고 얻은 인사이트를 공유합니다유저가 소유한 리소스 - /users/me/resources vs /resources유저가 소유한 리소스를 나타내는 REST API URI를 설계할 때 원칙에 따른다면/resources: 현재 로그인한 유저와 관계 없는 전체 리소스/users/me/resources: 현재 로그인한 유저가 소유한 리소스이렇게 명명을 해야할 것 같다.그러나 현실적으로 Jira 처럼 로그인해서 쓰는 애플리케이션은 내 데이터만 볼 수 있는 경우가 많고, 그렇다면 대부분의 api가 /users/me 하위에 위치하게 되어 리소스 분류가 안 되어 좋은 설계는 아닌 것 같다는 생각이 들었다. 그래서 Jira는 어떻게 하는 지 찾아 봤다.예시: /rest/api/3/das..
· misc
Bitbucket REST API: GET /user/{userSlug}With own resourceExamples:JIRA REST API: GET /myselfGitHub REST API: GET /userStack Exchange REST API: GET /meThis solution has one resource for users and one additional resource for logged in user.With symbolic linkExample:Confluence REST API: GET /user/currentThis solution has a symbolic link for the ID of the user.With filterExample:JIRA REST API: GET /..
요약요청은 올바르지만 요청을 처리할 수 없을 때 사용한다ex) 엔티티의 생성 가능한 최대 개수 초과https://stackoverflow.com/questions/51990143/400-vs-422-for-client-error-request 400 vs 422 for Client Error RequestI've read a lot of posts and articles regarding proper http status code to return for client request error. Others suggest to use 400 as it has been redefined in RFC 7231 though I'm not sure if thestackoverflow.comhttps://devel..