Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/TEAM-MODDY/moddy-server
Browse files Browse the repository at this point in the history
…into refactor/#266

# Conflicts:
#	src/main/java/com/moddy/server/domain/hair_model_application/HairModelApplication.java
  • Loading branch information
pkl0912 committed Mar 2, 2024
2 parents c66667e + 1cf81d8 commit e7946fd
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum SuccessCode {
CREATE_MODEL_APPLICATION_SUCCESS(HttpStatus.OK, "모델 지원서 생성 성공입니다."),
USER_WITHDRAW_SUCCESS(HttpStatus.OK, "회원 탈퇴 성공입니다."),
GET_PRE_SIGNED_URL_SUCCESS(HttpStatus.OK, "제안서 다운로드 url 생성 성공"),
GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공");
GET_APPLICATION_IMG_URL_SUCCESS(HttpStatus.OK, "지원서 이미지 url 가져오기 성공"),
APPLICATION_DELETE_SUCCESS(HttpStatus.OK, "지원서 삭제하기 성공");

private final HttpStatus httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.moddy.server.config.resolver.user.UserId;
import com.moddy.server.controller.model.dto.request.ModelApplicationRequest;
import com.moddy.server.service.application.HairModelApplicationRegisterService;
import com.moddy.server.service.offer.HairServiceOfferRegisterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -17,19 +18,24 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import static com.moddy.server.common.exception.enums.SuccessCode.APPLICATION_DELETE_SUCCESS;
import static com.moddy.server.common.exception.enums.SuccessCode.USER_WITHDRAW_SUCCESS;

@RestController
@RequiredArgsConstructor
@Tag(name = "Application Controller")
@RequestMapping("/application")
public class ApplicationRegisterController {

private final HairModelApplicationRegisterService hairModelApplicationRegisterService;
private final HairServiceOfferRegisterService hairServiceOfferRegisterService;

@Operation(summary = "[JWT] 모델 지원서 작성", description = "모델 지원서 작성 API입니다.")
@ApiResponses({
Expand All @@ -47,4 +53,19 @@ public SuccessNonDataResponse submitModelApplication(
hairModelApplicationRegisterService.postApplication(modelId, modelImgUrl, applicationCaptureImgUrl, applicationInfo);
return SuccessNonDataResponse.success(SuccessCode.CREATE_MODEL_APPLICATION_SUCCESS);
}

@DeleteMapping
@Operation(summary = "[JWT] 지원서 삭제하기 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "지원서 삭제하기 성공입니다."),
@ApiResponse(responseCode = "401", description = "토큰이 만료되었습니다. 다시 로그인 해주세요.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "해당 유저는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@SecurityRequirement(name = "JWT Auth")
public SuccessNonDataResponse deleteApplication(@Parameter(hidden = true) @UserId final Long modelId) {
hairServiceOfferRegisterService.deleteModelHairServiceOfferInfos(modelId);
hairModelApplicationRegisterService.deleteModelApplications(modelId);
return SuccessNonDataResponse.success(APPLICATION_DELETE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public SuccessResponse<ApplicationDetailInfoResponse> getApplicationDetailInfo(
applicationDto.recordResponseList(),
applicationDto.hairDetail(),
hairServiceOfferRetrieveService.getIsSendStatus(applicationId, designerId),
applicationDto.instgramId()
applicationDto.instgramId(),
applicationDto.createdDate(),
applicationDto.expiredDate()
);

ModelInfoResponse modelInfoResponse = new ModelInfoResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public record ApplicationInfoResponse(
List<HairRecordResponse> hairServiceRecords,
String hairDetail,
boolean isSend,
String instagramId
String instagramId,
String createdDate,
String expiredDate
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public record ApplicationDto(
List<String> preferHairStyleList,
List<HairRecordResponse> recordResponseList,
String hairDetail,
String instgramId
String instgramId,
String createdDate,
String expiredDate
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void postApplication(final Long modelId, final MultipartFile modelImgUrl,
saveHairServiceRecords(applicationInfo, hairModelApplication);
}

@Transactional
public void deleteModelApplications(final Long modelId) {
List<HairModelApplication> hairModelApplications = hairModelApplicationJpaRepository.findAllByModelId(modelId);
hairModelApplications.forEach(hairModelApplication -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.time.format.DateTimeFormatter;

@Service
@RequiredArgsConstructor
Expand All @@ -42,6 +43,7 @@ public class HairModelApplicationRetrieveService {
private final S3Service s3Service;
private final PreferHairStyleJpaRepository preferHairStyleJpaRepository;
private final HairServiceRecordJpaRepository hairServiceRecordJpaRepository;
private static final String DATE_FORMAT = "yyyy. MM. dd.";

public DesignerMainResponse getDesignerMainInfo(final Long designerId, final int page, final int size) {

Expand Down Expand Up @@ -96,9 +98,12 @@ public ApplicationDto getApplicationDetailInfo(final Long applicationId) {
preferhairStyleList,
recordResponseList,
hairModelApplication.getHairDetail(),
hairModelApplication.getInstagramId());
hairModelApplication.getInstagramId(),
hairModelApplication.getCreatedDate().format(DateTimeFormatter.ofPattern(DATE_FORMAT)),
hairModelApplication.getExpiredDate().format(DateTimeFormatter.ofPattern(DATE_FORMAT)));
}


public boolean fetchModelApplyStatus(final Long modelId) {
return hairModelApplicationJpaRepository.existsByModelId(modelId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class HairServiceOfferRegisterService {
private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository;
private final SmsUtil smsUtil;

@Transactional
public void deleteModelHairServiceOfferInfos(final Long modelId) {
final List<HairServiceOffer> hairServiceOffers = hairServiceOfferJpaRepository.findAllByModelId(modelId);
hairServiceOffers.forEach(hairServiceOffer -> {
Expand Down

0 comments on commit e7946fd

Please sign in to comment.