1️⃣ 요구사항 정리
- 일정을 생성, 조회, 수정, 삭제할 수 있습니다.
- 일정은 아래 필드를 가집니다.
- 작성 유저명, 할일 제목, 할일 내용, 작성일, 수정일 필드
- 작성일, 수정일 필드는 JPA Auditing을 활용
2️⃣ 기술 스택
- Spring Boot 3.1.x
- Spring Web, Spring Validation
- Spring Data JDBC
- MySQL
- Lombok
3️⃣ 계층 구조 (MVC) 명세
Controller → Service → Repository → DB
- Controller: HTTP 요청/응답 처리
- Service: 비즈니스 로직 구현
- Repository: DB 접근
4️⃣ API 명세
| Method | URL | 설명 |
| POST | /schedules | 일정 등록 |
| GET | /schedules | 전체 조회 |
| GET | /schedules/{scheduleId} | 단간 조회 |
| PATCH | /schedules/{scheduleId} | 수정 |
| DELETE | /schedules/{scheduleId} | 삭제 |
5️⃣ ERD

6️⃣ 주요 코드(일정 생성)
더보기
(ScheduleController.java)
@RestController
@RequestMapping("/schedules")
@RequiredArgsConstructor
public class ScheduleController {
private final ScheduleService scheduleService;
@PostMapping
public ResponseEntity<CreateScheduleResponseDto> save(@Valid @RequestBody CreateScheduleRequestDto dto) {
CreateScheduleResponseDto createScheduleResponseDto = scheduleService.saveSchedule(dto);
return new ResponseEntity<>(createScheduleResponseDto, HttpStatus.CREATED);
}
}
(CreateScheduleRequestDto.java)
@Getter
@NoArgsConstructor
public class CreateScheduleRequestDto {
@NotBlank(message = "작성자 이름을 적어주세요")
private String authorName;
@NotBlank(message = "제목을 적어주세요")
private String title;
private String contents;
public CreateScheduleRequestDto(String authorName, String title, String contents) {
this.authorName = authorName;
this.title = title;
this.contents = contents;
}
}
(ScheduleService.java)
@Service
@RequiredArgsConstructor
public class ScheduleServiceImpl implements ScheduleService {
private final ScheduleRepository scheduleRepository;
@Override
public CreateScheduleResponseDto saveSchedule(CreateScheduleRequestDto dto) {
Schedule schedule = new Schedule(dto);
Schedule save = scheduleRepository.save(schedule);
return new CreateScheduleResponseDto(save.getScheduleId(), save.getAuthorName(), save.getTitle(), save.getContents());
}
(ScheduleRepository.java)
public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
}
(Schedule.java)
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
@Entity
@Table(name = "simple_schedule")
public class Schedule extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long scheduleId;
@Column(nullable = false)
private String authorName;
@Column(nullable = false)
private String title;
private String contents;
public Schedule(CreateScheduleRequestDto dto) {
this.authorName = dto.getAuthorName();
this.title = dto.getTitle();
this.contents = dto.getContents();
}
📌 GitHub 저장소: https://github.com/sukh115/schedulerJpa/lv1
GitHub - sukh115/schedulerJpa
Contribute to sukh115/schedulerJpa development by creating an account on GitHub.
github.com
'SPRING' 카테고리의 다른 글
| [Spring Boot + JPA] LV.3 + LV.4 (1) | 2025.03.28 |
|---|---|
| [Spring Boot + JPA] LV.2 (1) | 2025.03.28 |
| [Spring Boot + JPA] 트러블 슈팅 (2) | 2025.03.28 |
| Spring JPA 영속성 컨텍스트 (0) | 2025.03.26 |
| Spring JPA (0) | 2025.03.26 |