Skip to content

Commit

Permalink
🔨 [Refactoring] Admin 공유일정 조회 API -> 분류별 일정조회 API로 변경 #1091
Browse files Browse the repository at this point in the history
  • Loading branch information
seyeon22222 committed Jan 2, 2025
2 parents 27ea36c + 21ac71b commit 57c3601
Show file tree
Hide file tree
Showing 37 changed files with 1,791 additions and 103 deletions.
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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class PublicScheduleAdminCreateReqDto {

private String link;

@NotNull
private ScheduleStatus status;

@NotNull
Expand Down
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;

}
}
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();
}
}
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);
}
}
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();
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.RequestBody;
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.user.schedule.privateschedule.controller.request.PrivateScheduleCreateReqDto;
import gg.calendar.api.user.schedule.privateschedule.controller.request.PrivateScheduleUpdateReqDto;
import gg.calendar.api.user.schedule.privateschedule.controller.response.PrivateScheduleUpdateResDto;
import gg.calendar.api.user.schedule.privateschedule.service.PrivateScheduleService;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
Expand All @@ -28,4 +32,14 @@ public ResponseEntity<Void> privateScheduleCreate(@Login @Parameter(hidden = tru
privateScheduleService.createPrivateSchedule(userDto, privateScheduleCreateReqDto);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@PutMapping("/{id}")
public ResponseEntity<PrivateScheduleUpdateResDto> privateScheduleUpdate(
@Login @Parameter(hidden = true) UserDto userDto,
@Valid @RequestBody PrivateScheduleUpdateReqDto privateScheduleUpdateReqDto,
@PathVariable Long id) {
PrivateScheduleUpdateResDto privateScheduleUpdateResDto = privateScheduleService.updatePrivateSchedule(userDto,
privateScheduleUpdateReqDto, id);
return ResponseEntity.status(HttpStatus.OK).body(privateScheduleUpdateResDto);
}
}
Loading

0 comments on commit 57c3601

Please sign in to comment.