Skip to content

Commit

Permalink
Merge pull request #14 from JNU-econovation/feat/2/schedule-domain
Browse files Browse the repository at this point in the history
schedule domain
  • Loading branch information
capDoYeonLee authored Mar 23, 2024
2 parents e924490 + f6b4b37 commit 88cf278
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class CreateScheduleRequest {

private String eventName;
private LocalDateTime eventStartDate;
private LocalDateTime eventEndDate;
private String eventInfo;
private String eventPlace;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class CreateScheduleResponse { private Long eventId;}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class MonthCalendarResponse {
private Long eventId;
private String eventName;
private LocalDateTime eventStartDate;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class SpecificScheduleResopnse {
private Long eventId;
private String eventName;
private String eventInfo;
private LocalDateTime eventStartDate;
private LocalDateTime eventEndDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.demo.schedule.application.dto;


import com.example.demo.schedule.persistence.ScheduleType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class UpdateScheduleRequest {
private Long eventId;
private String eventName;
private LocalDateTime eventStartDate;
private LocalDateTime eventEndDate;
private String eventInfo;
private String eventPlace;
private ScheduleType eventType;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class WeekDayCalendarResponse {
private Long eventId;
private String eventName;
private LocalDateTime eventStartDate;
private LocalDateTime eventEndDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.demo.schedule.application.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
public class YearCalendarResponse {
private Long eventId;
private LocalDateTime eventStartDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.example.demo.schedule.persistence;

import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
//@AllArgsConstructor(access = AccessLevel.PRIVATE)
@ToString
@Entity
public class ScheduleEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long eventId;

@Column(nullable = false)
private String eventName;

@Column(nullable = false)
private LocalDateTime eventStartDate;
private LocalDateTime eventEndDate;

@Column(nullable = false)
private String eventInfo;

@Column(nullable = false)
private String eventPlace;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private ScheduleType scheduleTypeType;

@Builder
public ScheduleEntity(Long eventId, String eventName, LocalDateTime eventStartDate, LocalDateTime eventEndDate, String eventInfo, String eventPlace, ScheduleType eventType) {
//this.eventId = eventId;
this.eventName = eventName;
this.eventStartDate = eventStartDate;
this.eventEndDate = eventEndDate;
this.eventInfo = eventInfo;
this.eventPlace = eventPlace;
this.scheduleTypeType = eventType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.demo.schedule.persistence;

import org.springframework.data.jpa.repository.JpaRepository;

public interface ScheduleRepository extends JpaRepository<ScheduleEntity, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.demo.schedule.persistence;

public enum ScheduleType {
PUBLIC,
PRIVATE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.demo.schedule.presentation;

import com.example.demo.common.presentation.response.ApiResponse;
import com.example.demo.common.presentation.response.ApiResponseBody.SuccessBody;
import com.example.demo.common.presentation.response.ApiResponseGenerator;
import com.example.demo.common.presentation.response.MessageCode;
import com.example.demo.schedule.application.dto.CreateScheduleRequest;
import com.example.demo.schedule.application.dto.UpdateScheduleRequest;
import com.example.demo.schedule.application.dto.YearCalendarResponse;
import com.sun.net.httpserver.Authenticator;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
public class ScheduleController {

@PostMapping("/calendar")
public ApiResponse<SuccessBody<Void>> create(
@RequestBody CreateScheduleRequest createScheduleRequest) {
// 일정 생성하는 service logic
return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.CREATE);
}

@GetMapping("/calendar/{eventId}")
public ApiResponse<SuccessBody<YearCalendarResponse>> getSpecificCalendar (
@PathVariable("eventId") Long eventId) {
// specific response 담아서 리턴 logic
return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET);
}

@GetMapping("/calendar")
public ApiResponse<SuccessBody<YearCalendarResponse>> getTypeCalendar (
@RequestParam("period") String type) {
// type 별 response 담아서 리턴 logic
return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET);
}

@PutMapping("/calendar/{eventId}")
public ApiResponse<SuccessBody<Void>> update(
@RequestBody UpdateScheduleRequest updateScheduleRequest,
@PathVariable("eventId") Long eventId) {
// 수정하는 logic
return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.UPDATE);
}

@DeleteMapping("/calendar/{eventId}")
public ApiResponse<SuccessBody<Void>> delete(
@PathVariable("eventId") Long eventId) {
// 일정 삭제하는 logic
return return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.DELETE);
}

}

0 comments on commit 88cf278

Please sign in to comment.