Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.run_us.server.domains.running.live.service.usecase.CreateLiveRunningUseCase;
import com.run_us.server.global.common.SuccessResponse;
import com.run_us.server.global.security.annotation.CurrentUser;
import com.run_us.server.global.security.principal.UserPrincipal;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand All @@ -22,9 +21,9 @@ public class LiveRunningController {
@PostMapping()
public ResponseEntity<SuccessResponse<LiveRunningCreateResponse>> createLiveRunning(
@RequestParam("runPublicId") String runPublicId,
@CurrentUser UserPrincipal userPrincipal) {
@CurrentUser String currentUserPublicId) {
SuccessResponse<LiveRunningCreateResponse> response =
createLiveRunningUseCase.createLiveRunning(runPublicId, userPrincipal.getInternalId());
createLiveRunningUseCase.createLiveRunning(runPublicId, currentUserPublicId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import com.run_us.server.global.common.SuccessResponse;

public interface CreateLiveRunningUseCase {
SuccessResponse<LiveRunningCreateResponse> createLiveRunning(String runPublicId, Integer userId);
SuccessResponse<LiveRunningCreateResponse> createLiveRunning(String runPublicId, String userPublicId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.run_us.server.domains.running.run.service.RunQueryService;
import com.run_us.server.domains.running.run.service.RunValidator;
import com.run_us.server.domains.running.run.service.model.ParticipantInfo;
import com.run_us.server.domains.user.domain.UserPrincipal;
import com.run_us.server.domains.user.service.resolver.UserIdResolver;
import com.run_us.server.global.common.SuccessResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -23,15 +25,17 @@ public class CreateLiveRunningUseCaseImpl implements CreateLiveRunningUseCase {
private final RunValidator runValidator;
private final ParticipantService participantService;
private final PassCodeRegistry passCodeRegistry;
private final UserIdResolver userIdResolver;

@Override
@Transactional
public SuccessResponse<LiveRunningCreateResponse> createLiveRunning(String runPublicId, Integer userId) {
public SuccessResponse<LiveRunningCreateResponse> createLiveRunning(String runPublicId, String userPublicId) {
UserPrincipal UserPrincipal = userIdResolver.resolve(userPublicId);
Run selectedRun = runQueryService.findByRunPublicId(runPublicId);
runValidator.validateCurrentUserCanStartRun(userId, selectedRun);
participantService.joinLiveRunning(userId, selectedRun);
runValidator.validateCurrentUserCanStartRun(UserPrincipal.getInternalId(), selectedRun);
participantService.joinLiveRunning(UserPrincipal.getInternalId(), selectedRun);
String passcode = passCodeRegistry.generateAndGetPassCode(runPublicId);
selectedRun.openLiveSession(userId);
selectedRun.openLiveSession(UserPrincipal.getInternalId());
List<ParticipantInfo> participantInfos = participantService.getParticipants(selectedRun);
return SuccessResponse.of(RunningHttpResponseCode.LIVE_ROOM_CREATED, LiveRunningCreateResponse.from(selectedRun, passcode, participantInfos));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.run_us.server.global.common.cache.InMemoryCache;
import com.run_us.server.global.common.cache.SpringInMemoryCache;
import com.run_us.server.domains.user.domain.TokenStatus;
import com.run_us.server.global.common.resolver.DomainPrincipal;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Loading