Skip to content

Commit

Permalink
login설정 문제 해결
Browse files Browse the repository at this point in the history
month와 year받아서 달 동 수정
  • Loading branch information
juhhoho committed Mar 19, 2024
1 parent 89f5cb5 commit dacf8e1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.stream.Collectors;



@RestController
@RequiredArgsConstructor
@Log4j2
Expand All @@ -26,8 +25,8 @@ public class EventController {
private final EventServiceImpl eventServiceImpl;

@GetMapping("/calendar")
public ResponseEntity<List<EventDTO>> calendar_home(){
return ResponseEntity.ok(eventServiceImpl.findMonthlyEvents());
public ResponseEntity<List<EventDTO>> calendar_home(@RequestParam("year") int year, @RequestParam("month") int month){
return ResponseEntity.ok(eventServiceImpl.findMonthlyEvents(year, month));
}

@GetMapping("/calendar/{event_id}")
Expand Down
2 changes: 1 addition & 1 deletion JWT/src/main/java/JWTLogIn/JWT/user/entity/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Builder
@DynamicInsert
@NoArgsConstructor @AllArgsConstructor
@Table(name = "user")
@Table(name = "users")
public class UserEntity extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) // 점직적 증가
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

@Repository
public interface EventRepository extends JpaRepository<EventEntity, Long> {
@Query("SELECT e FROM EventEntity e WHERE YEAR(e.startDate) = YEAR(CURRENT_DATE()) AND MONTH(e.startDate) = MONTH(CURRENT_DATE())")
List<EventEntity> findByCurrentMonthEvents();

@Query("SELECT e FROM EventEntity e WHERE YEAR(e.startDate) = :year AND MONTH(e.startDate) = :month")
List<EventEntity> findByCurrentMonthEvents(int year, int month);
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ public void changeLevel(Long id, Level level) {
}
} // 회원의 level 변경

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

public interface EventService {
List<EventDTO> findMonthlyEvents();
List<EventDTO> findMonthlyEvents(int year, int month);


EventDTO findDayEvent(Long id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class EventServiceImpl implements EventService{

private final EventRepository eventRepository;
@Override
public List<EventDTO> findMonthlyEvents() {
public List<EventDTO> findMonthlyEvents(int year, int month) {

List<EventEntity> monthlyEvents = eventRepository.findByCurrentMonthEvents();
List<EventEntity> monthlyEvents = eventRepository.findByCurrentMonthEvents(year, month);
if(monthlyEvents == null){
return null;
}
Expand Down

0 comments on commit dacf8e1

Please sign in to comment.