Skip to content

Commit

Permalink
Merge pull request #179 from swm-nodriversomabus/BUS-209-MVP1-bugfix
Browse files Browse the repository at this point in the history
Bus 209 mvp1 bugfix
  • Loading branch information
Lemonade255 authored Nov 7, 2023
2 parents 3eb6b92 + 7a09f03 commit f2ca2c7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ErrorCodeEnum {
USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "유저 정보가 없습니다"),
CODE_IS_EXPIRED(HttpStatus.BAD_REQUEST, "휴대전화를 인증해주세요"),
CODE_IS_NOT_VALID(HttpStatus.BAD_REQUEST, "잘못된 인증번호입니다"),
INVALID_DURATION(HttpStatus.BAD_REQUEST, "시작 시간이 종료 시간 이후입니다"),
MATCHING_NOT_FOUND(HttpStatus.BAD_REQUEST, "매칭 정보가 없습니다"),
PREFERENCE_NOT_FOUND(HttpStatus.BAD_REQUEST, "선호도 정보가 없습니다"),
APPLICATION_NOT_FOUND(HttpStatus.BAD_REQUEST, "신청 정보가 없습니다"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.example.api.user.type.UserRoleEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class MatchingController {
*/
@Operation(summary = "Create matching", description = "새로운 매칭을 생성한다.")
@PostMapping("/matching")
public FindMatchingDto createMatching(@RequestBody SaveMatchingDto saveMatchingDto) {
public FindMatchingDto createMatching(@Valid @RequestBody SaveMatchingDto saveMatchingDto) {
SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication();
if (securityUser == null) {
log.error("MatchingController::createMatching: Login is needed");
Expand All @@ -71,7 +72,7 @@ public FindMatchingDto createMatching(@RequestBody SaveMatchingDto saveMatchingD
*/
@Operation(summary = "Create matching application", description = "새로운 매칭 신청을 생성한다.")
@PostMapping("/matching/application")
public ChatRoom createMatchingApplication(@RequestBody SaveMatchingApplicationDto matchingApplicationDto) {
public ChatRoom createMatchingApplication(@Valid @RequestBody SaveMatchingApplicationDto matchingApplicationDto) {
FindMatchingDto matchingDto = findMatchingUsecase.getMatchingById(matchingApplicationDto.getMatchingId());
if (matchingDto == null) {
log.error("MatchingController::createMatchingApplication: No such matching");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class SaveMatchingApplicationDto {
@org.hibernate.validator.constraints.UUID
private UUID userId;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public class SaveMatchingDto {
@NotNull
private MatchingTypeEnum type;

@NotBlank
@NotBlank(message = "Title is empty")
private String title;

@NotBlank
@NotBlank(message = "Place is empty")
private String place;

@NotBlank
@NotBlank(message = "Content is empty")
private String content;

@NotNull
Expand All @@ -34,7 +34,7 @@ public class SaveMatchingDto {
private LocalDateTime endDate;

@NotNull
@Min(1)
@Min(value = 1, message = "MaxMember must be at least 1")
private Integer maxMember;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.api.matching.service;

import com.example.api.common.exception.CustomException;
import com.example.api.common.type.ApplicationStateEnum;
import com.example.api.common.type.ErrorCodeEnum;
import com.example.api.common.type.Pair;
import com.example.api.matching.adapter.out.persistence.MatchingEntity;
import com.example.api.matching.adapter.out.persistence.MatchingMapperInterface;
Expand Down Expand Up @@ -39,6 +41,10 @@ public class MatchingService implements SaveMatchingUsecase, FindMatchingUsecase
public FindMatchingDto createMatching(UUID writerId, SaveMatchingDto matchingDto) {
Matching matching = matchingMapper.toDomain(matchingDto);
matching.setWriterId(writerId);
if (matching.getStartDate().isAfter(matching.getEndDate())) {
log.error("MatchingService::createMatching: Invalid duration");
throw new CustomException(ErrorCodeEnum.INVALID_DURATION);
}
return matchingMapper.toDto(saveMatchingPort.createMatching(matching));
}

Expand Down

0 comments on commit f2ca2c7

Please sign in to comment.