diff --git a/build.gradle b/build.gradle index 19ba621..388a84b 100644 --- a/build.gradle +++ b/build.gradle @@ -44,10 +44,6 @@ dependencies { runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3' - // AWS - implementation platform('io.awspring.cloud:spring-cloud-aws-dependencies:3.0.0') - implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3' - // Database runtimeOnly 'com.h2database:h2:2.2.224' implementation 'mysql:mysql-connector-java:8.0.32' diff --git a/compose.yaml b/compose.yaml index 3979093..f5f6938 100644 --- a/compose.yaml +++ b/compose.yaml @@ -56,10 +56,6 @@ services: GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} GMAIL_USERNAME: ${GMAIL_USERNAME} GMAIL_APP_PASSWORD: ${GMAIL_APP_PASSWORD} - AWS_ACCESS_KEY: ${AWS_ACCESS_KEY} - AWS_SECRET_KEY: ${AWS_SECRET_KEY} - AWS_REGION: ${AWS_REGION} - AWS_S3_BUCKET: ${AWS_S3_BUCKET} DISCORD_WEBHOOK_URL: ${DISCORD_WEBHOOK_URL} JWT_SECRET: ${JWT_SECRET} JWT_EXPIRATION: ${JWT_EXPIRATION} @@ -112,11 +108,14 @@ services: awslogs-group: ${AWS_LOG_GROUP} awslogs-stream: certbot awslogs-multiline-pattern: "^Saving debug log to" + depends_on: + nginx: + condition: service_healthy volumes: - ./certbot/data:/var/www/certbot/:rw - ./certbot/conf:/etc/letsencrypt/:rw # If your nginx server has not yet been issued an SSL certificate, run the command below - # docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d gdsc-konkuk.dev + # docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d api.gdsc-konkuk.dev entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12d & wait $${!}; done;'" autoheal: diff --git a/nginx.conf b/nginx.conf index 776f41b..ded6c0e 100644 --- a/nginx.conf +++ b/nginx.conf @@ -35,8 +35,8 @@ http { listen 443 default_server ssl; listen [::]:443 ssl; - ssl_certificate /etc/letsencrypt/live/gdsc-konkuk.dev/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/gdsc-konkuk.dev/privkey.pem; + ssl_certificate /etc/letsencrypt/live/api.gdsc-konkuk.dev/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/api.gdsc-konkuk.dev/privkey.pem; location / { proxy_pass http://spring:8080; diff --git a/src/main/java/gdsc/konkuk/platformcore/application/attendance/AttendanceService.java b/src/main/java/gdsc/konkuk/platformcore/application/attendance/AttendanceService.java index b04df3c..4a22ee5 100644 --- a/src/main/java/gdsc/konkuk/platformcore/application/attendance/AttendanceService.java +++ b/src/main/java/gdsc/konkuk/platformcore/application/attendance/AttendanceService.java @@ -3,21 +3,16 @@ import static gdsc.konkuk.platformcore.application.attendance.AttendanceServiceHelper.findAttendanceById; import gdsc.konkuk.platformcore.application.attendance.dtos.AttendanceStatus; -import gdsc.konkuk.platformcore.application.attendance.exceptions.AttendanceAlreadyExistException; -import gdsc.konkuk.platformcore.application.attendance.exceptions.AttendanceErrorCode; -import gdsc.konkuk.platformcore.application.event.exceptions.EventErrorCode; -import gdsc.konkuk.platformcore.application.event.exceptions.EventNotFoundException; import gdsc.konkuk.platformcore.application.member.exceptions.MemberErrorCode; import gdsc.konkuk.platformcore.application.member.exceptions.UserNotFoundException; -import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceRegisterRequest; import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; import gdsc.konkuk.platformcore.domain.attendance.entity.Participant; import gdsc.konkuk.platformcore.domain.attendance.repository.AttendanceRepository; import gdsc.konkuk.platformcore.domain.attendance.repository.ParticipantRepository; -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import gdsc.konkuk.platformcore.domain.event.repository.EventRepository; import gdsc.konkuk.platformcore.domain.member.entity.Member; import gdsc.konkuk.platformcore.domain.member.repository.MemberRepository; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; @@ -29,7 +24,6 @@ @Transactional(readOnly = true) public class AttendanceService { private final ParticipantRepository participantRepository; - private final EventRepository eventRepository; private final MemberRepository memberRepository; private final AttendanceRepository attendanceRepository; private final ParticipantService participantService; @@ -45,14 +39,17 @@ public Participant attend(Long memberId, Long attendanceId, String qrUuid) { return participantService.attend(member.getId(), attendanceId); } + public List getAllByPeriod(LocalDate month) { + return attendanceRepository.findAllByPeriod(month.atStartOfDay(), month.atStartOfDay().plusMonths(1)); + } + @Transactional - public Attendance registerAttendance(AttendanceRegisterRequest registerRequest) { - checkAttendanceAlreadyExist(registerRequest.getEventId()); - Attendance newAttendance = AttendanceRegisterRequest.toEntity(registerRequest); + public Attendance registerAttendance(String title, String batch) { + Attendance newAttendance = Attendance.builder().title(title).attendanceTime(LocalDateTime.now()).build(); newAttendance.generateQr(); attendanceRepository.saveAndFlush(newAttendance); - List members = memberRepository.findAllByBatch(registerRequest.getBatch()); + List members = memberRepository.findAllByBatch(batch); registerParticipants(newAttendance, members); return newAttendance; } @@ -82,21 +79,6 @@ public void expireQr(Long attendanceId) { attendance.expireQr(); } - private void checkAttendanceAlreadyExist(Long eventId) { - Event event = - eventRepository - .findById(eventId) - .orElseThrow(() -> EventNotFoundException.of(EventErrorCode.EVENT_NOT_FOUND)); - - attendanceRepository - .findByEventId(event.getId()) - .ifPresent( - attendance -> { - throw AttendanceAlreadyExistException.of( - AttendanceErrorCode.ATTENDANCE_ALREADY_EXIST); - }); - } - private void registerParticipants(Attendance attendance, List members){ List participants = new ArrayList<>(); for(Member member : members) { diff --git a/src/main/java/gdsc/konkuk/platformcore/application/attendance/dtos/MemberAttendanceQueryDto.java b/src/main/java/gdsc/konkuk/platformcore/application/attendance/dtos/MemberAttendanceQueryDto.java index 5703a65..f37bfce 100644 --- a/src/main/java/gdsc/konkuk/platformcore/application/attendance/dtos/MemberAttendanceQueryDto.java +++ b/src/main/java/gdsc/konkuk/platformcore/application/attendance/dtos/MemberAttendanceQueryDto.java @@ -12,7 +12,6 @@ @Builder @AllArgsConstructor public class MemberAttendanceQueryDto { - private Long eventId; private Long memberId; private String memberName; private MemberRole memberRole; diff --git a/src/main/java/gdsc/konkuk/platformcore/application/attendance/exceptions/AttendanceAlreadyExistException.java b/src/main/java/gdsc/konkuk/platformcore/application/attendance/exceptions/AttendanceAlreadyExistException.java deleted file mode 100644 index a5616f2..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/attendance/exceptions/AttendanceAlreadyExistException.java +++ /dev/null @@ -1,14 +0,0 @@ -package gdsc.konkuk.platformcore.application.attendance.exceptions; - -import gdsc.konkuk.platformcore.global.exceptions.BusinessException; -import gdsc.konkuk.platformcore.global.exceptions.CustomErrorCode; - -public class AttendanceAlreadyExistException extends BusinessException { - protected AttendanceAlreadyExistException(CustomErrorCode errorCode, String logMessage) { - super(errorCode, logMessage); - } - - public static AttendanceAlreadyExistException of(CustomErrorCode errorCode) { - return new AttendanceAlreadyExistException(errorCode, errorCode.getMessage()); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/EventMapper.java b/src/main/java/gdsc/konkuk/platformcore/application/event/EventMapper.java deleted file mode 100644 index 7c57ed6..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/EventMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package gdsc.konkuk.platformcore.application.event; - -import gdsc.konkuk.platformcore.application.event.dtos.EventBrief; -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import java.util.List; - -public class EventMapper { - - public static List mapEventListToEventBriefList( - List events) { - return events.stream() - .map( - event -> - EventBrief.builder() - .id(event.getId()) - .title(event.getTitle()) - .content(event.getContent()) - .startAt(event.getStartAt()) - .thumbnail(event.getThumbnail().orElse(null)) - .build()) - .toList(); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/EventService.java b/src/main/java/gdsc/konkuk/platformcore/application/event/EventService.java deleted file mode 100644 index 5f24ce2..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/EventService.java +++ /dev/null @@ -1,118 +0,0 @@ -package gdsc.konkuk.platformcore.application.event; - -import gdsc.konkuk.platformcore.application.attendance.AttendanceService; -import gdsc.konkuk.platformcore.application.event.dtos.EventBrief; -import gdsc.konkuk.platformcore.application.event.dtos.EventWithAttendance; -import gdsc.konkuk.platformcore.application.event.exceptions.EventErrorCode; -import gdsc.konkuk.platformcore.application.event.exceptions.EventNotFoundException; -import gdsc.konkuk.platformcore.controller.event.dtos.EventBriefResponse; -import gdsc.konkuk.platformcore.controller.event.dtos.EventDetailResponse; -import gdsc.konkuk.platformcore.controller.event.dtos.EventRegisterRequest; -import gdsc.konkuk.platformcore.controller.event.dtos.EventUpdateRequest; -import gdsc.konkuk.platformcore.domain.attendance.repository.AttendanceRepository; -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import gdsc.konkuk.platformcore.domain.event.entity.EventImage; -import gdsc.konkuk.platformcore.domain.event.repository.EventRepository; -import gdsc.konkuk.platformcore.external.s3.StorageClient; -import gdsc.konkuk.platformcore.global.utils.FileValidator; -import java.io.IOException; -import java.net.URL; -import lombok.RequiredArgsConstructor; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDate; -import java.time.LocalTime; -import java.util.List; -import org.springframework.web.multipart.MultipartFile; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class EventService { - private final EventRepository eventRepository; - private final StorageClient storageClient; - private final AttendanceRepository attendanceRepository; - private final AttendanceService attendanceService; - - public EventDetailResponse getEvent(Long eventId) { - Event event = findById(eventId); - return EventDetailResponse.fromEntity(event); - } - - public EventBriefResponse getAllBriefs() { - List events = eventRepository.findAll(); - List eventBriefs = EventMapper.mapEventListToEventBriefList(events); - return EventBriefResponse.builder().eventBriefs(eventBriefs).build(); - } - - @Transactional - public Event register(EventRegisterRequest registerRequest, List imageFiles) - throws IOException { - Event newEvent = eventRepository.saveAndFlush(EventRegisterRequest.toEntity(registerRequest)); - uploadImages(newEvent, imageFiles); - return newEvent; - } - - public List getEventsOfTheMonthWithAttendance(LocalDate month) { - return eventRepository.findAllWithAttendanceByStartAtBetween( - month.withDayOfMonth(1).atStartOfDay(), - month.withDayOfMonth(month.lengthOfMonth()).atTime(LocalTime.MAX)); - } - - @Transactional - public void update(Long eventId, EventUpdateRequest request, List newImageFiles) - throws IOException { - Event event = findById(eventId); - event.update( - request.getTitle(), request.getContent(), request.getLocation(), request.getStartAt(), request.getEndAt()); - - uploadImages(event, newImageFiles); - deleteImages(event, request.getEventImagesToDelete()); - } - - @Transactional - public void updateRetrospect(Long eventId, String content) { - Event event = findById(eventId); - event.updateRetrospectContent(content); - } - - @Transactional - public void delete(Long eventId) { - Event event = findById(eventId); - - attendanceRepository.findByEventId(eventId) - .ifPresent(attendance -> attendanceService.deleteAttendance(attendance.getId())); - eventRepository.delete(event); - - List eventImages = event.getEventImageList(); - List imageUrls = eventImages.stream().map(EventImage::getUrl).toList(); - storageClient.deleteFiles(imageUrls); - } - - private Event findById(Long eventId) { - return eventRepository - .findById(eventId) - .orElseThrow(() -> EventNotFoundException.of(EventErrorCode.EVENT_NOT_FOUND)); - } - - private void uploadImages(Event event, List imageFiles) throws IOException { - if (imageFiles == null) return; - - List eventImageUrls = - storageClient.uploadFiles(imageFiles, FileValidator::validateFileMimeTypeImage); - for (URL imageUrl : eventImageUrls) { - event.addEventImageByUrl(imageUrl); - } - } - - private void deleteImages(Event event, List imageUrls) { - if (imageUrls == null) return; - - for (URL imageUrl : imageUrls) { - event.deleteEventImageByUrl(imageUrl); - } - storageClient.deleteFiles(imageUrls); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventBrief.java b/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventBrief.java deleted file mode 100644 index 07cc276..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventBrief.java +++ /dev/null @@ -1,18 +0,0 @@ -package gdsc.konkuk.platformcore.application.event.dtos; - -import java.net.URL; -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@Builder -public class EventBrief { - private Long id; - private String title; - private String content; - private LocalDateTime startAt; - private URL thumbnail; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventWithAttendance.java b/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventWithAttendance.java deleted file mode 100644 index 39931b2..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/dtos/EventWithAttendance.java +++ /dev/null @@ -1,19 +0,0 @@ -package gdsc.konkuk.platformcore.application.event.dtos; - -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalDateTime; - -@Getter -@Setter -@Builder -public class EventWithAttendance { - @NotNull private Long eventId; - private Long attendanceId; - @NotEmpty private String title; - @NotNull private LocalDateTime startAt; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventErrorCode.java b/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventErrorCode.java deleted file mode 100644 index c346cc4..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventErrorCode.java +++ /dev/null @@ -1,27 +0,0 @@ -package gdsc.konkuk.platformcore.application.event.exceptions; - -import gdsc.konkuk.platformcore.global.exceptions.CustomErrorCode; -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -public enum EventErrorCode implements CustomErrorCode { - EVENT_NOT_FOUND("이벤트가 존재하지 않습니다. 다시 입력해주세요", "[ERROR] : 이벤트 정보를 찾을 수 없음"); - - private final String message; - private final String logMessage; - - @Override - public String getLogMessage() { - return this.logMessage; - } - - @Override - public String getName() { - return this.name(); - } - - @Override - public String getMessage() { - return this.message; - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventNotFoundException.java b/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventNotFoundException.java deleted file mode 100644 index 4c213e4..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/event/exceptions/EventNotFoundException.java +++ /dev/null @@ -1,14 +0,0 @@ -package gdsc.konkuk.platformcore.application.event.exceptions; - -import gdsc.konkuk.platformcore.global.exceptions.BusinessException; -import gdsc.konkuk.platformcore.global.exceptions.CustomErrorCode; - -public class EventNotFoundException extends BusinessException { - protected EventNotFoundException(CustomErrorCode errorCode, String logMessage) { - super(errorCode, logMessage); - } - - public static EventNotFoundException of(CustomErrorCode errorCode) { - return new EventNotFoundException(errorCode, errorCode.getMessage()); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/member/dtos/MemberAttendances.java b/src/main/java/gdsc/konkuk/platformcore/application/member/dtos/MemberAttendances.java index 50b203f..9eab867 100644 --- a/src/main/java/gdsc/konkuk/platformcore/application/member/dtos/MemberAttendances.java +++ b/src/main/java/gdsc/konkuk/platformcore/application/member/dtos/MemberAttendances.java @@ -64,7 +64,6 @@ private static MemberAttendanceInfo createMemberAttendanceInfo(MemberAttendanceQ .attendanceDate(attendanceInfo.getAttendanceDate()) .participantId(attendanceInfo.getParticipantId()) .attendanceId(attendanceInfo.getAttendanceId()) - .eventId(attendanceInfo.getEventId()) .isAttended(attendanceInfo.isAttended()) .build(); } diff --git a/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserNotAllowedException.java b/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserNotAllowedException.java deleted file mode 100644 index ad99ef5..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserNotAllowedException.java +++ /dev/null @@ -1,14 +0,0 @@ -package gdsc.konkuk.platformcore.application.member.exceptions; - -import gdsc.konkuk.platformcore.global.exceptions.BusinessException; -import gdsc.konkuk.platformcore.global.exceptions.CustomErrorCode; - -public class UserNotAllowedException extends BusinessException { - protected UserNotAllowedException(CustomErrorCode errorCode, String logMessage) { - super(errorCode, logMessage); - } - - public static UserNotAllowedException of(CustomErrorCode errorCode) { - return new UserNotAllowedException(errorCode, errorCode.getMessage()); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserPasswordInvalidException.java b/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserPasswordInvalidException.java deleted file mode 100644 index 8da7ccc..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/application/member/exceptions/UserPasswordInvalidException.java +++ /dev/null @@ -1,14 +0,0 @@ -package gdsc.konkuk.platformcore.application.member.exceptions; - -import gdsc.konkuk.platformcore.global.exceptions.BusinessException; -import gdsc.konkuk.platformcore.global.exceptions.CustomErrorCode; - -public class UserPasswordInvalidException extends BusinessException { - protected UserPasswordInvalidException(CustomErrorCode errorCode, String logMessage) { - super(errorCode, logMessage); - } - - public static UserPasswordInvalidException of(CustomErrorCode errorCode) { - return new UserPasswordInvalidException(errorCode, errorCode.getMessage()); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceController.java b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceController.java index 79385bf..b600afa 100644 --- a/src/main/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceController.java +++ b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceController.java @@ -6,15 +6,14 @@ import gdsc.konkuk.platformcore.application.attendance.AttendanceService; import gdsc.konkuk.platformcore.application.attendance.exceptions.AttendanceErrorCode; import gdsc.konkuk.platformcore.application.attendance.exceptions.QrInvalidException; -import gdsc.konkuk.platformcore.application.event.EventService; -import gdsc.konkuk.platformcore.application.event.dtos.EventWithAttendance; +import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceInfo; import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceRegisterRequest; import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceResponse; import gdsc.konkuk.platformcore.application.attendance.dtos.AttendanceStatus; import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; import gdsc.konkuk.platformcore.global.responses.SuccessResponse; import gdsc.konkuk.platformcore.global.utils.SecurityUtils; -import jakarta.validation.Valid; +import jakarta.servlet.http.HttpServletResponse; import java.time.LocalDate; import java.util.List; import lombok.RequiredArgsConstructor; @@ -32,21 +31,19 @@ import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import java.net.URI; -import software.amazon.awssdk.http.HttpStatusCode; @RestController @RequestMapping("/api/v1/attendances") @RequiredArgsConstructor public class AttendanceController { private final AttendanceService attendanceService; - private final EventService eventService; @GetMapping public ResponseEntity getEventsOfTheMonthWithAttendance( @RequestParam Integer year, @RequestParam Integer month) { - List eventsOfMonthWithAttendance = - eventService.getEventsOfTheMonthWithAttendance(LocalDate.of(year, month, 1)); - return ResponseEntity.ok(SuccessResponse.of(eventsOfMonthWithAttendance)); + List attendances = attendanceService.getAllByPeriod(LocalDate.of(year, month, 1)); + List attendanceInfos = attendances.stream().map(AttendanceInfo::from).toList(); + return ResponseEntity.ok(SuccessResponse.of(attendanceInfos)); } @GetMapping("/attend/{attendanceId}") @@ -56,18 +53,20 @@ public ResponseEntity attend(@PathVariable Long attendanceId, @RequestParam S attendanceService.attend(currentId, attendanceId, qrUuid); HttpHeaders headers = new HttpHeaders(); headers.add("Location", "https://admin.gdsc-konkuk.dev/attendance-return/success"); - return new ResponseEntity<>(headers, valueOf(HttpStatusCode.TEMPORARY_REDIRECT)); + return new ResponseEntity<>(headers, valueOf(HttpServletResponse.SC_TEMPORARY_REDIRECT)); }catch(Exception e) { HttpHeaders headers = new HttpHeaders(); headers.add("Location", "https://admin.gdsc-konkuk.dev/attendance-return/fail"); - return new ResponseEntity<>(headers, valueOf(HttpStatusCode.TEMPORARY_REDIRECT)); + return new ResponseEntity<>(headers, valueOf(HttpServletResponse.SC_TEMPORARY_REDIRECT)); } } @PostMapping() public ResponseEntity registerAttendance( - @RequestBody @Valid AttendanceRegisterRequest registerRequest) { - Attendance attendance = attendanceService.registerAttendance(registerRequest); + @RequestBody AttendanceRegisterRequest registerRequest) { + String title = registerRequest.getTitle(); + String batch = registerRequest.getBatch(); + Attendance attendance = attendanceService.registerAttendance(title, batch); AttendanceResponse response = AttendanceResponse.from(attendance, generateAttendUri(attendance)); return ResponseEntity.created(generateAttendanceUri(attendance)) .body(SuccessResponse.of(response)); diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceInfo.java b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceInfo.java new file mode 100644 index 0000000..85b19c9 --- /dev/null +++ b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceInfo.java @@ -0,0 +1,24 @@ +package gdsc.konkuk.platformcore.controller.attendance.dtos; + +import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; +import java.time.LocalDateTime; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Builder +public class AttendanceInfo { + private Long attendanceId; + private String title; + private LocalDateTime attendanceTime; + + public static AttendanceInfo from(Attendance attendance) { + return AttendanceInfo.builder() + .attendanceId(attendance.getId()) + .title(attendance.getTitle()) + .attendanceTime(attendance.getAttendanceTime()) + .build(); + } +} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceRegisterRequest.java b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceRegisterRequest.java index 6c80daa..e6ad711 100644 --- a/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceRegisterRequest.java +++ b/src/main/java/gdsc/konkuk/platformcore/controller/attendance/dtos/AttendanceRegisterRequest.java @@ -1,8 +1,6 @@ package gdsc.konkuk.platformcore.controller.attendance.dtos; -import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Builder; import lombok.Getter; import lombok.Setter; @@ -11,12 +9,8 @@ @Setter @Builder public class AttendanceRegisterRequest { - @NotNull - private Long eventId; + @NotEmpty + private String title; @NotEmpty private String batch; - - public static Attendance toEntity(AttendanceRegisterRequest request) { - return Attendance.builder().eventId(request.getEventId()).build(); - } } diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/EventController.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/EventController.java deleted file mode 100644 index d0b1510..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/EventController.java +++ /dev/null @@ -1,88 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event; - -import gdsc.konkuk.platformcore.application.event.EventService; -import gdsc.konkuk.platformcore.controller.event.dtos.EventBriefResponse; -import gdsc.konkuk.platformcore.controller.event.dtos.EventDetailResponse; -import gdsc.konkuk.platformcore.controller.event.dtos.EventRegisterRequest; -import gdsc.konkuk.platformcore.controller.event.dtos.EventUpdateRequest; -import gdsc.konkuk.platformcore.controller.event.dtos.RetrospectUpdateRequest; -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import gdsc.konkuk.platformcore.global.responses.SuccessResponse; -import jakarta.validation.Valid; -import java.io.IOException; -import lombok.RequiredArgsConstructor; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -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 org.springframework.web.servlet.support.ServletUriComponentsBuilder; - -import java.net.URI; -import java.util.List; - -@RestController -@RequestMapping("/api/v1/events") -@RequiredArgsConstructor -public class EventController { - private final EventService eventService; - - @GetMapping - public ResponseEntity getAll() { - EventBriefResponse eventBriefs = eventService.getAllBriefs(); - return ResponseEntity.ok(SuccessResponse.of(eventBriefs)); - } - - @GetMapping("/{eventId}") - public ResponseEntity getEvent(@PathVariable Long eventId) { - EventDetailResponse eventDetailResponse = eventService.getEvent(eventId); - return ResponseEntity.ok(SuccessResponse.of(eventDetailResponse)); - } - - @PostMapping - public ResponseEntity register( - @RequestPart("detail") @Valid EventRegisterRequest registerRequest, - @RequestPart(value = "images", required = false) List imageFiles) - throws IOException { - Event newEvent = eventService.register(registerRequest, imageFiles); - return ResponseEntity.created(getCreatedURI(newEvent.getId())) - .body(SuccessResponse.messageOnly()); - } - - @PatchMapping("/{eventId}") - public ResponseEntity update( - @PathVariable Long eventId, - @RequestPart(value = "detail") @Valid EventUpdateRequest updateRequest, - @RequestPart(value = "new-images", required = false) List files) - throws IOException { - eventService.update(eventId, updateRequest, files); - return ResponseEntity.ok(SuccessResponse.messageOnly()); - } - - @PatchMapping("/{eventId}/retrospect") - public ResponseEntity updateRetrospect( - @PathVariable Long eventId, @RequestBody @Valid RetrospectUpdateRequest updateRequest) { - eventService.updateRetrospect(eventId, updateRequest.getContent()); - return ResponseEntity.ok(SuccessResponse.messageOnly()); - } - - @DeleteMapping("/{eventId}") - public ResponseEntity delete(@PathVariable Long eventId) { - eventService.delete(eventId); - return ResponseEntity.noContent().build(); - } - - private URI getCreatedURI(Long memberId) { - return ServletUriComponentsBuilder.fromCurrentRequest() - .path("/{id}") - .buildAndExpand(memberId) - .toUri(); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventBriefResponse.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventBriefResponse.java deleted file mode 100644 index 9aaa0c0..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventBriefResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event.dtos; - -import gdsc.konkuk.platformcore.application.event.dtos.EventBrief; -import java.util.List; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@Builder -public class EventBriefResponse { - private List eventBriefs; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventDetailResponse.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventDetailResponse.java deleted file mode 100644 index d0a964a..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventDetailResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event.dtos; - -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import java.net.URL; -import java.time.LocalDateTime; -import java.util.List; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@Builder -public class EventDetailResponse { - private Long id; - private String title; - private String content; - private String location; - private LocalDateTime startAt; - private LocalDateTime endAt; - private List images; - private String retrospect; - - @Builder - public EventDetailResponse( - Long id, - String title, - String content, - String location, - LocalDateTime startAt, - LocalDateTime endAt, - List images, - String retrospect) { - this.id = id; - this.title = title; - this.content = content; - this.location = location; - this.startAt = startAt; - this.endAt = endAt; - this.images = images; - this.retrospect = retrospect; - } - - public static EventDetailResponse fromEntity(Event event) { - return EventDetailResponse.builder() - .id(event.getId()) - .title(event.getTitle()) - .content(event.getContent()) - .location(event.getLocation()) - .startAt(event.getStartAt()) - .endAt(event.getEndAt()) - .images(event.getEventImageUrls()) - .retrospect(event.getRetrospect().getContent()) - .build(); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventRegisterRequest.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventRegisterRequest.java deleted file mode 100644 index ece7cb7..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventRegisterRequest.java +++ /dev/null @@ -1,32 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event.dtos; - -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalDateTime; - -@Getter -@Setter -@Builder -public class EventRegisterRequest { - @NotEmpty private String title; - @NotNull private String content; - @NotNull private String location; - @NotNull private LocalDateTime startAt; - @NotNull private LocalDateTime endAt; - - public static Event toEntity(EventRegisterRequest request) { - return Event.builder() - .title(request.getTitle()) - .content(request.getContent()) - .location(request.getLocation()) - .startAt(request.getStartAt()) - .endAt(request.getEndAt()) - .retrospectContent("내용이 없습니다.") - .build(); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventUpdateRequest.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventUpdateRequest.java deleted file mode 100644 index c99a3e3..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/EventUpdateRequest.java +++ /dev/null @@ -1,20 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event.dtos; - -import java.net.URL; -import java.time.LocalDateTime; -import java.util.List; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@Builder -public class EventUpdateRequest { - private String title; - private String content; - private String location; - private LocalDateTime startAt; - private LocalDateTime endAt; - private List eventImagesToDelete; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/RetrospectUpdateRequest.java b/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/RetrospectUpdateRequest.java deleted file mode 100644 index e252e1c..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/controller/event/dtos/RetrospectUpdateRequest.java +++ /dev/null @@ -1,17 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event.dtos; - -import jakarta.validation.constraints.NotEmpty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class RetrospectUpdateRequest { - @NotEmpty private String content; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/entity/Attendance.java b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/entity/Attendance.java index 86245e4..475e636 100644 --- a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/entity/Attendance.java +++ b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/entity/Attendance.java @@ -7,6 +7,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -22,16 +23,20 @@ public class Attendance { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "event_id") - private Long eventId; + @Column(name = "title") + private String title; + + @Column(name = "attendance_time") + private LocalDateTime attendanceTime; @Column(name = "active_qr_uuid") private String activeQrUuid; @Builder - public Attendance(Long id, Long eventId, String activeQrUuid) { + public Attendance(Long id, String title, LocalDateTime attendanceTime, String activeQrUuid) { this.id = id; - this.eventId = eventId; + this.title = title; + this.attendanceTime = attendanceTime; this.activeQrUuid = activeQrUuid; } diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/AttendanceRepository.java b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/AttendanceRepository.java index 17851d9..441eeac 100644 --- a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/AttendanceRepository.java +++ b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/AttendanceRepository.java @@ -5,21 +5,20 @@ import java.time.LocalDateTime; import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; public interface AttendanceRepository extends JpaRepository { - Optional findByEventId(Long aLong); - + @Query("SELECT a FROM Attendance a WHERE a.attendanceTime BETWEEN :st AND :en") + List findAllByPeriod(LocalDateTime st, LocalDateTime en); + @Query("SELECT new gdsc.konkuk.platformcore.application.attendance.dtos.MemberAttendanceQueryDto(" + - "e.id, m.id, m.name, m.role, m.department, p.id, a.id, e.startAt, p.isAttended) " + + "m.id, m.name, m.role, m.department, p.id, a.id, a.attendanceTime, p.isAttended) " + "FROM Attendance a " + "LEFT JOIN Participant p ON p.attendance.id = a.id " + - "LEFT JOIN Event e ON p.attendance.eventId = e.id " + "LEFT JOIN Member m ON m.id = p.memberId " + "WHERE m.batch = :batch " + - "AND e.startAt BETWEEN :st AND :en") + "AND a.attendanceTime BETWEEN :st AND :en") List findAllAttendanceInfoByBatchAndPeriod(String batch, LocalDateTime st, LocalDateTime en); } diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/ParticipantRepository.java b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/ParticipantRepository.java index e89d68f..3621800 100644 --- a/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/ParticipantRepository.java +++ b/src/main/java/gdsc/konkuk/platformcore/domain/attendance/repository/ParticipantRepository.java @@ -20,8 +20,7 @@ public interface ParticipantRepository extends JpaRepository FROM Member m LEFT JOIN Participant p ON m.id = p.memberId LEFT JOIN Attendance a ON p.attendance.id = a.id - LEFT JOIN Event e ON a.eventId = e.id - WHERE m.batch = :batch AND e.startAt BETWEEN :st AND :en + WHERE m.batch = :batch AND a.attendanceTime BETWEEN :st AND :en """) List findAllByBatchAndStartAtBetween( String batch, LocalDateTime st, LocalDateTime en); diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Event.java b/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Event.java deleted file mode 100644 index 8f0fa2e..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Event.java +++ /dev/null @@ -1,105 +0,0 @@ -package gdsc.konkuk.platformcore.domain.event.entity; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Embedded; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.time.LocalDateTime; - -import static gdsc.konkuk.platformcore.global.utils.FieldValidator.validateNotNull; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Event { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "title") - private String title; - - @Column(name = "content", columnDefinition = "TEXT") - private String content; - - @Column(name = "location") - private String location; - - @Column(name = "start_at") - private LocalDateTime startAt; - - @Column(name = "end_at") - private LocalDateTime endAt; - - @OneToMany(mappedBy = "eventId", cascade = CascadeType.ALL, orphanRemoval = true) - private List eventImageList; - - @Embedded private Retrospect retrospect; - - @Builder - public Event( - Long id, - String title, - String content, - String location, - LocalDateTime startAt, - LocalDateTime endAt, - List eventImageList, - String retrospectContent) { - this.id = id; - this.title = validateNotNull(title, "title"); - this.content = validateNotNull(content, "content"); - this.location = validateNotNull(location, "location"); - this.startAt = validateNotNull(startAt, "startAt"); - this.endAt = validateNotNull(endAt, "endAt"); - this.eventImageList = eventImageList == null ? new ArrayList<>() : eventImageList; - this.retrospect = Retrospect.builder().content(retrospectContent).build(); - } - - public Optional getThumbnail() { - try { - // Event의 첫 사진을 썸네일로 사용 - return Optional.of(this.eventImageList.get(0).getUrl()); - } catch (Exception e) { - return Optional.empty(); - } - } - - public List getEventImageUrls() { - return this.eventImageList.stream().map(EventImage::getUrl).toList(); - } - - public void addEventImageByUrl(URL imageUrl) { - EventImage eventImage = new EventImage(this.id, imageUrl); - this.eventImageList.add(eventImage); - } - - public void deleteEventImageByUrl(URL imageUrl) { - this.eventImageList.removeIf(eventImage -> eventImage.isUrlEqual(imageUrl)); - } - - public void updateRetrospectContent(String content) { - this.retrospect.updateContent(content); - } - - public void update(String title, String content, String location, LocalDateTime startAt, LocalDateTime endAt) { - if (title != null) this.title = title; - if (content != null) this.content = content; - if (location != null) this.location = location; - if (startAt != null) this.startAt = startAt; - if (endAt != null) this.endAt = endAt; - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/EventImage.java b/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/EventImage.java deleted file mode 100644 index 15995c8..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/EventImage.java +++ /dev/null @@ -1,37 +0,0 @@ -package gdsc.konkuk.platformcore.domain.event.entity; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import java.net.URL; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class EventImage { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "event_id") - private Long eventId; - - @Column(name = "url") - private URL url; - - @Builder - public EventImage(Long eventId, URL url) { - this.eventId = eventId; - this.url = url; - } - - public boolean isUrlEqual(URL imageKey) { - return url.equals(imageKey); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Retrospect.java b/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Retrospect.java deleted file mode 100644 index 87c5f25..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/domain/event/entity/Retrospect.java +++ /dev/null @@ -1,27 +0,0 @@ -package gdsc.konkuk.platformcore.domain.event.entity; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import static gdsc.konkuk.platformcore.global.utils.FieldValidator.validateNotNull; - -@Embeddable -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Retrospect { - @Column(name = "retrospect_content", columnDefinition = "TEXT") - private String content; - - @Builder - public Retrospect(String content) { - this.content = validateNotNull(content, "content"); - } - - public void updateContent(String content) { - this.content = validateNotNull(content, "content"); - } -} diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/event/repository/EventRepository.java b/src/main/java/gdsc/konkuk/platformcore/domain/event/repository/EventRepository.java deleted file mode 100644 index 399a71c..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/domain/event/repository/EventRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package gdsc.konkuk.platformcore.domain.event.repository; - -import gdsc.konkuk.platformcore.application.event.dtos.EventWithAttendance; -import gdsc.konkuk.platformcore.domain.event.entity.Event; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; - -import java.time.LocalDateTime; -import java.util.List; - -public interface EventRepository extends JpaRepository { - @Query( - """ - SELECT new gdsc.konkuk.platformcore.application.event.dtos.EventWithAttendance( - e.id, a.id, e.title, e.startAt - ) - FROM Event e - lEFT JOIN Attendance a ON e.id = a.eventId - WHERE e.startAt BETWEEN :st AND :en - """) - List findAllWithAttendanceByStartAtBetween( - LocalDateTime st, LocalDateTime en); - - @Query( - """ - SELECT e - FROM Event e - LEFT JOIN FETCH e.eventImageList - """) - List findAll(); -} diff --git a/src/main/java/gdsc/konkuk/platformcore/domain/member/entity/Member.java b/src/main/java/gdsc/konkuk/platformcore/domain/member/entity/Member.java index bafd8d1..a432b9e 100644 --- a/src/main/java/gdsc/konkuk/platformcore/domain/member/entity/Member.java +++ b/src/main/java/gdsc/konkuk/platformcore/domain/member/entity/Member.java @@ -40,10 +40,6 @@ public class Member { @Column(name = "member_email") private String email; - // 현 기능 상 Member Profile Image의 사용처가 없음 - // @Column(name = "profile_image_url") - // private String profileImageUrl; - @Column(name = "department") private String department; @@ -78,7 +74,6 @@ public Member( String studentId, String name, String email, - // String profileImageUrl, String department, String role, String batch) { @@ -86,7 +81,6 @@ public Member( this.studentId = validateNotNull(studentId, "studentId"); this.name = validateNotNull(name, "name"); this.email = validateNotNull(email, "email"); - // this.profileImageUrl = profileImageUrl; this.department = validateNotNull(department, "department"); this.role = (role != null) ? MemberRole.from(role) : MemberRole.MEMBER; this.batch = validateNotNull(batch, "batch"); diff --git a/src/main/java/gdsc/konkuk/platformcore/external/s3/S3Properties.java b/src/main/java/gdsc/konkuk/platformcore/external/s3/S3Properties.java deleted file mode 100644 index 9ce8580..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/external/s3/S3Properties.java +++ /dev/null @@ -1,17 +0,0 @@ -package gdsc.konkuk.platformcore.external.s3; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Getter -@Setter -@Configuration -public class S3Properties { - @Value("${spring.cloud.aws.s3.bucket}") - private String bucket; - - @Value("${spring.cloud.aws.region.static}") - private String region; -} diff --git a/src/main/java/gdsc/konkuk/platformcore/external/s3/StorageClient.java b/src/main/java/gdsc/konkuk/platformcore/external/s3/StorageClient.java deleted file mode 100644 index 9ea9d88..0000000 --- a/src/main/java/gdsc/konkuk/platformcore/external/s3/StorageClient.java +++ /dev/null @@ -1,80 +0,0 @@ -package gdsc.konkuk.platformcore.external.s3; - -import static java.util.UUID.randomUUID; - -import io.awspring.cloud.s3.S3Template; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.function.Consumer; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -@Slf4j -@Component -@RequiredArgsConstructor -public class StorageClient { - private final S3Properties s3Properties; - private final S3Template s3Template; - - public List uploadFiles(List files, Consumer fileValidator) - throws IOException { - List objectUrls = new ArrayList<>(); - - if (files == null) throw new IllegalArgumentException("files is null"); - - for (MultipartFile file : files) { - fileValidator.accept(file); - String objectKey = genObjectKey(file.getOriginalFilename()); - s3Template.upload(s3Properties.getBucket(), objectKey, file.getInputStream()); - objectUrls.add(genObjectUrl(objectKey)); - } - return objectUrls; - } - - public void deleteFiles(List objectUrls) { - if (objectUrls == null) throw new IllegalArgumentException("objectUrls is null"); - - for (URL objectUrl : objectUrls) { - s3Template.deleteObject(s3Properties.getBucket(), extractObjectKeyFromUrl(objectUrl)); - } - } - - private String extractObjectKeyFromUrl(URL url) { - String baseUrl = - "https://" - + s3Properties.getBucket() - + ".s3." - + s3Properties.getRegion() - + ".amazonaws.com/"; - - if (url.toString().startsWith(baseUrl)) { - return url.toString().substring(baseUrl.length()); - } else { - throw new IllegalArgumentException("주어진 URL이 S3 Object URL이 아닙니다."); - } - } - - private URL genObjectUrl(String objectKey) throws MalformedURLException { - return new URL( - "https://" - + s3Properties.getBucket() - + ".s3." - + s3Properties.getRegion() - + ".amazonaws.com/" - + objectKey); - } - - private String genObjectKey(String filename) { - return randomUUID() + extractExtension(filename); - } - - private String extractExtension(String filename) { - return Objects.requireNonNull(filename).substring(filename.lastIndexOf(".")); - } -} diff --git a/src/main/resources/application-prod.yaml b/src/main/resources/application-prod.yaml index 2065893..bf12399 100644 --- a/src/main/resources/application-prod.yaml +++ b/src/main/resources/application-prod.yaml @@ -32,15 +32,6 @@ spring: auth: true starttls: enable: true - cloud: - aws: - credentials: - access-key: ${AWS_ACCESS_KEY} - secret-key: ${AWS_SECRET_KEY} - region: - static: ${AWS_REGION} - s3: - bucket: ${AWS_S3_BUCKET} jwt: secret: ${JWT_SECRET} diff --git a/src/test/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceControllerTest.java b/src/test/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceControllerTest.java index 3ca2029..7afc6d9 100644 --- a/src/test/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceControllerTest.java +++ b/src/test/java/gdsc/konkuk/platformcore/controller/attendance/AttendanceControllerTest.java @@ -7,7 +7,6 @@ import gdsc.konkuk.platformcore.application.attendance.AttendanceService; import gdsc.konkuk.platformcore.application.attendance.dtos.AttendanceStatus; import gdsc.konkuk.platformcore.application.auth.JwtTokenProvider; -import gdsc.konkuk.platformcore.application.event.EventService; import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceRegisterRequest; import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; @@ -16,7 +15,6 @@ import gdsc.konkuk.platformcore.fixture.attendance.AttendanceFixture; import gdsc.konkuk.platformcore.fixture.attendance.AttendanceRegisterRequestFixture; import gdsc.konkuk.platformcore.fixture.attendance.ParticipantFixture; -import gdsc.konkuk.platformcore.fixture.event.EventWithAttendanceFixture; import gdsc.konkuk.platformcore.fixture.member.MemberFixture; import java.time.LocalDate; import java.time.LocalDateTime; @@ -37,7 +35,6 @@ import static com.epages.restdocs.apispec.ResourceDocumentation.headerWithName; import static com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName; import static com.epages.restdocs.apispec.ResourceDocumentation.resource; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willDoNothing; import static org.springframework.http.MediaType.APPLICATION_JSON; @@ -63,7 +60,6 @@ class AttendanceControllerTest { @Autowired private JwtTokenProvider jwtTokenProvider; @MockBean private AttendanceService attendanceService; - @MockBean private EventService eventService; @BeforeEach void setUp( @@ -82,23 +78,20 @@ void should_get_events_of_the_month_when_pass_year_month() throws Exception { // given Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); String jwt = jwtTokenProvider.createToken(member); - given(eventService.getEventsOfTheMonthWithAttendance(LocalDate.of(2024, 7, 1))) + given(attendanceService.getAllByPeriod(LocalDate.of(2024, 7, 1))) .willReturn( List.of( - EventWithAttendanceFixture.builder() - .eventId(1L) - .attendanceId(1L) - .startAt(LocalDateTime.of(2024, 7, 1, 15, 30)) + AttendanceFixture.builder() + .id(1L) + .attendanceTime(LocalDateTime.of(2024, 7, 1, 15, 30)) .build().getFixture(), - EventWithAttendanceFixture.builder() - .eventId(2L) - .attendanceId(null) - .startAt(LocalDateTime.of(2024, 7, 15, 15, 30)) + AttendanceFixture.builder() + .id(2L) + .attendanceTime(LocalDateTime.of(2024, 7, 15, 15, 30)) .build().getFixture(), - EventWithAttendanceFixture.builder() - .eventId(3L) - .attendanceId(2L) - .startAt(LocalDateTime.of(2024, 7, 21, 15, 30)) + AttendanceFixture.builder() + .id(3L) + .attendanceTime(LocalDateTime.of(2024, 7, 21, 15, 30)) .build().getFixture())); // when @@ -129,10 +122,9 @@ void should_get_events_of_the_month_when_pass_year_month() throws Exception { .responseFields( fieldWithPath("success").description("성공 여부"), fieldWithPath("message").description("메시지"), - fieldWithPath("data[].eventId").description("이벤트 ID"), fieldWithPath("data[].attendanceId").description("출석 ID").optional(), - fieldWithPath("data[].title").description("이벤트 제목"), - fieldWithPath("data[].startAt").description("이벤트 시작 시간")) + fieldWithPath("data[].title").description("출석 제목"), + fieldWithPath("data[].attendanceTime").description("출석 시간")) .build()))); } @@ -187,12 +179,11 @@ void should_register_attendance_when_pass_event_id() throws Exception { // given Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); String jwt = jwtTokenProvider.createToken(member); - AttendanceRegisterRequest registerRequest = AttendanceRegisterRequestFixture.builder() - .eventId(1L).build().getFixture(); + AttendanceRegisterRequest registerRequest = AttendanceRegisterRequestFixture.builder().build().getFixture(); Attendance attendanceToRegister = AttendanceFixture.builder() - .eventId(1L).build().getFixture(); - given(attendanceService.registerAttendance(any(AttendanceRegisterRequest.class))) - .willReturn(attendanceToRegister); + .title(registerRequest.getTitle()).build().getFixture(); + given(attendanceService.registerAttendance(registerRequest.getTitle(), registerRequest.getBatch())) + .willReturn(attendanceToRegister); // when ResultActions result = diff --git a/src/test/java/gdsc/konkuk/platformcore/controller/event/EventControllerTest.java b/src/test/java/gdsc/konkuk/platformcore/controller/event/EventControllerTest.java deleted file mode 100644 index 01879d9..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/controller/event/EventControllerTest.java +++ /dev/null @@ -1,408 +0,0 @@ -package gdsc.konkuk.platformcore.controller.event; - -import static com.epages.restdocs.apispec.ResourceDocumentation.headerWithName; -import static com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName; -import static com.epages.restdocs.apispec.ResourceDocumentation.resource; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.mockito.MockitoAnnotations.openMocks; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; -import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.epages.restdocs.apispec.ResourceSnippetParameters; -import com.fasterxml.jackson.databind.ObjectMapper; -import gdsc.konkuk.platformcore.annotation.RestDocsTest; -import gdsc.konkuk.platformcore.application.auth.JwtTokenProvider; -import gdsc.konkuk.platformcore.application.event.EventService; -import gdsc.konkuk.platformcore.controller.event.dtos.EventDetailResponse; -import gdsc.konkuk.platformcore.controller.event.dtos.EventRegisterRequest; -import gdsc.konkuk.platformcore.controller.event.dtos.EventUpdateRequest; -import gdsc.konkuk.platformcore.controller.event.dtos.RetrospectUpdateRequest; -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import gdsc.konkuk.platformcore.domain.member.entity.Member; -import gdsc.konkuk.platformcore.domain.member.entity.MemberRole; -import gdsc.konkuk.platformcore.fixture.event.EventBriefResponseFixture; -import gdsc.konkuk.platformcore.fixture.event.EventFixture; -import gdsc.konkuk.platformcore.fixture.event.EventRegisterRequestFixture; -import gdsc.konkuk.platformcore.fixture.event.EventUpdateRequestFixture; -import gdsc.konkuk.platformcore.fixture.member.MemberFixture; -import java.util.List; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.restdocs.RestDocumentationContextProvider; -import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultActions; -import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.multipart.MultipartFile; - -@RestDocsTest -@SpringBootTest -public class EventControllerTest { - - private MockMvc mockMvc; - - @MockBean private EventService eventService; - - @Autowired private ObjectMapper objectMapper; - @Autowired private JwtTokenProvider jwtTokenProvider; - - @BeforeEach - void setUp( - WebApplicationContext webApplicationContext, - RestDocumentationContextProvider restDocumentation) { - openMocks(this); - mockMvc = - MockMvcBuilders.webAppContextSetup(webApplicationContext) - .apply(documentationConfiguration(restDocumentation)) - .apply(springSecurity()) - .build(); - } - - @Test - @DisplayName("모든 이벤트를 간략 조회할 수 있다") - void should_get_all_events_when_request() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - given(eventService.getAllBriefs()).willReturn(EventBriefResponseFixture.builder().build().getFixture()); - - // when - ResultActions result = - mockMvc.perform(RestDocumentationRequestBuilders - .get("/api/v1/events") - .header("Authorization", "Bearer " + jwt) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isOk()) - .andDo( - document( - "getAllEvents", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("모든 이벤트를 조회할 수 있다") - .tag("events") - .responseFields( - fieldWithPath("success").description("성공 여부"), - fieldWithPath("message").description("메시지"), - fieldWithPath("data.eventBriefs[].id").description("이벤트 ID"), - fieldWithPath("data.eventBriefs[].title").description("이벤트 제목"), - fieldWithPath("data.eventBriefs[].content").description("이벤트 내용"), - fieldWithPath("data.eventBriefs[].startAt").description("이벤트 시작 시간"), - fieldWithPath("data.eventBriefs[].thumbnail").description("썸네일 URL").optional()) - .build()))); - } - - @Test - @DisplayName("특정 이벤트를 상세 조회할 수 있다") - void should_get_event_detail_when_pass_event_id() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - Event eventToSee = EventFixture.builder() - .id(1L).build().getFixture(); - given(eventService.getEvent(eventToSee.getId())).willReturn(EventDetailResponse.fromEntity(eventToSee)); - - // when - ResultActions result = - mockMvc.perform( - RestDocumentationRequestBuilders - .get("/api/v1/events/{eventId}", 1L) - .header("Authorization", "Bearer " + jwt) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isOk()) - .andDo( - document( - "getEvent", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("특정 이벤트를 상세 조회할 수 있다") - .tag("events") - .pathParameters(parameterWithName("eventId").description("이벤트 ID")) - .responseFields( - fieldWithPath("success").description("성공 여부"), - fieldWithPath("message").description("메시지"), - fieldWithPath("data.id").description("이벤트 ID"), - fieldWithPath("data.title").description("이벤트 제목"), - fieldWithPath("data.content").description("이벤트 내용"), - fieldWithPath("data.location").description("이벤트 장소"), - fieldWithPath("data.startAt").description("이벤트 시작 시간"), - fieldWithPath("data.endAt").description("이벤트 종료 시간"), - fieldWithPath("data.images[]").description("이미지 URL"), - fieldWithPath("data.retrospect").description("회고 내용")) - .build()))); - } - - @Test - @DisplayName("이벤트를 등록할 수 있다") - void should_register_event_when_requested() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - EventRegisterRequest eventRegisterRequest = EventRegisterRequestFixture.builder().build().getFixture(); - given(eventService.register(any(EventRegisterRequest.class), any(List.class))) - .willReturn(EventFixture.builder().build().getFixture()); - - MockMultipartFile mockImages = - new MockMultipartFile("images", "test.jpg", "image/jpeg", "test".getBytes()); - MockMultipartFile mockDetail = - new MockMultipartFile( - "detail", - "", - "application/json", - objectMapper.writeValueAsString(eventRegisterRequest).getBytes()); - String mockRequestBodyForDocument = - objectMapper.writeValueAsString( - new Object() { - public final Object detail = eventRegisterRequest; - public final List images = List.of(); - }); - - // when - ResultActions result = - mockMvc.perform( - RestDocumentationRequestBuilders - .multipart("/api/v1/events") - .file(mockImages) - .file(mockDetail) - .header("Authorization", "Bearer " + jwt) - .content(mockRequestBodyForDocument) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isCreated()) - .andDo( - document( - "registerEvent", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("이벤트를 등록할 수 있다") - .tag("events") - .responseHeaders(headerWithName("Location").description("등록한 Event URI")) - .requestFields( - fieldWithPath("detail") - .description( - """ - 이벤트 정보 - - title(String): 이벤트 제목 - - content(String): 이벤트 내용 - - location(String): 이벤트 장소 - - startAt(DateTime): 이벤트 시작 시간 - - endAt(DateTime): 이벤트 종료 시간 - """), - fieldWithPath("detail.title").description("이벤트 제목"), - fieldWithPath("detail.content").description("이벤트 내용"), - fieldWithPath("detail.location").description("이벤트 장소"), - fieldWithPath("detail.startAt").description("이벤트 시작 시간"), - fieldWithPath("detail.endAt").description("이벤트 종료 시간"), - fieldWithPath("images[]").description("이미지 파일 목록 (여러개)").optional()) - .responseFields( - fieldWithPath("success").description("성공 여부"), - fieldWithPath("message").description("메시지"), - fieldWithPath("data").description("null")) - .build()))); - } - - @Test - @DisplayName("이벤트를 수정할 수 있다") - void should_update_event_when_requested() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - EventUpdateRequest eventUpdateRequest = EventUpdateRequestFixture.builder().build().getFixture(); - willDoNothing().given(eventService) - .update(any(Long.class), any(EventUpdateRequest.class), any(List.class)); - - MockMultipartFile mockImages = - new MockMultipartFile("new-images", "test.jpg", "image/jpeg", "test".getBytes()); - MockMultipartFile mockDetail = - new MockMultipartFile( - "detail", - "", - "application/json", - objectMapper.writeValueAsString(eventUpdateRequest).getBytes()); - String mockRequestBodyForDocument = - objectMapper.writeValueAsString( - new Object() { - public final Object detail = eventUpdateRequest; - public final List newImages = List.of(); - }); - - // when - MockMultipartHttpServletRequestBuilder putMultipartRestDocumentationRequestBuilder = - RestDocumentationRequestBuilders - .multipart("/api/v1/events/{eventId}", 1L); - putMultipartRestDocumentationRequestBuilder.with( - request -> { - request.setMethod("PATCH"); - return request; - }); - - ResultActions result = - mockMvc.perform( - putMultipartRestDocumentationRequestBuilder - .file(mockImages) - .file(mockDetail) - .header("Authorization", "Bearer " + jwt) - .content(mockRequestBodyForDocument) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isOk()) - .andDo( - document( - "updateEvent", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("이벤트를 수정할 수 있다") - .tag("events") - .pathParameters(parameterWithName("eventId").description("이벤트 ID")) - .requestFields( - fieldWithPath("newImages[]") - .description( - """ - **주의! form field 이름은 `new-images`입니다.** - 새로 추가할 이미지 파일 목록 (여러개) - """) - .optional(), - fieldWithPath("detail") - .description( - """ - 이벤트 정보 - - title(String?): 이벤트 제목 - - content(String?): 이벤트 내용 - - location(String?): 이벤트 장소 - - startAt(DateTime?): 이벤트 시작 시간 - - endAt(DateTime?): 이벤트 종료 시간 - - eventImagesToDelete(URL[]?): 삭제할 이미지 URL 목록 - """), - fieldWithPath("detail.title").description("이벤트 제목").optional(), - fieldWithPath("detail.content").description("이벤트 내용").optional(), - fieldWithPath("detail.location").description("이벤트 장소").optional(), - fieldWithPath("detail.startAt").description("이벤트 시작 시간").optional(), - fieldWithPath("detail.endAt").description("이벤트 종료 시간").optional(), - fieldWithPath("detail.eventImagesToDelete[]") - .description("삭제할 이미지 Key 목록").optional()) - .responseFields( - fieldWithPath("success").description("성공 여부"), - fieldWithPath("message").description("메시지"), - fieldWithPath("data").description("null")) - .build()))); - } - - @Test - @DisplayName("회고 수정 성공") - void should_update_retrospect_when_pass_content() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - Event eventToUpdateRetrospect = EventFixture.builder() - .id(1L).build().getFixture(); - RetrospectUpdateRequest retrospectUpdateRequest = new RetrospectUpdateRequest("content"); - willDoNothing().given(eventService) - .updateRetrospect(eventToUpdateRetrospect.getId(), "content"); - - // when - ResultActions result = - mockMvc.perform( - RestDocumentationRequestBuilders - .patch("/api/v1/events/{eventId}/retrospect", 1L) - .header("Authorization", "Bearer " + jwt) - .content(objectMapper.writeValueAsString(retrospectUpdateRequest)) - .contentType(APPLICATION_JSON) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isOk()) - .andDo( - document( - "updateRetrospect", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("회고를 수정할 수 있다") - .tag("events") - .pathParameters(parameterWithName("eventId").description("이벤트 ID")) - .requestFields(fieldWithPath("content").description("회고 내용")) - .responseFields( - fieldWithPath("success").description("성공 여부"), - fieldWithPath("message").description("메시지"), - fieldWithPath("data").description("null")) - .build()))); - } - - @Test - @DisplayName("이벤트 삭제 성공") - void should_delete_event_when_pass_event_id() throws Exception { - // given - Member member = MemberFixture.builder().role(MemberRole.CORE).build().getFixture(); - String jwt = jwtTokenProvider.createToken(member); - Event eventToDelete = EventFixture.builder() - .id(1L).build().getFixture(); - willDoNothing().given(eventService).delete(eventToDelete.getId()); - - // when - ResultActions result = - mockMvc.perform( - RestDocumentationRequestBuilders - .delete("/api/v1/events/{eventId}", 1L) - .header("Authorization", "Bearer " + jwt) - .contentType(APPLICATION_JSON) - .with(csrf())); - - // then - result - .andDo(print()) - .andExpect(status().isNoContent()) - .andDo( - document( - "deleteEvent", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()), - resource( - ResourceSnippetParameters.builder() - .description("이벤트를 삭제할 수 있다") - .tag("events") - .pathParameters(parameterWithName("eventId").description("이벤트 ID")) - .build()))); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/controller/member/MemberControllerTest.java b/src/test/java/gdsc/konkuk/platformcore/controller/member/MemberControllerTest.java index 02bb614..8790498 100644 --- a/src/test/java/gdsc/konkuk/platformcore/controller/member/MemberControllerTest.java +++ b/src/test/java/gdsc/konkuk/platformcore/controller/member/MemberControllerTest.java @@ -210,7 +210,6 @@ void should_success_when_get_attendances_by_batch() throws Exception { fieldWithPath("data[].memberId").description("멤버 아이디"), fieldWithPath("data[].memberName").description("멤버 이름"), fieldWithPath("data[].memberRole").description("멤버 역할"), - // fieldWithPath("data[].profileImageUrl").description("멤버 프로필 이미지"), fieldWithPath("data[].department").description("멤버 학과"), fieldWithPath("data[].totalAttendances").description("전체 등록 횟수"), fieldWithPath("data[].actualAttendances").description("실제 출석 횟수"), diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceFixture.java index 185bd46..31f6b2f 100644 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceFixture.java +++ b/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceFixture.java @@ -3,6 +3,7 @@ import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance; +import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; @@ -11,10 +12,11 @@ public class AttendanceFixture { private final Attendance fixture; @Builder - public AttendanceFixture(Long id, Long eventId, String activeQrUuid) { + public AttendanceFixture(Long id, String title, LocalDateTime attendanceTime, String activeQrUuid) { this.fixture = Attendance.builder() .id(getDefault(id, 0L)) - .eventId(getDefault(eventId, 0L)) + .title(getDefault(title, "title")) + .attendanceTime(getDefault(attendanceTime, LocalDateTime.now())) .activeQrUuid(getDefault(activeQrUuid, "uuid")) .build(); } diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceRegisterRequestFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceRegisterRequestFixture.java index dd62329..6ee7246 100644 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceRegisterRequestFixture.java +++ b/src/test/java/gdsc/konkuk/platformcore/fixture/attendance/AttendanceRegisterRequestFixture.java @@ -8,13 +8,13 @@ @Getter public class AttendanceRegisterRequestFixture { - private final AttendanceRegisterRequest fixture; + private final AttendanceRegisterRequest fixture; - @Builder - public AttendanceRegisterRequestFixture(Long eventId, String batch) { - this.fixture = AttendanceRegisterRequest.builder() - .eventId(getDefault(eventId, 0L)) - .batch(getDefault(batch, "24-25")) - .build(); - } + @Builder + public AttendanceRegisterRequestFixture(String title, String batch) { + this.fixture = AttendanceRegisterRequest.builder() + .title(getDefault(title, "title")) + .batch(getDefault(batch, "batch")) + .build(); + } } diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventBriefResponseFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventBriefResponseFixture.java deleted file mode 100644 index 6a23ffc..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventBriefResponseFixture.java +++ /dev/null @@ -1,28 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.application.event.EventMapper.mapEventListToEventBriefList; -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.application.event.dtos.EventBrief; -import gdsc.konkuk.platformcore.controller.event.dtos.EventBriefResponse; -import java.net.MalformedURLException; -import java.util.List; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventBriefResponseFixture { - private final EventBriefResponse fixture; - - @Builder - public EventBriefResponseFixture(List eventBriefs) throws MalformedURLException { - this.fixture = EventBriefResponse.builder() - .eventBriefs(getDefault(eventBriefs, mapEventListToEventBriefList( - List.of( - EventFixture.builder().id(1L).build().getFixture(), - EventFixture.builder().id(2L).build().getFixture(), - EventFixture.builder().id(3L).build().getFixture() - )))) - .build(); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventFixture.java deleted file mode 100644 index 6cfcee7..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventFixture.java +++ /dev/null @@ -1,35 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.domain.event.entity.Event; -import gdsc.konkuk.platformcore.domain.event.entity.EventImage; -import java.net.MalformedURLException; -import java.net.URL; -import java.time.LocalDateTime; -import java.util.List; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventFixture { - private final Event fixture; - - @Builder - public EventFixture(Long id, String title, String content, String location, LocalDateTime startAt, LocalDateTime endAt, List eventImageList, String retrospectContent) - throws MalformedURLException { - this.fixture = Event.builder() - .id(getDefault(id, 0L)) - .title(getDefault(title, "title")) - .content(getDefault(content, "content")) - .location(getDefault(location, "location")) - .startAt(getDefault(startAt, LocalDateTime.now())) - .endAt(getDefault(endAt, LocalDateTime.now().plusHours(1))) - .eventImageList(getDefault(eventImageList, List.of( - EventImageFixture.builder().url(new URL("https://s3.com/foo/bar1.png")).build().getFixture(), - EventImageFixture.builder().url(new URL("https://s3.com/foo/bar2.jpeg")).build().getFixture() - ))) - .retrospectContent(getDefault(retrospectContent, "retrospect")) - .build(); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventImageFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventImageFixture.java deleted file mode 100644 index bd2d058..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventImageFixture.java +++ /dev/null @@ -1,22 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.domain.event.entity.EventImage; -import java.net.MalformedURLException; -import java.net.URL; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventImageFixture { - private final EventImage fixture; - - @Builder - public EventImageFixture(Long eventId, URL url) throws MalformedURLException { - this.fixture = EventImage.builder() - .eventId(getDefault(eventId, 0L)) - .url(getDefault(url, new URL("https://example.com/foo/bar.jpg"))) - .build(); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventRegisterRequestFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventRegisterRequestFixture.java deleted file mode 100644 index fa0e887..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventRegisterRequestFixture.java +++ /dev/null @@ -1,24 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.controller.event.dtos.EventRegisterRequest; -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventRegisterRequestFixture { - private final EventRegisterRequest fixture; - - @Builder - public EventRegisterRequestFixture(String title, String content, String location, LocalDateTime startAt, LocalDateTime endAt) { - this.fixture = EventRegisterRequest.builder() - .title(getDefault(title, "title")) - .content(getDefault(content, "content")) - .location(getDefault(location, "location")) - .startAt(getDefault(startAt, LocalDateTime.now())) - .endAt(getDefault(endAt, LocalDateTime.now().plusHours(1))) - .build(); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventUpdateRequestFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventUpdateRequestFixture.java deleted file mode 100644 index a6184f3..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventUpdateRequestFixture.java +++ /dev/null @@ -1,32 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.controller.event.dtos.EventUpdateRequest; -import java.net.MalformedURLException; -import java.net.URL; -import java.time.LocalDateTime; -import java.util.List; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventUpdateRequestFixture { - private final EventUpdateRequest fixture; - - @Builder - public EventUpdateRequestFixture(String title, String content, String location, LocalDateTime startAt, LocalDateTime endAt, List eventImagesToDelete) - throws MalformedURLException { - this.fixture = EventUpdateRequest.builder() - .title(getDefault(title, "title")) - .content(getDefault(content, "content")) - .location(getDefault(location, "location")) - .startAt(getDefault(startAt, LocalDateTime.now())) - .endAt(getDefault(endAt, LocalDateTime.now().plusHours(1))) - .eventImagesToDelete(getDefault(eventImagesToDelete, List.of( - EventImageFixture.builder().url(new URL("https://s3.com/foo/bar1.png")).build().getFixture().getUrl(), - EventImageFixture.builder().url(new URL("https://s3.com/foo/bar2.jpeg")).build().getFixture().getUrl() - ))) - .build(); - } -} diff --git a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventWithAttendanceFixture.java b/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventWithAttendanceFixture.java deleted file mode 100644 index 0fdbbea..0000000 --- a/src/test/java/gdsc/konkuk/platformcore/fixture/event/EventWithAttendanceFixture.java +++ /dev/null @@ -1,23 +0,0 @@ -package gdsc.konkuk.platformcore.fixture.event; - -import static gdsc.konkuk.platformcore.global.utils.GetDefault.getDefault; - -import gdsc.konkuk.platformcore.application.event.dtos.EventWithAttendance; -import java.time.LocalDateTime; -import lombok.Builder; -import lombok.Getter; - -@Getter -public class EventWithAttendanceFixture { - private final EventWithAttendance fixture; - - @Builder - public EventWithAttendanceFixture(Long eventId, Long attendanceId, String title, LocalDateTime startAt) { - this.fixture = EventWithAttendance.builder() - .eventId(getDefault(eventId, 0L)) - .attendanceId(getDefault(attendanceId, null)) - .title(getDefault(title, "title")) - .startAt(getDefault(startAt, LocalDateTime.now())) - .build(); - } -}