-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 [Refactoring] Admin 공유일정 조회 API -> 분류별 일정조회 API로 변경 #1091
- Loading branch information
Showing
37 changed files
with
1,791 additions
and
103 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
...alendar/api/admin/schedule/privateschedule/controller/PrivateScheduleAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
package gg.calendar.api.admin.schedule.privateschedule.controller; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.calendar.api.admin.schedule.privateschedule.service.PrivateScheduleAdminService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/admin/calendar") | ||
@RequestMapping("/admin/calendar/private") | ||
public class PrivateScheduleAdminController { | ||
|
||
private final PrivateScheduleAdminService privateScheduleAdminService; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...api/admin/schedule/publicschedule/controller/request/PublicScheduleAdminUpdateReqDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,71 @@ | ||
package gg.calendar.api.admin.schedule.publicschedule.controller.request; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
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.type.DetailClassification; | ||
import gg.data.calendar.type.EventTag; | ||
import gg.data.calendar.type.JobTag; | ||
import gg.data.calendar.type.ScheduleStatus; | ||
import gg.data.calendar.type.TechTag; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PublicScheduleAdminUpdateReqDto { | ||
|
||
@NotNull | ||
private DetailClassification classification; | ||
|
||
private EventTag eventTag; | ||
|
||
private JobTag jobTag; | ||
|
||
private TechTag techTag; | ||
|
||
@NotBlank | ||
@Size(max = 50, message = "제목은 50자이하로 입력해주세요.") | ||
private String title; | ||
|
||
@Size(max = 2000, message = "내용은 2000자이하로 입력해주세요.") | ||
private String content; | ||
|
||
private String link; | ||
|
||
@NotNull | ||
private ScheduleStatus status; | ||
|
||
@NotNull | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | ||
private LocalDateTime startTime; | ||
|
||
@NotNull | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) | ||
private LocalDateTime endTime; | ||
|
||
@Builder | ||
private PublicScheduleAdminUpdateReqDto(DetailClassification classification, EventTag eventTag, JobTag jobTag, | ||
TechTag techTag, String title, String content, String link, ScheduleStatus status, LocalDateTime startTime, | ||
LocalDateTime endTime) { | ||
|
||
this.classification = classification; | ||
this.eventTag = eventTag; | ||
this.jobTag = jobTag; | ||
this.techTag = techTag; | ||
this.title = title; | ||
this.content = content; | ||
this.link = link; | ||
this.status = status; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
|
||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...pi/admin/schedule/publicschedule/controller/response/PublicScheduleAdminUpdateResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,83 @@ | ||
package gg.calendar.api.admin.schedule.publicschedule.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.calendar.PublicSchedule; | ||
import gg.data.calendar.type.EventTag; | ||
import gg.data.calendar.type.JobTag; | ||
import gg.data.calendar.type.ScheduleStatus; | ||
import gg.data.calendar.type.TechTag; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PublicScheduleAdminUpdateResDto { | ||
|
||
private Long id; | ||
|
||
private String classification; | ||
|
||
private EventTag eventTag; | ||
|
||
private JobTag jobTag; | ||
|
||
private TechTag techTag; | ||
|
||
private String author; | ||
|
||
private String title; | ||
|
||
private String content; | ||
|
||
private String link; | ||
|
||
private Integer sharedCount; | ||
|
||
private ScheduleStatus status; | ||
|
||
private LocalDateTime startTime; | ||
|
||
private LocalDateTime endTime; | ||
|
||
@Builder | ||
private PublicScheduleAdminUpdateResDto(Long id, String classification, EventTag eventTag, JobTag jobTag, | ||
TechTag techTag, | ||
String author, String title, String content, String link, Integer sharedCount, ScheduleStatus status, | ||
LocalDateTime startTime, LocalDateTime endTime) { | ||
this.id = id; | ||
this.classification = classification; | ||
this.eventTag = eventTag; | ||
this.jobTag = jobTag; | ||
this.techTag = techTag; | ||
this.author = author; | ||
this.title = title; | ||
this.content = content; | ||
this.link = link; | ||
this.sharedCount = sharedCount; | ||
this.status = status; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
|
||
} | ||
|
||
public static PublicScheduleAdminUpdateResDto toDto(PublicSchedule publicSchedule) { | ||
return PublicScheduleAdminUpdateResDto.builder() | ||
.id(publicSchedule.getId()) | ||
.classification(publicSchedule.getClassification().name()) | ||
.eventTag(publicSchedule.getEventTag()) | ||
.jobTag(publicSchedule.getJobTag()) | ||
.techTag(publicSchedule.getTechTag()) | ||
.author(publicSchedule.getAuthor()) | ||
.title(publicSchedule.getTitle()) | ||
.content(publicSchedule.getContent()) | ||
.link(publicSchedule.getLink()) | ||
.sharedCount(publicSchedule.getSharedCount()) | ||
.status(publicSchedule.getStatus()) | ||
.startTime(publicSchedule.getStartTime()) | ||
.endTime(publicSchedule.getEndTime()) | ||
.build(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...gg/calendar/api/admin/schedule/totalschedule/controller/TotalScheduleAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package gg.calendar.api.admin.schedule.totalschedule.controller; | ||
|
||
import javax.validation.Valid; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.calendar.api.admin.schedule.totalschedule.controller.response.TotalScheduleAdminResDto; | ||
import gg.calendar.api.admin.schedule.totalschedule.service.TotalScheduleAdminService; | ||
import gg.data.calendar.type.DetailClassification; | ||
import gg.utils.dto.PageRequestDto; | ||
import gg.utils.dto.PageResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/admin/calendar") | ||
public class TotalScheduleAdminController { | ||
|
||
private final TotalScheduleAdminService totalScheduleAdminService; | ||
|
||
@GetMapping("/list/{detailClassification}") | ||
public ResponseEntity<PageResponseDto<TotalScheduleAdminResDto>> totalScheduleAdminClassificationList( | ||
@PathVariable DetailClassification detailClassification, @ModelAttribute @Valid PageRequestDto pageRequestDto) { | ||
int page = pageRequestDto.getPage(); | ||
int size = pageRequestDto.getSize(); | ||
|
||
PageResponseDto<TotalScheduleAdminResDto> pageResponseDto = totalScheduleAdminService.findAllByClassification( | ||
detailClassification, page, size); | ||
|
||
return ResponseEntity.ok(pageResponseDto); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...lendar/api/admin/schedule/totalschedule/controller/response/TotalScheduleAdminResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package gg.calendar.api.admin.schedule.totalschedule.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.calendar.PublicSchedule; | ||
import gg.data.calendar.type.DetailClassification; | ||
import gg.data.calendar.type.EventTag; | ||
import gg.data.calendar.type.JobTag; | ||
import gg.data.calendar.type.ScheduleStatus; | ||
import gg.data.calendar.type.TechTag; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class TotalScheduleAdminResDto { | ||
|
||
private Long id; | ||
|
||
private DetailClassification classification; | ||
|
||
private EventTag eventTag; | ||
|
||
private JobTag jobTag; | ||
|
||
private TechTag techTag; | ||
|
||
private String author; | ||
|
||
private String title; | ||
|
||
private LocalDateTime startTime; | ||
|
||
private LocalDateTime endTime; | ||
|
||
private String link; | ||
|
||
private Integer sharedCount; | ||
|
||
private ScheduleStatus status; | ||
|
||
@Builder | ||
public TotalScheduleAdminResDto(PublicSchedule publicSchedule) { | ||
this.id = publicSchedule.getId(); | ||
this.classification = publicSchedule.getClassification(); | ||
this.eventTag = publicSchedule.getEventTag(); | ||
this.jobTag = publicSchedule.getJobTag(); | ||
this.techTag = publicSchedule.getTechTag(); | ||
this.author = publicSchedule.getAuthor(); | ||
this.title = publicSchedule.getTitle(); | ||
this.startTime = publicSchedule.getStartTime(); | ||
this.endTime = publicSchedule.getEndTime(); | ||
this.link = publicSchedule.getLink(); | ||
this.sharedCount = publicSchedule.getSharedCount(); | ||
this.status = publicSchedule.getStatus(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../java/gg/calendar/api/admin/schedule/totalschedule/service/TotalScheduleAdminService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package gg.calendar.api.admin.schedule.totalschedule.service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.admin.repo.calendar.PublicScheduleAdminRepository; | ||
import gg.calendar.api.admin.schedule.totalschedule.controller.response.TotalScheduleAdminResDto; | ||
import gg.data.calendar.PublicSchedule; | ||
import gg.data.calendar.type.DetailClassification; | ||
import gg.utils.dto.PageResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class TotalScheduleAdminService { | ||
|
||
private final PublicScheduleAdminRepository publicScheduleAdminRepository; | ||
|
||
public PageResponseDto<TotalScheduleAdminResDto> findAllByClassification(DetailClassification detailClassification, | ||
int page, int size) { | ||
|
||
Pageable pageable = PageRequest.of(page - 1, size, | ||
Sort.by(Sort.Order.asc("status"), Sort.Order.asc("startTime"))); | ||
|
||
Page<PublicSchedule> publicSchedules = publicScheduleAdminRepository.findAllByClassification( | ||
detailClassification, pageable); | ||
|
||
List<TotalScheduleAdminResDto> publicScheduleList = publicSchedules.stream() | ||
.map(TotalScheduleAdminResDto::new) | ||
.collect(Collectors.toList()); | ||
return PageResponseDto.of(publicSchedules.getTotalElements(), publicScheduleList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.