TIL

220615 TIL

Vince_rf 2022. 6. 17. 19:58

# HashMap 과 ResponseEntity

https://hyeonic.tistory.com/197

# For each

for(Comment comment : comments){
            CommentResponseDto commentResponseDto = new CommentResponseDto(
                    comment.getId(),
                    comment.getUser().getNickname(),
                    comment.getComment(),
                    comment.getCreatedAt()
            );

for문을 줄여서 저렇게 씀

# @Jsonignore
DB에 안 올라가게 하는 어노테이션
무한참조에 관련된 어노테이션이다.

@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")

# Time스탬프 로컬 시간 설정
spring.jpa.properties.hibernate.jdbc.time_zone = [ 사용할 시간의 지역 ]

spring.jpa.properties.hibernate.jdbc.time_zone = Asia/Seoul

위의 코드가 안 먹히면 
( 9시간이 차이나기 때문에 )

spring.jpa.properties.hibernate.jdbc.time_zone = +09:00

# 회원가입시에 바디에 회원정보 내려주기

1. SignupResponseDto 만들어주기
@Getter
public class SignupResponseDto {
    private String username;
    private String nickname;
    private String profileUrl;
    private String message;

    public SignupResponseDto(String username, String nickname, String profileUrl, String message) {
        this.username = username;
        this.nickname = nickname;
        this.profileUrl = profileUrl;
        this.message = message;
    }
2. UserSerivce에 회원가입 메서드 내부에 리스트 만들어주고 리스트 채워주기
(SignupResponseDto를 리스트로 만든다)
SignupResponseDto signResponseDto = new SignupResponseDto(
                requestDto.getUsername(), requestDto.getNickname(), requestDto.getProfileUrl(), "회원가입 성공");
        List<SignupResponseDto> signupResponseDtoList = new ArrayList<>();
        signupResponseDtoList.add(signResponseDto);

3. return값 손보기

return new ResponseEntity(signupResponseDtoList, HttpStatus.OK);

'TIL' 카테고리의 다른 글

220620 WIL  (0) 2022.06.19
220616 TIL  (0) 2022.06.17
220614 TIL  (0) 2022.06.17
220616 미니프로젝트 트러블슈팅 TIL  (0) 2022.06.16
220613 TIL  (0) 2022.06.14