Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ae/get-p-server into feature/GETP-157
  • Loading branch information
wlgns12370 committed Aug 2, 2024
2 parents f3a98fd + 131ac5b commit f6053df
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package es.princip.getp.infra.annotation;
package es.princip.getp.domain.common.annotation;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
@Target({ ElementType.FIELD, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {})
public @interface URLValid {
public @interface URLPattern {

String message() default "";
String message() default "{validation.constraints.URL.message}";

Class<?>[] groups() default {};

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/es/princip/getp/domain/common/domain/URL.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package es.princip.getp.domain.common.domain;

import es.princip.getp.domain.common.annotation.URLValid;
import es.princip.getp.domain.common.annotation.URLPattern;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
Expand All @@ -20,7 +20,7 @@ public class URL {
private static final Pattern URL_PATTERN = Pattern.compile(URL_REGEX);

@Column(name = "url")
@URLValid
@URLPattern
@NotNull
private String value;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package es.princip.getp.domain.people.command.presentation.dto.request;

import es.princip.getp.domain.common.annotation.Enum;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand;
import es.princip.getp.domain.people.command.domain.PeopleType;
import es.princip.getp.infra.annotation.Enum;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package es.princip.getp.domain.people.command.presentation.dto.request;

import es.princip.getp.domain.common.annotation.URLValid;
import es.princip.getp.domain.common.annotation.URLPattern;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

public record PortfolioRequest(
@NotBlank String description,
@NotNull @URLValid String url
@NotNull @URLPattern String url
) {
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package es.princip.getp.domain.people.command.presentation.dto.request;

import es.princip.getp.domain.common.annotation.Enum;
import es.princip.getp.domain.member.command.annotation.EmailPattern;
import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern;
import es.princip.getp.domain.member.command.domain.model.Email;
import es.princip.getp.domain.member.command.domain.model.Nickname;
import es.princip.getp.domain.member.command.domain.model.PhoneNumber;
import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand;
import es.princip.getp.domain.people.command.domain.PeopleType;
import es.princip.getp.infra.annotation.Enum;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
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.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 RegisterProjectCommand 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
Expand Up @@ -11,11 +11,11 @@

@DomainService
@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 @@ -6,6 +6,7 @@
import es.princip.getp.domain.project.command.application.command.ApplyProjectCommand;
import es.princip.getp.domain.project.command.application.command.ScheduleMeetingCommand;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;

import es.princip.getp.domain.project.command.domain.AttachmentFile;
import es.princip.getp.domain.project.command.presentation.dto.request.ScheduleMeetingRequest;
import es.princip.getp.domain.project.command.presentation.dto.request.ApplyProjectRequest;
Expand Down
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.ProjectCommissionService;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
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 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,9 +1,9 @@
package es.princip.getp.domain.project.command.presentation.dto.request;

import es.princip.getp.domain.common.annotation.Enum;
import es.princip.getp.domain.common.domain.Duration;
import es.princip.getp.domain.project.command.domain.MeetingType;
import es.princip.getp.domain.project.command.domain.ProjectCategory;
import es.princip.getp.infra.annotation.Enum;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

Expand Down
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,7 +1,7 @@
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.ProjectCommissionService;
import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand;
import es.princip.getp.domain.project.command.presentation.description.RegisterProjectRequestDescription;
import es.princip.getp.domain.project.command.presentation.description.RegisterProjectResponseDescription;
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 @@ -54,7 +54,7 @@ private ResultActions perform() throws Exception {
void commissionProject() throws Exception {
given(projectCommandMapper.mapToCommand(anyLong(), any(CommissionProjectRequest.class)))
.willReturn(mock(RegisterProjectCommand.class));
given(projectService.registerProject(any(RegisterProjectCommand.class)))
given(projectCommissionService.commissionProject(any(RegisterProjectCommand.class)))
.willReturn(1L);

perform()
Expand Down

0 comments on commit f6053df

Please sign in to comment.