Skip to content

Commit

Permalink
Merge pull request #188 from UnivApp/feature/festival
Browse files Browse the repository at this point in the history
feat: 축제 정보 구현
  • Loading branch information
nyeroni authored Nov 20, 2024
2 parents 739c59d + a12f424 commit 0ecc57c
Show file tree
Hide file tree
Showing 74 changed files with 1,203 additions and 637 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Set environment variables
run: echo "FIREBASE_CONFIG=${{ secrets.FIREBASE_CONFIG }}"

- name: Zip the JAR file
run: zip -r myapp.zip build/libs/*.jar appspec.yml scripts

Expand Down Expand Up @@ -79,4 +82,4 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
distribution: 'temurin'
2 changes: 2 additions & 0 deletions src/main/java/yerong/wedle/WedleApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@EnableJpaAuditing
@SpringBootApplication
public class WedleApplication {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import yerong.wedle.calendar.dto.CalendarEventResponse;
import yerong.wedle.calendar.service.CalendarEventService;
Expand All @@ -34,5 +31,4 @@ public ResponseEntity<List<CalendarEventResponse>> getAllEvents() {
List<CalendarEventResponse> responses = calendarEventService.getAll();
return ResponseEntity.ok(responses);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
@AllArgsConstructor
public class CalendarEventResponse {

private Long id;
private Long calendarEventId;
private String title;
private LocalDate date;
private String type;

private boolean notificationActive;
private Long notificationId;
}
Original file line number Diff line number Diff line change
@@ -1,54 +1,83 @@
package yerong.wedle.calendar.service;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import yerong.wedle.calendar.domain.CalendarEvent;
import yerong.wedle.calendar.dto.CalendarEventResponse;
import yerong.wedle.calendar.exception.CalendarEventNotFoundException;
import yerong.wedle.calendar.repository.CalendarEventRepository;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import yerong.wedle.member.domain.Member;
import yerong.wedle.member.exception.MemberNotFoundException;
import yerong.wedle.member.repository.MemberRepository;
import yerong.wedle.notification.domain.Notification;
import yerong.wedle.notification.repository.NotificationRepository;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CalendarEventService {

private final CalendarEventRepository calendarEventRepository;
private final NotificationRepository notificationRepository;
private final MemberRepository memberRepository;

public List<CalendarEventResponse> getAll() {
List<CalendarEvent> calendarEvents = calendarEventRepository.findAll();

return calendarEvents.stream()
.flatMap(event -> convertToDto(event).stream())
.collect(Collectors.toList());
return convertToDto(calendarEvents);
}

public List<CalendarEventResponse> convertToDto(CalendarEvent calendarEvent) {
LocalDate startDate = calendarEvent.getStartDate();
LocalDate endDate = calendarEvent.getEndDate();

if (endDate == null) {
return List.of(new CalendarEventResponse(
calendarEvent.getId(),
calendarEvent.getTitle(),
startDate,
calendarEvent.getCalendarEventType().getDisplayName()
));
}
public List<CalendarEventResponse> convertToDto(List<CalendarEvent> calendarEvents) {
List<CalendarEventResponse> calendarEventResponses = new ArrayList<>();
String socialId = getCurrentUserId();
Member member = memberRepository.findBySocialId(socialId)
.orElseThrow(MemberNotFoundException::new);
for (CalendarEvent calendarEvent : calendarEvents) {
LocalDate startDate = calendarEvent.getStartDate();
LocalDate endDate = calendarEvent.getEndDate();

return startDate.datesUntil(endDate.plusDays(1))
.map(date -> new CalendarEventResponse(
if (endDate == null) {
Notification notification = notificationRepository.findByMemberAndEventAndNotificationDate(member,
calendarEvent, startDate).orElse(null);
Long notificationId = notification != null ? notification.getNotificationId() : null;
calendarEventResponses.add(new CalendarEventResponse(
calendarEvent.getId(),
calendarEvent.getTitle(),
date,
calendarEvent.getCalendarEventType().getDisplayName()
))
.collect(Collectors.toList());
startDate,
calendarEvent.getCalendarEventType().getDisplayName(),
notification != null && notification.isActive() && notification.getNotificationDate()
.equals(startDate),
notificationId
));
} else {
startDate.datesUntil(endDate.plusDays(1))
.forEach(date -> {
Notification notification = notificationRepository.findByMemberAndEventAndNotificationDate(
member, calendarEvent, date).orElse(null);
Long notificationId = notification != null ? notification.getNotificationId() : null;
boolean isActive = notification != null && notification.isActive()
&& notification.getNotificationDate().equals(date);

calendarEventResponses.add(new CalendarEventResponse(
calendarEvent.getId(),
calendarEvent.getTitle(),
date,
calendarEvent.getCalendarEventType().getDisplayName(),
isActive,
notificationId
));
});
}
}
return calendarEventResponses;
}

private String getCurrentUserId() {
String socialId = SecurityContextHolder.getContext().getAuthentication().getName();

return socialId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<ActivityResponse> getActivitiesByUniversityId(Long universityId) {

@Transactional
public List<ActivityResponse> getActivitiesByIds() {
List<Long> activityIds = Arrays.asList(45L, 51L, 94L, 59L, 48L, 18L, 16L, 11L, 19L, 114L);
List<Long> activityIds = Arrays.asList(45L, 50L, 101L, 59L, 138L, 18L, 53L, 13L, 19L, 128L);

List<Activity> activities = activityRepository.findByActivityIdIn(activityIds);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package yerong.wedle.category.event.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yerong.wedle.category.event.dto.ArtistTop10Response;
import yerong.wedle.category.event.service.ArtistService;

@Tag(name = "Artist API", description = "아티스트 정보 API")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/artists")
public class ArtistController {

private final ArtistService artistService;

@Operation(
summary = "가장 많이 방문한 아티스트 조회",
description = "대학교에서 가장 많이 방문한 아티스트 TOP 10을 조회합니다."
)
@GetMapping("/top")
public ResponseEntity<List<ArtistTop10Response>> getTopArtists() {
List<ArtistTop10Response> topArtists = artistService.getTopArtists();
return ResponseEntity.ok(topArtists);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package yerong.wedle.category.event.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import yerong.wedle.category.event.dto.UniversityFestivalResponse;
import yerong.wedle.category.event.service.FestivalService;

@Tag(name = "Festival API", description = "대학교 관련 축제 정보 API")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/festivals")
public class FestivalApiController {
private final FestivalService eventService;

@Operation(
summary = "대학교 이벤트 조회",
description = "대학교 ID를 이용해 해당 대학교에서 진행된 이벤트 목록을 조회합니다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공적으로 축제 목록 조회"),
@ApiResponse(responseCode = "404", description = "해당 대학교를 찾을 수 없음")
}
)
@GetMapping
public ResponseEntity<UniversityFestivalResponse> getEventsByUniversityId(@RequestParam Long universityId) {
UniversityFestivalResponse eventsByUniversityId = eventService.getFestivalsByUniversityId(universityId);
return ResponseEntity.ok(eventsByUniversityId);
}
}
35 changes: 35 additions & 0 deletions src/main/java/yerong/wedle/category/event/domain/Artist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package yerong.wedle.category.event.domain;

import static lombok.AccessLevel.PROTECTED;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.Set;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
public class Artist {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "artist_id")
private Long artistId;

@Column(nullable = false)
private String name;
@Column(nullable = false)
private String subname;

private final String image = "";

@OneToMany(mappedBy = "artist", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<FestivalArtist> eventArtists;
}
47 changes: 0 additions & 47 deletions src/main/java/yerong/wedle/category/event/domain/Event.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/yerong/wedle/category/event/domain/EventDetails.java

This file was deleted.

Loading

0 comments on commit 0ecc57c

Please sign in to comment.