Skip to content

Commit

Permalink
Merge pull request #136 from MUIT-UMC/develop
Browse files Browse the repository at this point in the history
[merge] 250217 / 33th deploy
  • Loading branch information
yhi9839 authored Feb 17, 2025
2 parents 1ea1caf + 9399b42 commit e3ba6c0
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 33 deletions.
7 changes: 4 additions & 3 deletions src/main/java/muit/backend/controller/AmateurController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public class AmateurController {
public ApiResponse<AmateurEnrollResponseDTO.EnrollResponseDTO> enroll(@RequestHeader("Authorization") String authorizationHeader, @RequestPart("data") AmateurEnrollRequestDTO amateurEnrollRequestDTO, // JSON 데이터
@RequestPart(name = "posterImage", required = false) MultipartFile posterImage,
@RequestPart(name = "castingImages", required = false) List<MultipartFile> castingImages,
@RequestPart(name = "noticeImages", required = false) List<MultipartFile> noticeImages,
@RequestPart(name = "summaryImage", required = false) MultipartFile summaryImage){
@RequestPart(name = "noticeImages", required = false) List<MultipartFile> noticeImages){
//@RequestPart(name = "summaryImage", required = false) MultipartFile summaryImage){
Member member = memberService.getMemberByToken(authorizationHeader);
AmateurEnrollResponseDTO.EnrollResponseDTO enrollResponseDTO = showService.enrollShow(member, amateurEnrollRequestDTO, posterImage, castingImages, noticeImages, summaryImage);

AmateurEnrollResponseDTO.EnrollResponseDTO enrollResponseDTO = showService.enrollShow(member, amateurEnrollRequestDTO, posterImage, castingImages, noticeImages);
return ApiResponse.onSuccess(enrollResponseDTO);

}
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/muit/backend/converter/AmateurConverter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package muit.backend.converter;

import lombok.extern.slf4j.Slf4j;
import muit.backend.domain.entity.amateur.*;
import muit.backend.domain.entity.member.Member;
import muit.backend.domain.enums.TicketType;
Expand Down Expand Up @@ -50,25 +51,24 @@ public static List<AmateurCasting> toCastingEntity(List<AmateurEnrollRequestDTO.
.collect(Collectors.toList());
}

public static AmateurNotice toNoticeEntity(AmateurEnrollRequestDTO.AmateurNoticeDTO dto,
public static AmateurNotice toNoticeEntity(String noticeContent,
List<String> urls, AmateurShow show) {
if (dto == null || urls == null) return null;
if (noticeContent == null || urls == null) return null;

return AmateurNotice.builder()
.amateurShow(show)
.noticeImageUrls(urls)
.content(dto.getContent())
.content(noticeContent)
.build();
}

public static AmateurSummary toSummaryEntity(AmateurEnrollRequestDTO.AmateurSummaryDTO dto,
String url, AmateurShow show) {
if (dto == null || url == null) return null;
public static AmateurSummary toSummaryEntity(String summaryContent,
AmateurShow show) {
if (summaryContent == null) return null;

return AmateurSummary.builder()
.amateurShow(show)
.summaryImage(url)
.content(dto.getContent())
.content(summaryContent)
.build();
}

Expand All @@ -79,7 +79,6 @@ public static List<AmateurTicket> toTicketEntity(List<AmateurEnrollRequestDTO.Am
return dtos.stream()
.map(dto -> AmateurTicket.builder()
.amateurShow(show)
.ticketType(TicketType.valueOf(dto.getTicketType()))
.ticketName(dto.getTicketName())
.price(Integer.parseInt(dto.getPrice()))
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@AllArgsConstructor
public class AmateurEnrollRequestDTO {
private String name;
private String posterImgUrl;
//private String posterImgUrl; // 포스터는 따로 뺌
private String place;
private String schedule;
private String age;
Expand All @@ -25,38 +25,38 @@ public class AmateurEnrollRequestDTO {
private String hashtag;
private String runtime;
private List<AmateurCastingDTO> castings;
private AmateurNoticeDTO notice;
private String noticeContent;
private List<AmateurTicketDTO> tickets;
private List<AmateurStaffDTO> staff;
private AmateurSummaryDTO summaries;
private String summaryContent;


@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public static class AmateurCastingDTO{
private String imgUrl;
//private String imgUrl; // 캐스팅 url도 따로 Multipart로
private String actorName;
private String castingName;
}

@Builder
/* @Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public static class AmateurNoticeDTO{
private List<String> imgUrls;
// private List<String> imgUrls;
private String content;
}
}*/

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public static class AmateurTicketDTO{
private String ticketName;
private String ticketType;
//private String ticketType; // 티켓 타입 빼기로함
private String price;
}

Expand All @@ -70,12 +70,12 @@ public static class AmateurStaffDTO{
private String name;
}

@Builder
/* @Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
public static class AmateurSummaryDTO{
private String imgUrl;
// private String imgUrl;
private String content;
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public interface AmateurShowService {
AmateurEnrollResponseDTO.EnrollResponseDTO enrollShow(Member member, AmateurEnrollRequestDTO dto,
MultipartFile posterImage,
List<MultipartFile> castingImages,
List<MultipartFile> noticeImages,
MultipartFile summaryImage);
List<MultipartFile> noticeImages
);
AmateurShowResponseDTO getShow(Long amateurId);

List<AmateurShowResponseDTO.AmateurShowListDTO> getAllShows(Integer page, Integer size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public class AmateurShowServiceImpl implements AmateurShowService{
public AmateurEnrollResponseDTO.EnrollResponseDTO enrollShow(Member member, AmateurEnrollRequestDTO dto,
MultipartFile posterImage,
List<MultipartFile> castingImages,
List<MultipartFile> noticeImages,
MultipartFile summaryImage){
List<MultipartFile> noticeImages
//,MultipartFile summaryImage // 줄거리 이미지 빼기로함
){
String posterUrl = (posterImage != null) ?
uuidFileService.createFile(posterImage, FilePath.AMATEUR).getFileUrl() : null;

Expand All @@ -58,41 +59,52 @@ public AmateurEnrollResponseDTO.EnrollResponseDTO enrollShow(Member member, Amat
.map(file -> uuidFileService.createFile(file, FilePath.AMATEUR_NOTICE).getFileUrl())
.toList() : null;

String summaryUrl = (summaryImage != null) ?
uuidFileService.createFile(summaryImage, FilePath.AMATEUR_SUMMARY).getFileUrl() : null;
// String summaryUrl = (summaryImage != null) ?
// uuidFileService.createFile(summaryImage, FilePath.AMATEUR_SUMMARY).getFileUrl() : null;
AmateurShow amateurShow = AmateurConverter.toEntityWithDetails(member, dto, posterUrl);
showRepository.save(amateurShow);
//여기서 posterUrl 까지만 저장해주고

saveRelatedEntity(dto, amateurShow, castingUrls, noticeUrls, summaryUrl);
log.info("Notice Content: {}", dto.getNoticeContent());
log.info("Notice Image URLs: {}", noticeUrls);

saveRelatedEntity(dto, amateurShow, castingUrls, noticeUrls);
//여기서 나머지도 저장 해줍니다

return AmateurConverter.enrolledResponseDTO(amateurShow);
}

// 등록하기전에 합치기
private void saveRelatedEntity(AmateurEnrollRequestDTO dto, AmateurShow show, List<String> castingUrls, List<String> noticeUrls, String summaryUrl){
private void saveRelatedEntity(AmateurEnrollRequestDTO dto, AmateurShow show, List<String> castingUrls, List<String> noticeUrls){
List<AmateurCasting> castings = AmateurConverter.toCastingEntity(dto.getCastings(), castingUrls, show);
if (!castings.isEmpty()) {
amateurCastingRepository.saveAll(castings);
log.info("캐스팅 등록하기, 총 {}명 등록됨", castings.size());
}

AmateurNotice notice = AmateurConverter.toNoticeEntity(dto.getNotice(), noticeUrls, show);
// 캐스팅 이미지와 함게 저장

AmateurNotice notice = AmateurConverter.toNoticeEntity(dto.getNoticeContent(), noticeUrls, show);
if (notice != null) {
amateurNoticeRepository.save(notice);
}

// 공지사항 이미지와 함께 저장

List<AmateurTicket> tickets = AmateurConverter.toTicketEntity(dto.getTickets(), show);
if(!tickets.isEmpty()) {
amateurTicketRepository.saveAll(tickets);
log.info("티켓도 등록 해줘요");
}

AmateurSummary summaries = AmateurConverter.toSummaryEntity( dto.getSummaries(), summaryUrl, show);
// 티켓 저장, ticketType 제거

AmateurSummary summaries = AmateurConverter.toSummaryEntity(dto.getSummaryContent(), show);
amateurSummaryRepository.save(summaries);
log.info("줄거리도 등록 완료");

// 줄거리 저장, 줄거리 이미지 제거

List<AmateurStaff> staff = AmateurConverter.toStaffEntity(dto.getStaff(), show);
amateurStaffRepository.saveAll(staff);
log.info("연출자도 등록 완료");
Expand Down

0 comments on commit e3ba6c0

Please sign in to comment.