Skip to content

Commit

Permalink
feat/#294 : 메서드 네이밍 수정 및 spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
LJH098 committed Jun 8, 2024
1 parent 0dfb493 commit 0858520
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public class UpdateWeightEvent extends InfraEvent {
private LocalDateTime localDateTime;

public static UpdateWeightEvent from(Long memberId, String url, LocalDateTime localDateTime) {
return new UpdateWeightEvent(memberId,url,localDateTime);
return new UpdateWeightEvent(memberId, url, localDateTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ConnectEmitterService implements ConnectEmitterUseCase {
private final Long CONNECT_TIMEOUT = 1000L * 60 * 60;

@Override
public SseEmitter connect(final String memberId, final String lastEventId) {
public SseEmitter execute(final String memberId, final String lastEventId) {
String eventId = memberId + "_" + System.currentTimeMillis();
SseEmitter emitter = emitterRepository.save(eventId, new SseEmitter(CONNECT_TIMEOUT));
// 이벤트를 정상적으로 보냈을 때
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@Service
@RequiredArgsConstructor
public class sendEmitterService implements SendEmitterUseCase {
public class SendEmitterService implements SendEmitterUseCase {
private final EmitterRepository emitterRepository;
private final NotifyPort notifyPort;
private final NotifyConverter notifyConverter;
Expand Down Expand Up @@ -72,6 +72,6 @@ public void send(MemberEntity receiver, String content, String url, Notification
}

private Long splitEventIdToTime(String eventId) {
return Long.parseLong(eventId.split("_")[1]);
return Long.valueOf(eventId.split("_")[1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

@UseCase
public interface ConnectEmitterUseCase {
SseEmitter connect(final String memberId, final String lastEventId);
SseEmitter execute(final String memberId, final String lastEventId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.gaebaljip.exceed.member.adapter.in;

import com.gaebaljip.exceed.common.event.Events;
import com.gaebaljip.exceed.common.event.UpdateWeightEvent;
import java.time.LocalDateTime;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -10,6 +12,8 @@
import com.gaebaljip.exceed.common.ApiResponse;
import com.gaebaljip.exceed.common.ApiResponseGenerator;
import com.gaebaljip.exceed.common.annotation.AuthenticationMemberId;
import com.gaebaljip.exceed.common.event.Events;
import com.gaebaljip.exceed.common.event.UpdateWeightEvent;
import com.gaebaljip.exceed.dto.UpdateWeightRequest;
import com.gaebaljip.exceed.dto.UpdateWeightResponse;
import com.gaebaljip.exceed.member.application.UpdateWeightService;
Expand All @@ -20,9 +24,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1")
Expand All @@ -33,11 +34,16 @@ public class UpdateWeightController {

@Operation(summary = "회원 몸무게 및 목표 몸무게 수정", description = "회원 몸무게 및 목표 몸무게를 수정한다.")
@PatchMapping("/members/weight")
public ApiResponse<UpdateWeightResponse> updateWeight(HttpServletRequest servletRequest,
UpdateWeightRequest request, @AuthenticationMemberId Long memberId) {
UpdateWeightResponse response = updateWeightService.execute(
UpdateWeightCommand.of(request.weight(), request.targetWeight(), memberId));
Events.raise(UpdateWeightEvent.from(memberId,servletRequest.getRequestURI(), LocalDateTime.now()));
public ApiResponse<UpdateWeightResponse> updateWeight(
HttpServletRequest servletRequest,
UpdateWeightRequest request,
@AuthenticationMemberId Long memberId) {
UpdateWeightResponse response =
updateWeightService.execute(
UpdateWeightCommand.of(request.weight(), request.targetWeight(), memberId));
Events.raise(
UpdateWeightEvent.from(
memberId, servletRequest.getRequestURI(), LocalDateTime.now()));
return ApiResponseGenerator.success(response, HttpStatus.OK);
}
}

0 comments on commit 0858520

Please sign in to comment.