Skip to content

Commit

Permalink
rename: registerProject에서 commissionProject로 변경 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
scv1702 authored Jul 30, 2024
1 parent 1eea903 commit 131ac5b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package es.princip.getp.domain.project.command.application;

import es.princip.getp.domain.client.command.domain.ClientRepository;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.application.command.CommissionProjectCommand;
import es.princip.getp.domain.project.command.domain.Project;
import es.princip.getp.domain.project.command.domain.ProjectCommissioner;
import es.princip.getp.domain.project.command.domain.ProjectData;
import es.princip.getp.domain.project.command.domain.ProjectRegister;
import es.princip.getp.domain.project.command.domain.ProjectRepository;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
Expand All @@ -14,20 +14,20 @@
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class ProjectService {
public class ProjectCommissionService {

private final ProjectDataMapper projectDataMapper;
private final ClientRepository clientRepository;
private final ProjectRepository projectRepository;
private final ProjectRegister projectRegister;
private final ProjectCommissioner projectCommissioner;

@Transactional
public Long registerProject(final RegisterProjectCommand command) {
public Long commissionProject(final CommissionProjectCommand command) {
final Long clientId = clientRepository.findByMemberId(command.memberId())
.orElseThrow(() -> new EntityNotFoundException("해당 의뢰자가 존재하지 않습니다."))
.getClientId();
final ProjectData data = projectDataMapper.mapToData(clientId, command);
final Project project = projectRegister.registerProject(data);
final Project project = projectCommissioner.commissionProject(data);
projectRepository.save(project);
return project.getProjectId();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package es.princip.getp.domain.project.command.application;

import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.application.command.CommissionProjectCommand;
import es.princip.getp.domain.project.command.domain.ProjectData;
import org.mapstruct.Mapper;

@Mapper(componentModel = "spring")
public interface ProjectDataMapper {

ProjectData mapToData(Long clientId, RegisterProjectCommand command);
ProjectData mapToData(Long clientId, CommissionProjectCommand command);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.List;

public record RegisterProjectCommand(
public record CommissionProjectCommand(
Long memberId,
String title,
Long payment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

@Component
@RequiredArgsConstructor
public class ProjectRegister {
public class ProjectCommissioner {

private final ClockHolder clockHolder;

public Project registerProject(final ProjectData data) {
public Project commissionProject(final ProjectData data) {
final Clock clock = clockHolder.getClock();
final Duration applicationDuration = data.applicationDuration();
final Duration estimatedDuration = data.estimatedDuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import es.princip.getp.domain.common.infra.HashtagMapper;
import es.princip.getp.domain.common.infra.URLMapper;
import es.princip.getp.domain.project.command.application.command.ApplyProjectCommand;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.application.command.CommissionProjectCommand;
import es.princip.getp.domain.project.command.domain.AttachmentFile;
import es.princip.getp.domain.project.command.presentation.dto.request.ApplyProjectRequest;
import es.princip.getp.domain.project.command.presentation.dto.request.CommissionProjectRequest;
Expand All @@ -17,5 +17,5 @@ public interface ProjectCommandMapper {

AttachmentFile mapToAttachmentFile(URL url);

RegisterProjectCommand mapToCommand(Long memberId, CommissionProjectRequest request);
CommissionProjectCommand mapToCommand(Long memberId, CommissionProjectRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package es.princip.getp.domain.project.command.presentation;

import es.princip.getp.domain.project.command.application.ProjectService;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.application.ProjectCommissionService;
import es.princip.getp.domain.project.command.application.command.CommissionProjectCommand;
import es.princip.getp.domain.project.command.presentation.dto.request.CommissionProjectRequest;
import es.princip.getp.domain.project.command.presentation.dto.response.RegisterProjectResponse;
import es.princip.getp.domain.project.command.presentation.dto.response.CommissionProjectResponse;
import es.princip.getp.infra.dto.response.ApiResponse;
import es.princip.getp.infra.dto.response.ApiResponse.ApiSuccessResult;
import es.princip.getp.infra.security.details.PrincipalDetails;
Expand All @@ -24,7 +24,7 @@
public class ProjectCommissionController {

private final ProjectCommandMapper projectCommandMapper;
private final ProjectService projectService;
private final ProjectCommissionService projectCommissionService;

/**
* 프로젝트 의뢰
Expand All @@ -34,14 +34,14 @@ public class ProjectCommissionController {
*/
@PostMapping
@PreAuthorize("hasRole('CLIENT') and isAuthenticated()")
public ResponseEntity<ApiSuccessResult<RegisterProjectResponse>> commissionProject(
public ResponseEntity<ApiSuccessResult<CommissionProjectResponse>> commissionProject(
@RequestBody @Valid final CommissionProjectRequest request,
@AuthenticationPrincipal final PrincipalDetails principalDetails
) {
final Long memberId = principalDetails.getMember().getMemberId();
final RegisterProjectCommand command = projectCommandMapper.mapToCommand(memberId, request);
final Long projectId = projectService.registerProject(command);
final RegisterProjectResponse response = new RegisterProjectResponse(projectId);
final CommissionProjectCommand command = projectCommandMapper.mapToCommand(memberId, request);
final Long projectId = projectCommissionService.commissionProject(command);
final CommissionProjectResponse response = new CommissionProjectResponse(projectId);
return ApiResponse.success(HttpStatus.CREATED, response);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.domain.project.command.presentation.dto.response;

public record RegisterProjectResponse(
public record CommissionProjectResponse(
Long projectId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class ProjectRegisterTest {
class ProjectCommissionerTest {

private final ClockHolder clockHolder = new StubClockHolder(LocalDate.of(2024, 7, 1));
private final ProjectRegister projectRegister = new ProjectRegister(clockHolder);
private final ProjectCommissioner projectCommissioner = new ProjectCommissioner(clockHolder);

@Test
void 지원자_모집_기간이_오늘보다_이전일__없다() {
Expand All @@ -41,7 +41,7 @@ class ProjectRegisterTest {
hashtags()
);

assertThatThrownBy(() -> projectRegister.registerProject(data))
assertThatThrownBy(() -> projectCommissioner.commissionProject(data))
.isInstanceOf(ApplicationDurationIsEndedException.class);
}

Expand All @@ -67,7 +67,7 @@ class ProjectRegisterTest {
hashtags()
);

final Project project = projectRegister.registerProject(data);
final Project project = projectCommissioner.commissionProject(data);

assertThat(project).usingRecursiveComparison().isNotNull();
}
Expand All @@ -94,7 +94,7 @@ class ProjectRegisterTest {
hashtags()
);

assertThatThrownBy(() -> projectRegister.registerProject(data))
assertThatThrownBy(() -> projectCommissioner.commissionProject(data))
.isInstanceOf(ApplicationDurationIsNotBeforeEstimatedDurationException.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package es.princip.getp.domain.project.command.presentation;

import es.princip.getp.domain.member.command.domain.model.MemberType;
import es.princip.getp.domain.project.command.application.ProjectService;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.application.ProjectCommissionService;
import es.princip.getp.domain.project.command.application.command.CommissionProjectCommand;
import es.princip.getp.domain.project.command.presentation.description.RegisterProjectRequestDescription;
import es.princip.getp.domain.project.command.presentation.description.RegisterProjectResponseDescription;
import es.princip.getp.domain.project.command.presentation.dto.request.CommissionProjectRequest;
Expand Down Expand Up @@ -31,7 +31,7 @@
class ProjectCommissionControllerTest extends AbstractControllerTest {

@MockBean
private ProjectService projectService;
private ProjectCommissionService projectCommissionService;

@MockBean
private ProjectCommandMapper projectCommandMapper;
Expand All @@ -53,8 +53,8 @@ private ResultActions perform() throws Exception {
@WithCustomMockUser(memberType = MemberType.ROLE_CLIENT)
void commissionProject() throws Exception {
given(projectCommandMapper.mapToCommand(anyLong(), any(CommissionProjectRequest.class)))
.willReturn(mock(RegisterProjectCommand.class));
given(projectService.registerProject(any(RegisterProjectCommand.class)))
.willReturn(mock(CommissionProjectCommand.class));
given(projectCommissionService.commissionProject(any(CommissionProjectCommand.class)))
.willReturn(1L);

perform()
Expand Down

0 comments on commit 131ac5b

Please sign in to comment.