Skip to content

Commit 52a65e0

Browse files
authored
Merge pull request #25 from What-s-Your-Plan/feat/#14
일정 생성 Domain 모듈 작성
2 parents 13f1dac + aabf25a commit 52a65e0

File tree

25 files changed

+363
-124
lines changed

25 files changed

+363
-124
lines changed

application/wypl-core/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ java {
99

1010
dependencies {
1111
implementation project(':application:application-common')
12+
implementation project(':common')
13+
implementation project(':domain:jpa-common')
14+
implementation project(':domain:jpa-member-domain')
15+
implementation project(':domain:jpa-calendar-domain')
1216
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.wypl;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
6+
7+
@SpringBootApplication
8+
@EnableJpaRepositories(basePackages = {"com.wypl"})
9+
public class WyplCoreApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(WyplCoreApplication.class, args);
13+
}
14+
15+
}

application/wypl-core/src/main/java/com/wypl/wyplcore/WyplColorApplication.java

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.wypl.wyplcore.schedule.data.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Builder;
5+
6+
@Builder
7+
public record ScheduleCreateRequest(
8+
9+
@JsonProperty("calendar_id")
10+
long calenderId,
11+
12+
@JsonProperty("schedule_request")
13+
ScheduleRequest scheduleRequest
14+
15+
) {
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.wypl.wyplcore.schedule.data.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.wypl.jpacalendardomain.calendar.data.ConvertibleSchedule;
5+
import com.wypl.jpacalendardomain.calendar.data.RepetitionCycle;
6+
7+
import java.time.LocalDate;
8+
import java.time.LocalDateTime;
9+
10+
public record ScheduleRequest (
11+
12+
String title,
13+
14+
String description,
15+
16+
@JsonProperty("start_datetime")
17+
LocalDateTime startDateTime,
18+
19+
@JsonProperty("end_datetime")
20+
LocalDateTime endDateTime,
21+
22+
@JsonProperty("repetition_cycle")
23+
RepetitionCycle repetitionCycle,
24+
25+
@JsonProperty("day_of_week")
26+
int dayOfWeek,
27+
28+
@JsonProperty("week_interval")
29+
Integer weekInterval,
30+
31+
@JsonProperty("repetition_start_date")
32+
LocalDate repetitionStartDate,
33+
34+
@JsonProperty("repetition_end_date")
35+
LocalDate repetitionEndDate
36+
37+
) implements ConvertibleSchedule {
38+
@Override
39+
public String getTitle() {
40+
return this.title;
41+
}
42+
43+
@Override
44+
public String getDescription() {
45+
return this.description;
46+
}
47+
48+
@Override
49+
public LocalDateTime getStartDateTime() {
50+
return this.startDateTime;
51+
}
52+
53+
@Override
54+
public LocalDateTime getEndDateTime() {
55+
return this.endDateTime;
56+
}
57+
58+
@Override
59+
public LocalDate getRepetitionStartDate() {
60+
return this.repetitionStartDate;
61+
}
62+
63+
@Override
64+
public LocalDate getRepetitionEndDate() {
65+
return this.repetitionEndDate;
66+
}
67+
68+
@Override
69+
public RepetitionCycle getRepetitionCycle() {
70+
return this.repetitionCycle;
71+
}
72+
73+
@Override
74+
public Integer getDayOfWeek() {
75+
return this.dayOfWeek;
76+
}
77+
78+
@Override
79+
public Integer getWeekInterval() {
80+
return this.weekInterval;
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.wypl.wyplcore.schedule.service;
2+
3+
import com.wypl.jpacalendardomain.calendar.domain.Calendar;
4+
import com.wypl.jpacalendardomain.calendar.domain.ScheduleInfo;
5+
import com.wypl.jpacalendardomain.calendar.repository.ScheduleInfoRepository;
6+
import com.wypl.jpacalendardomain.calendar.repository.ScheduleRepository;
7+
import com.wypl.wyplcore.schedule.data.request.ScheduleCreateRequest;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.stereotype.Service;
10+
11+
@Service
12+
@RequiredArgsConstructor
13+
public class ScheduleService {
14+
15+
private final ScheduleRepository scheduleRepository;
16+
private final ScheduleInfoRepository scheduleInfoRepository;
17+
18+
public void createSchedule(long memberId, ScheduleCreateRequest scheduleCreateRequest) {
19+
20+
//Schedule, ScheduleInfo 생성
21+
Calendar calendar = null; // FIXME: scheduleInfoRequest의 calendarId로 찾는다.
22+
ScheduleInfo scheduleInfo = null;
23+
24+
}
25+
}

application/wypl-core/src/main/resources/application.properties

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
spring:
2+
application:
3+
name: wypl-core
4+
jpa:
5+
properties:
6+
hibernate:
7+
show_sql: true
8+
format_sql: true
9+
hibernate:
10+
ddl-auto: create-drop
11+
datasource:
12+
driver-class-name: org.h2.Driver
13+
url: jdbc:h2:mem:db
14+
username: sa
15+
password:
16+
h2:
17+
console:
18+
enabled: true
19+
path: /h2

common/src/main/java/com/wypl/common/exception/GlobalErrorCode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public enum GlobalErrorCode implements ServerErrorCode {
88
private final String errorCode;
99
private final String message;
1010

11-
private GlobalErrorCode(int statusCode, String errorCode, String message) {
11+
GlobalErrorCode(int statusCode, String errorCode, String message) {
1212
this.statusCode = statusCode;
1313
this.errorCode = errorCode;
1414
this.message = message;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.wypl.jpacalendardomain.calendar.data;
2+
3+
import java.time.LocalDate;
4+
import java.time.LocalDateTime;
5+
6+
public interface ConvertibleSchedule {
7+
8+
String getTitle();
9+
10+
String getDescription();
11+
12+
LocalDateTime getStartDateTime();
13+
14+
LocalDateTime getEndDateTime();
15+
16+
LocalDate getRepetitionStartDate();
17+
18+
LocalDate getRepetitionEndDate();
19+
20+
RepetitionCycle getRepetitionCycle();
21+
22+
Integer getDayOfWeek();
23+
24+
Integer getWeekInterval();
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.wypl.jpacalendardomain.calendar.data;
2+
3+
public interface ConvertibleScheduleInfo {
4+
5+
Long getCreatorId();
6+
7+
}

domain/jpa-calendar-domain/src/main/java/com/wypl/jpacalendardomain/schedule/data/RepetitionCycle.java domain/jpa-calendar-domain/src/main/java/com/wypl/jpacalendardomain/calendar/data/RepetitionCycle.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.wypl.jpacalendardomain.schedule.data;
1+
package com.wypl.jpacalendardomain.calendar.data;
22

33
public enum RepetitionCycle {
44
DAY,
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
package com.wypl.jpacalendardomain.calendar.domain;
22

3+
import com.wypl.jpacommon.JpaBaseEntity;
4+
import jakarta.persistence.*;
35
import org.hibernate.annotations.SQLRestriction;
46

5-
import jakarta.persistence.Column;
6-
import jakarta.persistence.Entity;
7-
import jakarta.persistence.GeneratedValue;
8-
import jakarta.persistence.GenerationType;
9-
import jakarta.persistence.Id;
10-
import jakarta.persistence.Table;
117
import lombok.AccessLevel;
12-
import lombok.AllArgsConstructor;
138
import lombok.Builder;
149
import lombok.Getter;
1510
import lombok.NoArgsConstructor;
1611

17-
@Builder
12+
import java.util.List;
13+
1814
@Getter
19-
@AllArgsConstructor
2015
@NoArgsConstructor(access = AccessLevel.PROTECTED)
2116
@SQLRestriction("deleted_at is null")
2217
@Entity
23-
@Table(name = "calendar")
24-
public class Calendar {
25-
// Todo : extends BaseEntity
18+
@Table(name = "calendar_tbl")
19+
public class Calendar extends JpaBaseEntity {
20+
2621
@Id
2722
@GeneratedValue(strategy = GenerationType.IDENTITY)
2823
@Column(name = "calendar_id")
@@ -37,6 +32,21 @@ public class Calendar {
3732
@Column(name = "owner_id")
3833
private Long ownerId;
3934

40-
// Todo : boolean type 설정
41-
// private Boolean isShared;
35+
@OneToMany(mappedBy = "calendar")
36+
private List<ScheduleInfo> scheduleInfos;
37+
38+
@OneToMany(mappedBy = "calendar")
39+
private List<MemberCalendar> memberCalendars;
40+
41+
@Column(name = "is_shared")
42+
private Boolean isShared;
43+
44+
@Builder
45+
public Calendar(String name, String description, Long ownerId, List<ScheduleInfo> scheduleInfos, Boolean isShared) {
46+
this.name = name;
47+
this.description = description;
48+
this.ownerId = ownerId;
49+
this.scheduleInfos = scheduleInfos;
50+
this.isShared = isShared;
51+
}
4252
}

domain/jpa-calendar-domain/src/main/java/com/wypl/jpacalendardomain/calendar/domain/MemberCalendar.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.wypl.jpacalendardomain.calendar.domain;
22

3+
import com.wypl.jpacommon.JpaBaseEntity;
34
import org.hibernate.annotations.SQLRestriction;
45

56
import com.wypl.common.Color;
@@ -29,9 +30,8 @@
2930
@SQLRestriction("deleted_at is null")
3031
@Entity
3132
@IdClass(MemberCalendarId.class)
32-
@Table(name = "member_calendar")
33-
public class MemberCalendar {
34-
// Todo : extends BaseEntity
33+
@Table(name = "member_calendar_tbl")
34+
public class MemberCalendar extends JpaBaseEntity {
3535

3636
@Id
3737
@ManyToOne(fetch = FetchType.LAZY)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.wypl.jpacalendardomain.calendar.domain;
2+
3+
import com.wypl.jpacalendardomain.calendar.data.RepetitionCycle;
4+
import com.wypl.jpacommon.JpaBaseEntity;
5+
import jakarta.persistence.*;
6+
import lombok.*;
7+
import org.hibernate.annotations.SQLRestriction;
8+
9+
import java.time.LocalDate;
10+
import java.time.LocalDateTime;
11+
12+
@Getter
13+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
14+
@SQLRestriction("deleted_at is null")
15+
@Entity
16+
@Table(name = "schedule_tbl")
17+
public class Schedule extends JpaBaseEntity {
18+
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
@Column(name = "schedule_id")
22+
private Long scheduleId;
23+
24+
@ManyToOne(fetch = FetchType.LAZY)
25+
@JoinColumn(name = "schedule_info_id", nullable = false)
26+
private ScheduleInfo scheduleInfo;
27+
28+
@Column(name = "title", length = 100)
29+
private String title;
30+
31+
@Column(name = "description")
32+
private String description;
33+
34+
@Column(name = "start_datetime", nullable = false)
35+
private LocalDateTime startDateTime;
36+
37+
@Column(name = "end_datetime", nullable = false)
38+
private LocalDateTime endDateTime;
39+
40+
@Column(name = "repetition_start_date", nullable = false)
41+
private LocalDate repetitionStartDate;
42+
43+
@Column(name = "repetition_end_date")
44+
private LocalDate repetitionEndDate;
45+
46+
@Enumerated(EnumType.STRING)
47+
private RepetitionCycle repetitionCycle; // 반복 주기 (일, 주, 달, 년)
48+
49+
@Column(name = "day_of_week")
50+
private Integer dayOfWeek; // 반복 요일
51+
52+
@Column(name = "week_interval")
53+
private Integer weekInterval; // 주 반복
54+
55+
// Todo: Review Mapping
56+
57+
@Builder
58+
public Schedule(ScheduleInfo scheduleInfo, String title, String description, LocalDateTime startDateTime, LocalDateTime endDateTime, LocalDate repetitionStartDate, LocalDate repetitionEndDate, RepetitionCycle repetitionCycle, Integer dayOfWeek, Integer weekInterval) {
59+
this.scheduleInfo = scheduleInfo;
60+
this.title = title;
61+
this.description = description;
62+
this.startDateTime = startDateTime;
63+
this.endDateTime = endDateTime;
64+
this.repetitionStartDate = repetitionStartDate;
65+
this.repetitionEndDate = repetitionEndDate;
66+
this.repetitionCycle = repetitionCycle;
67+
this.dayOfWeek = dayOfWeek;
68+
this.weekInterval = weekInterval;
69+
}
70+
}

0 commit comments

Comments
 (0)