Skip to content

Commit

Permalink
Merge pull request #40 from Team-UMC/feature/#25/Schedule
Browse files Browse the repository at this point in the history
[FEAT] 스케줄 API 구현
  • Loading branch information
junseokkim authored Jan 27, 2024
2 parents 9a5c384 + bb77288 commit 46e7c90
Show file tree
Hide file tree
Showing 10 changed files with 531 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.umc.networkingService.domain.schedule.controller;

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule;
import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule;
import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail;
import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId;
import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar;
import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists;
import com.umc.networkingService.domain.schedule.service.ScheduleService;
import com.umc.networkingService.global.common.base.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDate;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "일정 API", description = "일정 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/schedules")
public class ScheduleController {

private final ScheduleService scheduleService;

// GET
@Operation(summary = "일정 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.")
@GetMapping
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공")
})
public BaseResponse<ScheduleInfoSummaryLists> getScheduleLists(@RequestParam LocalDate date) {

return BaseResponse.onSuccess((scheduleService.getScheduleLists(date)));
}

@Operation(summary = "일정 조회(상세조회)", description = "홈화면의 달력에서 일정을 상세조회하는 API입니다.")
@GetMapping("/detail/{scheduleId}")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.")
})
public BaseResponse<ScheduleDetail> getScheduleDetail(@CurrentMember Member member,
@PathVariable("scheduleId") UUID scheduleId) {

return BaseResponse.onSuccess(scheduleService.getScheduleDetail(member, scheduleId));
}

// POST

@Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.")
@PostMapping("/calendar")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공")
})
public BaseResponse<ScheduleInfoSummariesInCalendar> getSchedule(@RequestParam LocalDate date) {

return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(date));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.umc.networkingService.domain.schedule.controller;

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule;
import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule;
import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId;
import com.umc.networkingService.domain.schedule.service.ScheduleService;
import com.umc.networkingService.global.common.base.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;

@Tag(name = "운영진 스케줄 API", description = "운영진 스케줄 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/staff/schedules")
public class StaffScheduleController {

private final ScheduleService scheduleService;

@Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.")
@PostMapping
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공")
})
public BaseResponse<ScheduleId> createSchedule(@CurrentMember Member member,
@RequestBody CreateSchedule request) {

return BaseResponse.onSuccess(scheduleService.createSchedule(member, request));
}

@Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.")
@PostMapping("/update/{scheduleId}")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.")
})
public BaseResponse<ScheduleId> updateSchedule(@CurrentMember Member member,
@PathVariable("scheduleId") UUID scheduleId,
@RequestBody UpdateSchedule request) {

return BaseResponse.onSuccess(scheduleService.updateSchedule(member, scheduleId, request));
}

// DELETE

@Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.")
@DeleteMapping("/{scheduleId}")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.")
})
public BaseResponse<ScheduleId> deleteSchedule(@CurrentMember Member member,
@PathVariable("scheduleId") UUID scheduleId) {

return BaseResponse.onSuccess(scheduleService.deleteSchedule(member, scheduleId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.umc.networkingService.domain.schedule.dto.request;

import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.global.common.enums.Semester;
import java.time.LocalDateTime;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public class ScheduleRequest {
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class CreateSchedule {
private String title;
private String content;
private LocalDateTime startDateTime;
private LocalDateTime endDateTime;
private List<Semester> semesterPermission;
private HostType hostType;
private String placeSetting;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class UpdateSchedule {
private String title;
private String content;
private LocalDateTime startDateTime;
private LocalDateTime endDateTime;
private List<Semester> semesterPermission;
private HostType hostType;
private String placeSetting;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.umc.networkingService.domain.schedule.dto.response;

import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.member.entity.PositionType;
import com.umc.networkingService.global.common.enums.Role;
import com.umc.networkingService.global.common.enums.Semester;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public class ScheduleResponse {

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleInfoSummaryInCalendar {
private UUID scheduleId;
private LocalDateTime startDateTime;
private LocalDateTime endDateTime;
private String hostType;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleInfoSummariesInCalendar {
private List<ScheduleInfoSummaryInCalendar> schedules;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleInfoSummary {
private UUID scheduleId;
private LocalDateTime startDateTime;
private LocalDateTime endDatetime;
private String title;
private HostType hostType;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleInfoSummaryLists {
private List<ScheduleInfoSummary> campusSchedules;
private List<ScheduleInfoSummary> branchSchedules;
private List<ScheduleInfoSummary> centerSchedules;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleId {
private UUID scheduleId;
}

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class ScheduleDetail {
private UUID scheduleId;
private String writerName;
private String writerNickname;
private String title;
private String content;
private LocalDateTime startDateTime;
private LocalDateTime endDateTime;
private String placeSetting;
private HostType hostType;

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule;
import com.umc.networkingService.global.common.base.BaseEntity;
import com.umc.networkingService.global.common.enums.Semester;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.UuidGenerator;

Expand All @@ -18,6 +22,8 @@

@Getter
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor(access= AccessLevel.PROTECTED)
@SQLRestriction("deleted_at is null")
public class Schedule extends BaseEntity {
Expand Down Expand Up @@ -52,4 +58,14 @@ public class Schedule extends BaseEntity {

@Column(nullable = false)
private HostType hostType;

public void updateSchedule(UpdateSchedule request) {
this.title = request.getTitle();
this.content = request.getContent();
this.startDateTime = request.getStartDateTime();
this.endDateTime = request.getEndDateTime();
this.semesterPermission = request.getSemesterPermission();
this.hostType = request.getHostType();
this.placeSetting = request.getPlaceSetting();
}
}
Loading

0 comments on commit 46e7c90

Please sign in to comment.