Skip to content

Commit

Permalink
feat: event get api
Browse files Browse the repository at this point in the history
  • Loading branch information
raae7742 committed Mar 24, 2022
1 parent 1079910 commit ba8e495
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ protected void configure(HttpSecurity http) throws Exception {
.and()
.authorizeRequests()
.anyRequest()
.authenticated()
.permitAll()
// .authenticated()
.and()
.addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,6 +13,8 @@

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;


@RestController
Expand All @@ -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<Event> eventList = eventService.findAll();
List<EventResponseDto> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.List;

@Service
@RequiredArgsConstructor
Expand All @@ -40,16 +41,19 @@ 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) {
return eventRepository.findById(id).orElseThrow(
() -> new CustomException(ErrorCode.NOT_FOUND)
);
}

public List<Event> findAll() {
return eventRepository.findAll();
}
}

0 comments on commit ba8e495

Please sign in to comment.