diff --git a/gg-calendar-api/build.gradle b/gg-calendar-api/build.gradle deleted file mode 100644 index 9d9883c0e..000000000 --- a/gg-calendar-api/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -plugins { - id 'java' -} - -group 'gg.api' -version '42gg' - -repositories { - mavenCentral() -} - -dependencies { - /* spring */ - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-mail' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - testImplementation testFixtures(project(':gg-utils')) -} - - -test { - useJUnitPlatform() -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/PrivateScheduleController.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/PrivateScheduleController.java deleted file mode 100644 index 659798186..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/PrivateScheduleController.java +++ /dev/null @@ -1,57 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.controller; - -import javax.validation.Valid; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import gg.auth.UserDto; -import gg.auth.argumentresolver.Login; -import gg.calendar.api.schedule.privateschedule.controller.request.PrivateScheduleCreateReqDto; -import gg.calendar.api.schedule.privateschedule.controller.request.PrivateScheduleUpdateReqDto; -import gg.calendar.api.schedule.privateschedule.controller.response.PrivateScheduleUpdateResDto; -import gg.calendar.api.schedule.privateschedule.service.PrivateScheduleService; -import gg.data.calendar.PrivateSchedule; -import io.swagger.v3.oas.annotations.Parameter; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/private") -public class PrivateScheduleController { - private final PrivateScheduleService privateScheduleService; - - public ResponseEntity createPrivateSchedule( - @Valid @ModelAttribute PrivateScheduleCreateReqDto privateScheduleCreateReqDto, - @Login @Parameter(hidden = true) UserDto userDto) { - privateScheduleService.createPrivateSchedule(userDto, privateScheduleCreateReqDto); - return ResponseEntity.status(HttpStatus.OK).build(); - } - - @PutMapping("/{scheduleId}/update") - public ResponseEntity updatePrivateSchedule(@PathVariable @Valid Long scheduleId, - @ModelAttribute @Valid PrivateScheduleUpdateReqDto privateScheduleUpdateReqDto, - @Login @Parameter(hidden = true) UserDto userDto) { - Long userId = userDto.getId(); - PrivateSchedule privateSchedule = privateScheduleService.updatePrivateSchedule(scheduleId, userId, - privateScheduleUpdateReqDto); - PrivateScheduleUpdateResDto responseDto = PrivateScheduleUpdateResDto.of(privateSchedule); - return ResponseEntity.status(HttpStatus.OK).body(responseDto); - } - - @PatchMapping("/{scheduleId}/delete") - public ResponseEntity deletePrivateSchedule(@PathVariable @Valid Long scheduleId, - @Login @Parameter(hidden = true) UserDto userDto) { - Long userId = userDto.getId(); - privateScheduleService.deletePrivateSchedule(scheduleId, userId); - return ResponseEntity.status(HttpStatus.OK).build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleCreateReqDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleCreateReqDto.java deleted file mode 100644 index 07d10ebca..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleCreateReqDto.java +++ /dev/null @@ -1,62 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.controller.request; - -import java.time.LocalDateTime; -import java.util.Set; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.springframework.format.annotation.DateTimeFormat; - -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PrivateScheduleCreateReqDto { - @NotNull - private DetailClassification classification; - - @NotNull - private Set tags; - - @NotBlank - @Size(max = 50, message = "제목은 50자이하로 입력해주세요.") - private String title; - - @Size(max = 2000, message = "내용은 2000자이하로 입력해주세요.") - private String content; - - private String link; - - @NotNull - private boolean alarm; - - private String color; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime startTime; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime endTime; - - public static PublicSchedule of(String author, PrivateScheduleCreateReqDto privateScheduleCreateReqDto) { - return PublicSchedule.builder() - .author(author) - .classification(privateScheduleCreateReqDto.classification) - .tags(privateScheduleCreateReqDto.tags) - .title(privateScheduleCreateReqDto.title) - .content(privateScheduleCreateReqDto.content) - .link(privateScheduleCreateReqDto.link) - .startTime(privateScheduleCreateReqDto.startTime) - .endTime(privateScheduleCreateReqDto.endTime) - .build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleUpdateReqDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleUpdateReqDto.java deleted file mode 100644 index d443d4580..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/request/PrivateScheduleUpdateReqDto.java +++ /dev/null @@ -1,55 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.controller.request; - -import java.time.LocalDateTime; -import java.util.Set; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.springframework.format.annotation.DateTimeFormat; - -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -public class PrivateScheduleUpdateReqDto { - - /* - * 공유 일정의 테이블 - */ - @NotNull - private DetailClassification detailClassification; - - @NotNull - private Set tags; - - @NotBlank - @Size(max = 50, message = "제목은 50자이하로 입력해주세요.") - private String title; - - @Size(max = 2000, message = "내용은 2000자이하로 입력해주세요.") - private String content; - - private String link; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime startTime; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime endTime; - - /* - * 개인 일정의 테이블 - */ - @NotNull - private boolean alarm; - - private String color; - -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleResDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleResDto.java deleted file mode 100644 index f3fa76864..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleResDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.controller.response; - -public class PrivateScheduleResDto { -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleUpdateResDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleUpdateResDto.java deleted file mode 100644 index b11e8fad0..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/controller/response/PrivateScheduleUpdateResDto.java +++ /dev/null @@ -1,68 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.controller.response; - -import java.time.LocalDateTime; -import java.util.Set; - -import gg.data.calendar.PrivateSchedule; -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PrivateScheduleUpdateResDto { - - private Long id; - - private DetailClassification detailClassification; - - private Set tags; - - private String title; - - private String content; - - private String link; - - private LocalDateTime startTime; - - private LocalDateTime endTime; - - private boolean alarm; - - private String color; - - @Builder - public PrivateScheduleUpdateResDto(Long id, DetailClassification detailClassification, Set tags, String title, - String content, String link, LocalDateTime startTime, LocalDateTime endTime, boolean alarm, String color) { - this.id = id; - this.detailClassification = detailClassification; - this.tags = tags; - this.title = title; - this.content = content; - this.link = link; - this.startTime = startTime; - this.endTime = endTime; - this.alarm = alarm; - this.color = color; - } - - public static PrivateScheduleUpdateResDto of(PrivateSchedule privateSchedule) { - - return PrivateScheduleUpdateResDto.builder() - .id(privateSchedule.getId()) - .detailClassification(privateSchedule.getPublicSchedule().getClassification()) - .tags(privateSchedule.getPublicSchedule().getTags()) - .title(privateSchedule.getPublicSchedule().getTitle()) - .content(privateSchedule.getPublicSchedule().getContent()) - .link(privateSchedule.getPublicSchedule().getLink()) - .startTime(privateSchedule.getPublicSchedule().getStartTime()) - .endTime(privateSchedule.getPublicSchedule().getEndTime()) - .alarm(privateSchedule.isAlarm()) - .color(privateSchedule.getColor()) - .build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/service/PrivateScheduleService.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/service/PrivateScheduleService.java deleted file mode 100644 index df4ab8d95..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/privateschedule/service/PrivateScheduleService.java +++ /dev/null @@ -1,79 +0,0 @@ -package gg.calendar.api.schedule.privateschedule.service; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import gg.auth.UserDto; -import gg.calendar.api.schedule.privateschedule.controller.request.PrivateScheduleCreateReqDto; -import gg.calendar.api.schedule.privateschedule.controller.request.PrivateScheduleUpdateReqDto; -import gg.data.calendar.PrivateSchedule; -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.type.DetailClassification; -import gg.data.calendar.type.ScheduleStatus; -import gg.data.user.User; -import gg.repo.calendar.PrivateScheduleRepository; -import gg.repo.calendar.PublicScheduleRepository; -import gg.repo.user.UserRepository; -import gg.utils.exception.user.UserNotFoundException; -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class PrivateScheduleService { - private final PrivateScheduleRepository privateScheduleRepository; - private final PublicScheduleRepository publicScheduleRepository; - private final UserRepository userRepository; - - @Transactional - public void createPrivateSchedule(UserDto userDto, PrivateScheduleCreateReqDto privateScheduleCreateReqDto) { - PublicSchedule publicSchedule = PrivateScheduleCreateReqDto.of(userDto.getIntraId(), - privateScheduleCreateReqDto); - publicScheduleRepository.save(publicSchedule); - User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); - PrivateSchedule privateSchedule = PrivateSchedule.of(user, publicSchedule, - privateScheduleCreateReqDto.getColor()); - privateScheduleRepository.save(privateSchedule); - } - - // Todo: 커스텀 에러 처리 - @Transactional - public PrivateSchedule updatePrivateSchedule(Long scheduleId, Long userId, - PrivateScheduleUpdateReqDto privateScheduleUpdateReqDto) { - if (privateScheduleUpdateReqDto.getStartTime().isAfter(privateScheduleUpdateReqDto.getEndTime())) { - throw new IllegalArgumentException("시작 시간이 종료 시간보다 늦을 수 없습니다."); - } - if (privateScheduleUpdateReqDto.getEndTime().isBefore(privateScheduleUpdateReqDto.getStartTime())) { - throw new IllegalArgumentException("종료 시간이 시작 시간보다 빠를 수 없습니다."); - } - if (privateScheduleUpdateReqDto.getEndTime().isEqual(privateScheduleUpdateReqDto.getStartTime())) { - throw new IllegalArgumentException("시작 시간과 종료 시간이 같을 수 없습니다."); - } - if (privateScheduleUpdateReqDto.getDetailClassification() != DetailClassification.NONE) { - throw new IllegalArgumentException("개인 일정이 아닙니다."); - } - PrivateSchedule privateSchedule = privateScheduleRepository.findByUserIdAndScheduleId(userId, scheduleId) - .orElseThrow(() -> new IllegalArgumentException("해당 일정이 없습니다.")); - privateSchedule.update(privateScheduleUpdateReqDto.getDetailClassification(), - privateScheduleUpdateReqDto.getTags(), privateScheduleUpdateReqDto.getTitle(), - privateScheduleUpdateReqDto.getContent(), privateScheduleUpdateReqDto.getLink(), - privateScheduleUpdateReqDto.getStartTime(), privateScheduleUpdateReqDto.getEndTime(), - privateScheduleUpdateReqDto.isAlarm(), privateScheduleUpdateReqDto.getColor()); - privateScheduleRepository.save(privateSchedule); - publicScheduleRepository.save(privateSchedule.getPublicSchedule()); - return privateSchedule; - } - - //Todo: 커스텀 에러 처리 - @Transactional - public void deletePrivateSchedule(Long scheduleId, Long userId) { - PrivateSchedule privateSchedule = privateScheduleRepository.findByUserIdAndScheduleId(userId, scheduleId) - .orElseThrow(() -> new IllegalArgumentException("해당 일정이 없습니다.")); - - if (privateSchedule.getStatus() == ScheduleStatus.DEACTIVATE) { - throw new IllegalArgumentException("이미 삭제된 일정입니다."); - } - privateSchedule.delete(); - privateScheduleRepository.save(privateSchedule); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleController.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleController.java deleted file mode 100644 index 29fc482c6..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleController.java +++ /dev/null @@ -1,57 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller; - -import javax.validation.Valid; - -import org.apache.coyote.Response; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ModelAttribute; -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.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import gg.auth.UserDto; -import gg.auth.argumentresolver.Login; -import gg.calendar.api.schedule.publicschedule.controller.request.PublicScheduleCreateReqDto; -import gg.calendar.api.schedule.publicschedule.controller.request.PublicScheduleUpdateReqDto; -import gg.calendar.api.schedule.publicschedule.controller.response.PublicScheduleUpdateResDto; -import gg.calendar.api.schedule.publicschedule.service.PublicScheduleService; -import io.swagger.v3.oas.annotations.Parameter; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@RestController -@RequiredArgsConstructor -@RequestMapping("/public") -public class PublicScheduleController { - private final PublicScheduleService publicScheduleService; - - @PostMapping("/create") - public ResponseEntity createPublicSchedule( - @Valid @ModelAttribute PublicScheduleCreateReqDto publicScheduleCreateReqDto, - @Login @Parameter(hidden = true) UserDto userDto) { - publicScheduleService.createPublicSchedule(userDto, publicScheduleCreateReqDto); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } - - @PutMapping("/{scheduleId}/update") - public ResponseEntity updatePublicSchedule(@PathVariable @Valid Long scheduleId, - @Valid @ModelAttribute PublicScheduleUpdateReqDto publicScheduleUpdateReqDto, - @Login @Parameter(hidden = true) UserDto userDto) { - Long userId = userDto.getId(); - PublicScheduleUpdateResDto scheduleUpdate = publicScheduleService.updatePublicSchedule(scheduleId, userId, publicScheduleUpdateReqDto); - return ResponseEntity.status(HttpStatus.OK).build(); - } - - @PatchMapping("/{scheduleId}/delete") - public ResponseEntity deletePublicSchedule(@PathVariable @Valid Long scheduleId, - @Login @Parameter(hidden = true) UserDto uSerDto) { - Long userId = uSerDto.getId(); - publicScheduleService.deletePublicSchedule(scheduleId, userId); - return ResponseEntity.status(HttpStatus.OK).build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleCreateReqDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleCreateReqDto.java deleted file mode 100644 index 4701453b1..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleCreateReqDto.java +++ /dev/null @@ -1,63 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller.request; -import java.time.LocalDateTime; -import java.util.Set; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.springframework.format.annotation.DateTimeFormat; - -import gg.data.calendar.PrivateSchedule; -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import gg.data.calendar.Tag; - - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PublicScheduleCreateReqDto { - @NotNull - private DetailClassification classification; - - @NotNull - private Set tags; - - @NotBlank - @Size(max = 50, message = "제목은 50자이하로 입력해주세요.") - private String title; - - @Size(max = 2000, message = "내용은 2000자이하로 입력해주세요.") - private String content; - - private String link; - - @NotNull - private boolean alarm; - - private String color; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime startTime; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime endTime; - - public static PublicSchedule of(String author, PublicScheduleCreateReqDto publicScheduleCreateReqDto){ - return PublicSchedule.builder() - .author(author) - .classification(publicScheduleCreateReqDto.classification) - .tags(publicScheduleCreateReqDto.tags) - .title(publicScheduleCreateReqDto.title) - .content(publicScheduleCreateReqDto.content) - .link(publicScheduleCreateReqDto.link) - .startTime(publicScheduleCreateReqDto.startTime) - .endTime(publicScheduleCreateReqDto.endTime) - .build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleReqDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleReqDto.java deleted file mode 100644 index acae278da..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleReqDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller.request; - -import java.time.LocalDateTime; -import java.util.Set; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.springframework.format.annotation.DateTimeFormat; - -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PublicScheduleReqDto { - -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleUpdateReqDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleUpdateReqDto.java deleted file mode 100644 index 8911805ae..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/request/PublicScheduleUpdateReqDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller.request; - -import java.time.LocalDateTime; -import java.util.Set; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.springframework.format.annotation.DateTimeFormat; - -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PublicScheduleUpdateReqDto { - @NotNull - private DetailClassification classification; - - @NotNull - private Set tags; - - @NotBlank - @Size(max = 50, message = "제목은 50자이하로 입력해주세요.") - private String title; - - @Size(max = 2000, message = "내용은 2000자이하로 입력해주세요.") - private String content; - - private String link; - - @NotNull - private boolean alarm; - - private String color; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime startTime; - - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime endTime; -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleResDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleResDto.java deleted file mode 100644 index 4a899bd81..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleResDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller.response; - -public class PublicScheduleResDto { -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleUpdateResDto.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleUpdateResDto.java deleted file mode 100644 index d655aa2fd..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/controller/response/PublicScheduleUpdateResDto.java +++ /dev/null @@ -1,59 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller.response; - -import java.time.LocalDateTime; -import java.util.Set; - -import gg.calendar.api.schedule.publicschedule.controller.request.PublicScheduleUpdateReqDto; -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.Tag; -import gg.data.calendar.type.DetailClassification; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PublicScheduleUpdateResDto { - private Long id; - private DetailClassification detailClassification; - private Set tags; - private String title; - private String content; - private String link; - private LocalDateTime startTime; - private LocalDateTime endTime; - private boolean alarm; - private String color; - - @Builder - public PublicScheduleUpdateResDto(Long id, DetailClassification detailClassification, Set tags, String title, - String content, String link, LocalDateTime startTime, LocalDateTime endTime, boolean alarm, String color) - { - this.id = id; - this.detailClassification = detailClassification; - this.tags = tags; - this.title = title; - this.content = content; - this.link = link; - this.startTime = startTime; - this.endTime = endTime; - this.alarm = alarm; - this.color = color; - } - - public static PublicScheduleUpdateResDto from(PublicSchedule publicSchedule) - { - return PublicScheduleUpdateResDto.builder().id(publicSchedule.getId()) - .detailClassification(publicSchedule.getClassification()) - .tags(publicSchedule.getTags()) - .title(publicSchedule.getTitle()) - .content(publicSchedule.getContent()) - .link(publicSchedule.getLink()) - .startTime(publicSchedule.getStartTime()) - .endTime(publicSchedule.getEndTime()) - .alarm(publicSchedule.isAlarm()) - .color(publicSchedule.getColor()) - .build(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/service/PublicScheduleService.java b/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/service/PublicScheduleService.java deleted file mode 100644 index fe051fd8e..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/schedule/publicschedule/service/PublicScheduleService.java +++ /dev/null @@ -1,104 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.service; - - - -import static gg.utils.exception.ErrorCode.*; - -import java.time.LocalDateTime; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.nimbusds.oauth2.sdk.util.StringUtils; - -import gg.auth.UserDto; -import gg.calendar.api.schedule.publicschedule.controller.request.PublicScheduleCreateReqDto; -import gg.calendar.api.schedule.publicschedule.controller.request.PublicScheduleUpdateReqDto; -import gg.calendar.api.schedule.publicschedule.controller.response.PublicScheduleUpdateResDto; -import gg.data.calendar.PublicSchedule; -import gg.data.calendar.type.DetailClassification; -import gg.data.calendar.type.ScheduleStatus; -import gg.data.user.User; -import gg.repo.calendar.PublicScheduleRepository; -import gg.repo.user.UserRepository; -import gg.utils.exception.ErrorCode; -import gg.utils.exception.custom.BusinessException; -import gg.utils.exception.user.UserNotFoundException; -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class PublicScheduleService { - private final PublicScheduleRepository publicScheduleRepository; - private final UserRepository userRepository; - - @Transactional - public void createPublicSchedule(UserDto userDto, PublicScheduleCreateReqDto publicScheduleCreateReqDto) { - - validateScheduleTime(publicScheduleCreateReqDto.getStartTime(),publicScheduleCreateReqDto.getEndTime()); - // Todo: 값이 누락된 경우 생각해봐야하나? 어차피 table에서 걸러주는데? 그래도 서비스단에서 먼저 확인하는 것이 맞겠지...? - PublicSchedule publicSchedule = PublicScheduleCreateReqDto.of(userDto.getIntraId(), - publicScheduleCreateReqDto); - publicScheduleRepository.save(publicSchedule); - } - - private void validateScheduleTime(LocalDateTime startTime, LocalDateTime endTime) { - if (startTime.isAfter(endTime)) - { - throw new BusinessException(CALENDAR_AFTER_DATE); - } - if (startTime.isBefore(endTime)) - { - throw new BusinessException(CALENDAR_BEFORE_DATE); - } - if (endTime.isEqual(startTime)) - { - throw new BusinessException(CALENDAR_EQUAL_DATE); - } - } - - //TODO: 에러처리하기! - @Transactional - public PublicScheduleUpdateResDto updatePublicSchedule(Long scheduleId, Long userId, PublicScheduleUpdateReqDto publicScheduleUpdateReqDto){ - PublicSchedule publicSchedule = publicScheduleRepository.findByUserIdAndSchduleId(userId, scheduleId).orElseThrow(()-> new IllegalArgumentException("해당 일정이 없습니다.")); - - validateScheduleUpdate(publicScheduleUpdateReqDto); - publicSchedule.update(publicScheduleUpdateReqDto.getClassification(), publicScheduleUpdateReqDto.getTags(), - publicScheduleUpdateReqDto.getTitle(), publicScheduleUpdateReqDto.getContent(), - publicScheduleUpdateReqDto.getLink(), publicScheduleUpdateReqDto.getStartTime(), - publicScheduleUpdateReqDto.getEndTime(), publicScheduleUpdateReqDto.isAlarm(), - publicScheduleUpdateReqDto.getColor()); - return PublicScheduleUpdateResDto.from(publicSchedule); - } - - private void validateScheduleUpdate(PublicScheduleUpdateReqDto publicScheduleUpdateReqDto) - { - if (publicScheduleUpdateReqDto.getStartTime().isAfter(publicScheduleUpdateReqDto.getEndTime())) - { - throw new IllegalArgumentException("시작 시간이 종료 시간보다 늦을 수 없습니다."); - } - if (publicScheduleUpdateReqDto.getEndTime().isBefore(publicScheduleUpdateReqDto.getStartTime())) - { - throw new IllegalArgumentException("종료시간이 시작시간보다 빠를 수 없습니다."); - } - if (publicScheduleUpdateReqDto.getEndTime().isEqual(publicScheduleUpdateReqDto.getStartTime())) - { - throw new IllegalArgumentException("시작 시간과 종료시간이 같을 수 없습니다."); - } - if (StringUtils.isBlank(publicScheduleUpdateReqDto.getTitle())) { - throw new IllegalArgumentException("일정 제목은 필수입니다."); - } - } - - // TODO: 에러처리하기 - @Transactional - public void deletePublicSchedule(Long scheduleId, Long userId) { - PublicSchedule publicSchedule = publicScheduleRepository.findByUserIdAndSchduleId(userId, scheduleId).orElseThrow(()-> new IllegalArgumentException("해당 일정이 없습니다")); - - if (publicSchedule.getStatus() == ScheduleStatus.DELETE) { - throw new IllegalArgumentException("이미 삭제된 일정입니다."); - } - publicSchedule.delete(); - } -} diff --git a/gg-calendar-api/src/main/java/gg/calendar/api/util/AuthVerification.java b/gg-calendar-api/src/main/java/gg/calendar/api/util/AuthVerification.java deleted file mode 100644 index 0879fb731..000000000 --- a/gg-calendar-api/src/main/java/gg/calendar/api/util/AuthVerification.java +++ /dev/null @@ -1,4 +0,0 @@ -package gg.calendar.api.util; - -public class AuthVerification { -} diff --git a/gg-calendar-api/src/test/java/gg/calendar/api/Test.java b/gg-calendar-api/src/test/java/gg/calendar/api/Test.java deleted file mode 100644 index e7021067f..000000000 --- a/gg-calendar-api/src/test/java/gg/calendar/api/Test.java +++ /dev/null @@ -1,6 +0,0 @@ -package gg.calendar.api; - -public class Test { - -} - diff --git a/gg-calendar-api/src/test/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleControllerTest.java b/gg-calendar-api/src/test/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleControllerTest.java deleted file mode 100644 index 8231c73f6..000000000 --- a/gg-calendar-api/src/test/java/gg/calendar/api/schedule/publicschedule/controller/PublicScheduleControllerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package gg.calendar.api.schedule.publicschedule.controller; - -import static org.junit.jupiter.api.Assertions.*; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import javax.persistence.EntityManager; -import javax.transaction.Transactional; - -import org.apache.catalina.User; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -import gg.calendar.api.schedule.publicschedule.service.PublicScheduleService; -import gg.utils.annotation.IntegrationTest; -import lombok.extern.slf4j.Slf4j; -import gg.utils.TestDataUtils; -import gg.data.user.User; - - -@Slf4j -@IntegrationTest -@Transactional -@AutoConfigureMockMvc -public class PublicScheduleControllerTest { - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private EntityManager em; - - @Autowired - private PublicCalendarMockDate publicCalendarMockDate; - - // @Autowired - // private PublicScheduleRepository publicScheduleRepository; - - private User user; - private String accessToken; - - @BeforeEach - void setUp() { - user = testDataUtils.createNewUser(); - accessToken = testDataUtils.getLoginAccessTokenFromUser(user); - } - - - @Nested - @DisplayName("공개 일정 생성") - class CreatePublicSchedule { - - @Test - @DisplayName("올바른 요청으로 공개 일정을 생성한다") - public void createPublicSchedule_Success() throws Exception { - - - } - } -} diff --git a/gg-data/src/main/java/gg/data/calendar/PrivateSchedule.java b/gg-data/src/main/java/gg/data/calendar/PrivateSchedule.java deleted file mode 100644 index 386e476de..000000000 --- a/gg-data/src/main/java/gg/data/calendar/PrivateSchedule.java +++ /dev/null @@ -1,77 +0,0 @@ -package gg.data.calendar; - -import java.time.LocalDateTime; -import java.util.Set; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; - -import gg.data.BaseTimeEntity; -import gg.data.calendar.type.DetailClassification; -import gg.data.calendar.type.ScheduleStatus; -import gg.data.user.User; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PrivateSchedule extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id", nullable = false) - private User user; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "public_schedule_id", nullable = false) - private PublicSchedule publicSchedule; - - @Column(columnDefinition = "boolean default true") - private boolean alarm; - - private String color; - - @Column(nullable = false) - private ScheduleStatus status; - - @Builder - public PrivateSchedule(User user, PublicSchedule publicSchedule, String color) { - this.user = user; - this.publicSchedule = publicSchedule; - this.color = color; - this.alarm = true; - this.status = ScheduleStatus.ACTIVATE; - } - - public static PrivateSchedule of(User user, PublicSchedule publicSchedule, String color) { - return PrivateSchedule.builder().user(user).publicSchedule(publicSchedule).color(color).build(); - } - - public void update(DetailClassification classification, Set tags, - String title, String content, String link, LocalDateTime startTime, LocalDateTime endTime, - boolean alarm, String color) { - - this.publicSchedule.update(classification, tags, title, content, link, startTime, endTime); - this.alarm = alarm; - this.color = color; - - } - - // Todo: 색깔을 변경한다하면 로직 추가 필요 - // 알림을 끌것인가? - public void delete() { - this.status = ScheduleStatus.DELETE; - this.alarm = false; - } -} diff --git a/gg-data/src/main/java/gg/data/calendar/PublicSchedule.java b/gg-data/src/main/java/gg/data/calendar/PublicSchedule.java deleted file mode 100644 index 20b025188..000000000 --- a/gg-data/src/main/java/gg/data/calendar/PublicSchedule.java +++ /dev/null @@ -1,115 +0,0 @@ -package gg.data.calendar; - -import java.time.LocalDateTime; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; - -import gg.data.BaseTimeEntity; -import gg.data.calendar.type.DetailClassification; -import gg.data.calendar.type.ScheduleStatus; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class PublicSchedule extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Enumerated(EnumType.STRING) - @Column(nullable = false, length = 20, columnDefinition = "VARCHAR(10)") - private DetailClassification classification; - - @OneToMany(mappedBy = "tag", cascade = CascadeType.ALL) - private Set tags = new HashSet<>(); - - @Column(nullable = false) - private String author; - - @Column(nullable = false) - private String title; - - private String content; - - private String link; - - @Column(nullable = false) - private LocalDateTime startTime; - - @Column(nullable = false) - private LocalDateTime endTime; - - @Column(nullable = false) - private ScheduleStatus status; - - @Column(columnDefinition = "boolean default true") - private boolean alarm; - - private String color; - - @Builder - public PublicSchedule(DetailClassification classification, Set tags, String author, String title, - String content, String link, LocalDateTime startTime, LocalDateTime endTime) { - this.classification = classification; - this.tags = tags; - this.author = author; - this.title = title; - this.content = content; - this.link = link; - this.startTime = startTime; - this.endTime = endTime; - this.status = ScheduleStatus.ACTIVATE; - } - - // public void update(DetailClassification classification, Set tags, String author, String title, String content, - // String link, LocalDateTime startTime, LocalDateTime endTime) { - // - // } - // - // public void update(DetailClassification classification, Set tags, String title, String content, String link, - // LocalDateTime startTime, LocalDateTime endTime) { - // - // this.classification = classification; - // this.tags = tags; - // this.title = title; - // this.content = content; - // this.link = link; - // this.startTime = startTime; - // this.endTime = endTime; - // } - - public void update(DetailClassification classification, Set tags, - String title, String content, String link, - LocalDateTime startTime, LocalDateTime endTime, - boolean alarm, String color) { - this.classification = classification; - this.tags = tags; - this.title = title; - this.content = content; - this.link = link; - this.startTime = startTime; - this.endTime = endTime; - this.alarm = alarm; - this.color = color; - } - - public void delete() - { - this.status = ScheduleStatus.DELETE; - this.alarm = false; - } -} diff --git a/gg-data/src/main/java/gg/data/calendar/Tag.java b/gg-data/src/main/java/gg/data/calendar/Tag.java deleted file mode 100644 index 589f56041..000000000 --- a/gg-data/src/main/java/gg/data/calendar/Tag.java +++ /dev/null @@ -1,25 +0,0 @@ -package gg.data.calendar; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Tag { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @JoinColumn(name = "public_schedule_id") - private Long publicScheduleId; - - private String value; -} diff --git a/gg-data/src/main/java/gg/data/calendar/type/DetailClassification.java b/gg-data/src/main/java/gg/data/calendar/type/DetailClassification.java deleted file mode 100644 index 7bb147bbf..000000000 --- a/gg-data/src/main/java/gg/data/calendar/type/DetailClassification.java +++ /dev/null @@ -1,16 +0,0 @@ -package gg.data.calendar.type; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum DetailClassification { - EVENT("42행사"), - - JOB_NOTICE("취업공고"), - - NONE("개인일정"); - - private final String value; -} diff --git a/gg-data/src/main/java/gg/data/calendar/type/ScheduleStatus.java b/gg-data/src/main/java/gg/data/calendar/type/ScheduleStatus.java deleted file mode 100644 index 3188c3e11..000000000 --- a/gg-data/src/main/java/gg/data/calendar/type/ScheduleStatus.java +++ /dev/null @@ -1,14 +0,0 @@ -package gg.data.calendar.type; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum ScheduleStatus { - ACTIVATE("활성"), - DEACTIVATE("비활성"), - DELETE("삭제"); - - private final String value; -} diff --git a/gg-data/src/main/java/gg/data/user/type/SnsType.java b/gg-data/src/main/java/gg/data/user/type/SnsType.java index 2638a8d7d..e5c7fb036 100644 --- a/gg-data/src/main/java/gg/data/user/type/SnsType.java +++ b/gg-data/src/main/java/gg/data/user/type/SnsType.java @@ -23,4 +23,5 @@ public static SnsType of(String code) { .findAny() .orElse(SLACK); } + } diff --git a/gg-repo/src/main/java/gg/repo/calendar/PrivateScheduleRepository.java b/gg-repo/src/main/java/gg/repo/calendar/PrivateScheduleRepository.java deleted file mode 100644 index 5d8261122..000000000 --- a/gg-repo/src/main/java/gg/repo/calendar/PrivateScheduleRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package gg.repo.calendar; - -import java.util.Optional; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import gg.data.calendar.PrivateSchedule; - -@Repository -public interface PrivateScheduleRepository extends JpaRepository { - - Optional findByUserIdAndScheduleId(Long userId, Long scheduleId); -} diff --git a/gg-repo/src/main/java/gg/repo/calendar/PublicScheduleRepository.java b/gg-repo/src/main/java/gg/repo/calendar/PublicScheduleRepository.java deleted file mode 100644 index 21fd02148..000000000 --- a/gg-repo/src/main/java/gg/repo/calendar/PublicScheduleRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package gg.repo.calendar; - -import java.util.Optional; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import gg.data.calendar.PrivateSchedule; -import gg.data.calendar.PublicSchedule; - -@Repository -public interface PublicScheduleRepository extends JpaRepository { - - Optional findByUserIdAndSchduleId(Long userId, Long scheduleId); -} diff --git a/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java b/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java index f5f37dc18..5526b53d0 100644 --- a/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java +++ b/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java @@ -234,12 +234,7 @@ public enum ErrorCode { AGENDA_ALREADY_CANCELED(409, "AG405", "이미 취소된 일정입니다."), AGENDA_ALREADY_CONFIRMED(409, "AG406", "이미 확정된 일정입니다."), AGENDA_CAPACITY_CONFLICT(409, "AG407", "팀 제한을 변경할 수 없습니다."), - AGENDA_TEAM_CAPACITY_CONFLICT(409, "AG408", "팀 인원 제한을 변경할 수 없습니다."), - - // calendar - CALENDAR_BEFORE_DATE(400, "DT201", "종료 시간이 시작 시간보다 빠를 수 없습니다."), - CALENDAR_AFTER_DATE(400, "DT202", "시작 시간이 종료 시간보다 늦을 수 없습니다."), - CALENDAR_EQUAL_DATE(400, "DT203", "시작 시간과 종료 시간이 같을 수 없습니다."); + AGENDA_TEAM_CAPACITY_CONFLICT(409, "AG408", "팀 인원 제한을 변경할 수 없습니다."); private final int status; private final String errCode; diff --git a/settings.gradle b/settings.gradle index a0643ea50..6b5cabcf4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,4 +7,3 @@ include 'gg-utils' include 'gg-auth' include 'gg-recruit-api' include 'gg-agenda-api' -include 'gg-calendar-api'