Skip to content
Closed
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
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

import jakarta.validation.constraints.NotNull;
import java.time.Instant;

public record CreateMatchCycleRequest(@NotNull Instant runAt, String period) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

public record MatchCycleDetailQuery(String memberIndustry, String status) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.patinanetwork.patchats.api.match.dto.match.AdminMatchResponse;

@Getter
@Builder
@ToString
@EqualsAndHashCode
public class MatchCycleDetailResponse {

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final MatchCycleResponse cycle;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final List<AdminMatchResponse> matches;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

import java.time.Instant;

public record MatchCycleListQuery(String period, Instant startTime, Instant endTime) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Instant;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.patinanetwork.patchats.api.match.db.models.MatchCycle;

@Getter
@Builder
@ToString
@EqualsAndHashCode
public class MatchCycleResponse {

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final Integer matchCycleId;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED, nullable = true)
private final String period;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final Instant runAt;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final boolean isDraft;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final Integer totalMembers;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final Integer totalMatched;

public static MatchCycleResponse from(final MatchCycle cycle) {
return MatchCycleResponse.builder()
.matchCycleId(cycle.getId())
.period(cycle.getPeriod())
.runAt(cycle.getRunAt())
.isDraft(cycle.isDraft())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.patinanetwork.patchats.api.match.dto.cycle;

import java.time.Instant;

public record UpdateMatchCycleRequest(Instant runAt, String period, Boolean isDraft) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.patinanetwork.patchats.api.match.dto.match;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

public record BulkCreateMatchesRequest(@Valid @NotEmpty List<CreateMatchRequest> matches) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.patinanetwork.patchats.api.match.dto.match;

import java.time.Instant;
import java.util.UUID;

public record MatchListQuery(UUID memberId, String period, Instant startTime, Instant endTime, String status) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.patinanetwork.patchats.api.match.dto.match;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.patinanetwork.patchats.api.match.db.models.Match;

@Getter
@Builder
@ToString
@EqualsAndHashCode
public class MatchResponse {

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final UUID matchId;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final UUID memberAId;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final UUID memberBId;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final String month;

@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private final String status;

public static MatchResponse from(final Match match, final String month) {
return MatchResponse.builder()
.matchId(match.getId())
.memberAId(match.getMemberAId())
.memberBId(match.getMemberBId())
.month(month)
.status(match.getStatus())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.patinanetwork.patchats.api.match.dto.match;

import jakarta.validation.constraints.NotBlank;

public record UpdateMatchFeedbackRequest(@NotBlank String feedback) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.patinanetwork.patchats.api.match.dto.match;

import jakarta.validation.constraints.NotBlank;

public record UpdateMatchStatusRequest(@NotBlank String status) {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.patinanetwork.patchats.common.web.exception.EmailNotResendableException;
import org.patinanetwork.patchats.common.web.exception.EmailTemplateNotFoundException;
import org.patinanetwork.patchats.common.web.exception.MatchCycleNotFoundException;
import org.patinanetwork.patchats.common.web.exception.MatchNotFoundException;
import org.patinanetwork.patchats.common.web.exception.MemberDuplicateException;
import org.patinanetwork.patchats.common.web.exception.MemberNotFoundException;
import org.patinanetwork.patchats.common.web.exception.ValidationException;
Expand Down Expand Up @@ -64,6 +65,11 @@ public ResponseEntity<ApiResponder<Void>> handleMatchCycleNotFound(final MatchCy
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ApiResponder.failure(ex.getMessage()));
}

@ExceptionHandler(MatchNotFoundException.class)
public ResponseEntity<ApiResponder<Void>> handleMatchNotFound(final MatchNotFoundException ex) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ApiResponder.failure(ex.getMessage()));
}

private String formatError(final FieldError error) {
return error.getField() + " " + error.getDefaultMessage();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.patinanetwork.patchats.common.web.exception;

import java.util.UUID;

public class MatchNotFoundException extends RuntimeException {
public MatchNotFoundException(UUID id) {
super("Match with ID " + id + " not found");
}
}