-
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로 변경
- Loading branch information
1 parent
93fa00f
commit c0961f7
Showing
10 changed files
with
269 additions
and
106 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
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
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
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.