From ba8e495efc1111e08f0977047be11aaac454a3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=ED=98=84=EC=95=A0?= Date: Thu, 24 Mar 2022 20:38:17 +0900 Subject: [PATCH] feat: event get api --- .../Config/security/WebSecurityConfig.java | 3 ++- .../Event/controller/EventController.java | 15 ++++++++++++--- .../notinote/Event/service/EventService.java | 10 +++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/spring/notinote/src/main/java/com/answer/notinote/Config/security/WebSecurityConfig.java b/spring/notinote/src/main/java/com/answer/notinote/Config/security/WebSecurityConfig.java index 24d7211..8541780 100644 --- a/spring/notinote/src/main/java/com/answer/notinote/Config/security/WebSecurityConfig.java +++ b/spring/notinote/src/main/java/com/answer/notinote/Config/security/WebSecurityConfig.java @@ -50,7 +50,8 @@ protected void configure(HttpSecurity http) throws Exception { .and() .authorizeRequests() .anyRequest() - .authenticated() + .permitAll() +// .authenticated() .and() .addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class); } diff --git a/spring/notinote/src/main/java/com/answer/notinote/Event/controller/EventController.java b/spring/notinote/src/main/java/com/answer/notinote/Event/controller/EventController.java index c640fa1..b1b2a32 100644 --- a/spring/notinote/src/main/java/com/answer/notinote/Event/controller/EventController.java +++ b/spring/notinote/src/main/java/com/answer/notinote/Event/controller/EventController.java @@ -1,13 +1,10 @@ package com.answer.notinote.Event.controller; -import com.answer.notinote.Child.domain.Child; -import com.answer.notinote.Child.service.ChildService; import com.answer.notinote.Event.domain.Event; import com.answer.notinote.Event.dto.EventRegisterDto; import com.answer.notinote.Event.dto.EventRequestDto; import com.answer.notinote.Event.dto.EventResponseDto; import com.answer.notinote.Event.service.EventService; -import com.answer.notinote.Event.service.GoogleCalendarService; import com.answer.notinote.Notice.domain.entity.Notice; import com.answer.notinote.Notice.service.NoticeService; import lombok.RequiredArgsConstructor; @@ -16,6 +13,8 @@ import java.io.IOException; import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.List; @RestController @@ -34,6 +33,16 @@ public ResponseEntity createEvent(@RequestParam(value = "id") Long id, @Reque return ResponseEntity.ok(new EventResponseDto(event)); } + @GetMapping("/event") + public ResponseEntity getEventList() { + List eventList = eventService.findAll(); + List response = new ArrayList<>(); + for (Event event : eventList) + response.add(new EventResponseDto(event)); + + return ResponseEntity.ok(response); + } + @PutMapping("/event/register") public ResponseEntity registerEvent(@RequestParam(value = "id") Long id, @RequestBody EventRegisterDto registerDto) throws GeneralSecurityException, IOException { return ResponseEntity.ok(eventService.registerEvent(id, registerDto)); diff --git a/spring/notinote/src/main/java/com/answer/notinote/Event/service/EventService.java b/spring/notinote/src/main/java/com/answer/notinote/Event/service/EventService.java index 1de57bc..9573141 100644 --- a/spring/notinote/src/main/java/com/answer/notinote/Event/service/EventService.java +++ b/spring/notinote/src/main/java/com/answer/notinote/Event/service/EventService.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.security.GeneralSecurityException; +import java.util.List; @Service @RequiredArgsConstructor @@ -40,11 +41,10 @@ public urlResponseDto registerEvent(Long id, EventRegisterDto requestDto) throws event.register(requestDto); event.setChild(child); - eventRepository.save(event); - String calendarUrl = calendarService.createEvent(event); - return new urlResponseDto(calendarUrl); + String url = calendarService.createEvent(event); + return new urlResponseDto(url); } public Event findEventById(Long id) { @@ -52,4 +52,8 @@ public Event findEventById(Long id) { () -> new CustomException(ErrorCode.NOT_FOUND) ); } + + public List findAll() { + return eventRepository.findAll(); + } }