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

[#37] 사용자 온/오프라인 상태 설정 #38

Merged
merged 11 commits into from
Feb 14, 2024
Merged

Conversation

jzakka
Copy link
Collaborator

@jzakka jzakka commented Feb 12, 2024

  • 로그인하면 자동으로 온라인상태, 로그아웃하면 자동으로 오프라인 상태
  • memberService.setOnline(), memberService.setoffline() 추가
  • loginsuccesshandler, logoutsucceesshandler가 위 메서드를 호출.
  • 로그인한 사용자가 직접 설정할 수도 있음
  • 온라인 상태가되면 레디스에 key=online:member, value=�멤버아이디가 저장됨.
  • 사용자 위도 경도가 있는 경우 key=member:pos, value=멤버아이디가 redis geo operation으로 저장됨
  • 위도,경도는 나중에 주변 사용자 검색기능 구현하기 위해 저장

그 외 변경점

  • feed와 graphicContent의 단방향 1:N를 양방향으로 수정
    • graphicConent의 feed_id는 notnull인데, feed를 저장하려 하면 하이버네이트가 이상하게 작동
    • feed저장 -> graphicContent에 feed_id 설정해서 저장 이렇게 하면 되는데 feed저장 -> graphicContent에 feed_id를 null로 설정하고 저장 -> graphicContent의 feed_id를 업데이트이런식으로 동작함. 그래서 notnull constraints때문에 에러.
    • graphicContent에 feed를 ManyToOne으로 가지는 대신 외부에서 참조 못하도록 막음

@jzakka jzakka added the enhancement New feature or request label Feb 12, 2024
@jzakka jzakka requested a review from f-lab-moony February 12, 2024 08:35
@jzakka jzakka self-assigned this Feb 12, 2024
Copy link

Copy link
Collaborator

@f-lab-moony f-lab-moony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니다!
온오프라인 상태 설정하는 부분에선 딱히 피드백드릴 내용이 없네요 바로 머지하도록 하겠습니다 ~

.requestMatchers(new MvcRequestMatcher.Builder(introspector).pattern(HttpMethod.GET, "/rank/**")).permitAll()
.requestMatchers(new MvcRequestMatcher.Builder(introspector).pattern(HttpMethod.GET, "/diaries/**")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/login")).permitAll()
.requestMatchers(new AntPathRequestMatcher("/members", "POST")).permitAll()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드 타입같은거 문자열로 다루게 되면 실수 할 여지가 생겨서 원래처럼 enum 값을 받을 수 있게 메서드를 하나 제공하는건 어떨까요 ?

Double longitude = Optional.ofNullable(request.getParameter("longitude"))
.map(Double::parseDouble).orElse(null);
memberService.setOnline(memberId, latitude, longitude);
response.setStatus(200);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200도 HttpStatus 사용하면 좋을 것 같아요 ~

@f-lab-moony f-lab-moony merged commit d7f76ae into main Feb 14, 2024
2 checks passed
@jzakka jzakka deleted the feature/37 branch February 15, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants