-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from CSID-DGU/develop
โจ [Feat] ํ์ฌ์ผ์
- Loading branch information
Showing
7 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/dongguk/osori/domain/academicEvent/controller/AcademicEventController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dongguk.osori.domain.academicEvent.controller; | ||
|
||
import dongguk.osori.domain.academicEvent.entity.AcademicEvent; | ||
import dongguk.osori.domain.academicEvent.service.AcademicEventService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/academic-events") | ||
@RequiredArgsConstructor | ||
public class AcademicEventController { | ||
|
||
private final AcademicEventService service; | ||
|
||
@GetMapping("/{year}/{month}") | ||
public ResponseEntity<List<AcademicEvent>> getEventsByMonth( | ||
@PathVariable int year, | ||
@PathVariable int month) { | ||
return ResponseEntity.ok(service.getEventsByMonth(year, month)); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/dongguk/osori/domain/academicEvent/entity/AcademicEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dongguk.osori.domain.academicEvent.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class AcademicEvent { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String eventTitle; | ||
|
||
@Column(nullable = false) | ||
private String department; | ||
|
||
@Column(nullable = false) | ||
private LocalDate startDate; | ||
|
||
@Column(nullable = false) | ||
private LocalDate endDate; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/dongguk/osori/domain/academicEvent/repository/AcademicEventRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dongguk.osori.domain.academicEvent.repository; | ||
|
||
import dongguk.osori.domain.academicEvent.entity.AcademicEvent; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Repository | ||
public interface AcademicEventRepository extends JpaRepository<AcademicEvent, Long> { | ||
List<AcademicEvent> findByStartDateBetween(LocalDate start, LocalDate end); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/dongguk/osori/domain/academicEvent/service/AcademicEventService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dongguk.osori.domain.academicEvent.service; | ||
|
||
import dongguk.osori.domain.academicEvent.entity.AcademicEvent; | ||
import dongguk.osori.domain.academicEvent.repository.AcademicEventRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
import java.time.YearMonth; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AcademicEventService { | ||
|
||
private final AcademicEventRepository repository; | ||
|
||
public List<AcademicEvent> getEventsByMonth(int year, int month) { | ||
YearMonth yearMonth = YearMonth.of(year, month); | ||
LocalDate startOfMonth = yearMonth.atDay(1); | ||
LocalDate endOfMonth = yearMonth.atEndOfMonth(); | ||
|
||
return repository.findByStartDateBetween(startOfMonth, endOfMonth); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters