diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index baf61fc..4a08313 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,14 +26,6 @@ jobs: chmod +x ./gradlew ./gradlew clean build -x test - - name: create firebase key - run: | - cd ./src/main/resources - ls -a . - touch ./firebase-service-key.json - echo "${{ secrets.FIREBASE_KEY }}" > ./firebase-service-key.json - shell: bash - - name: Docker build & push to docker repo run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} @@ -53,4 +45,4 @@ jobs: sudo docker rm ticats || true sudo docker image rm ${{ secrets.DOCKER_USERNAME }}/ticats:latest || true sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ticats:latest - sudo docker run -d -p 8080:8080 --name ticats -v ${{ secrets.DOCKER_USERNAME }}/ticats:latest + sudo docker run -d -p 8080:8080 --name ticats ${{ secrets.DOCKER_ENV }} ${{ secrets.DOCKER_USERNAME }}/ticats:latest diff --git a/Dockerfile b/Dockerfile index e9e6a93..cee385d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ FROM openjdk:11 + +# JAR 파일을 컨테이너로 복사 ARG JAR_FILE=build/libs/*.jar COPY ${JAR_FILE} app.jar -ENTRYPOINT ["java","-jar","/app.jar"] \ No newline at end of file + +# 애플리케이션 실행 +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/README.md b/README.md index a8df005..cb58e9a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ - TICKETS_S3_SECRET : S3 Secret key 정보 - TICKETS_SECRET : JWT Secret 키 정보 - TICKETS_CLIENT : KAKAO Client 정보(현재 비활성화) - - TICATS_SSL_PW : ssl 인증서의 pw 정보 2. Ticats 어플리케이션 백엔드 build ```bash ./gradlew bootjar diff --git a/src/main/java/project/backend/domain/culturalevent/controller/CulturalEventController.java b/src/main/java/project/backend/domain/culturalevent/controller/CulturalEventController.java index d5e610b..cfa6d17 100644 --- a/src/main/java/project/backend/domain/culturalevent/controller/CulturalEventController.java +++ b/src/main/java/project/backend/domain/culturalevent/controller/CulturalEventController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*; import project.backend.domain.culturalevent.dto.CulturalEventListDto; import project.backend.domain.culturalevent.dto.CulturalEventRetrieveDto; +import project.backend.domain.culturalevent.dto.CulturalEventSearchListDto; import project.backend.domain.culturalevent.entity.CulturalEvent; import project.backend.domain.culturalevent.mapper.CulturalEventMapper; import project.backend.domain.culturalevent.service.CulturalEventService; @@ -61,6 +62,19 @@ public ResponseEntity getCulturalEventList( return ResponseEntity.status(HttpStatus.OK).body(culturalEventResponseDtoList); } + @ApiOperation(value = "문화생활 검색 리스트 조회") + @GetMapping("/search") + public ResponseEntity getCulturalEventSearchList( + @RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "10") int size, + @RequestParam(defaultValue = "") String keyword + ) { + // Response + List culturalEventList = culturalEventService.getCulturalEventSearchList(page, size, keyword); + List CulturalEventSearchListDtoList = culturalEventMapper.culturalEventToCulturalEventSearchListDtos(culturalEventList); + return ResponseEntity.status(HttpStatus.OK).body(CulturalEventSearchListDtoList); + } + @ApiOperation(value = "문화생활 객체 조회") @GetMapping("/{id}") public ResponseEntity getCulturalEvent(@Positive @PathVariable Long id) { diff --git a/src/main/java/project/backend/domain/culturalevent/dto/CulturalEventSearchListDto.java b/src/main/java/project/backend/domain/culturalevent/dto/CulturalEventSearchListDto.java new file mode 100644 index 0000000..7808531 --- /dev/null +++ b/src/main/java/project/backend/domain/culturalevent/dto/CulturalEventSearchListDto.java @@ -0,0 +1,14 @@ +package project.backend.domain.culturalevent.dto; + +import lombok.*; + + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CulturalEventSearchListDto { + private Long id; + private String title; +} \ No newline at end of file diff --git a/src/main/java/project/backend/domain/culturalevent/mapper/CulturalEventMapper.java b/src/main/java/project/backend/domain/culturalevent/mapper/CulturalEventMapper.java index eaaf84a..4f7bbd4 100644 --- a/src/main/java/project/backend/domain/culturalevent/mapper/CulturalEventMapper.java +++ b/src/main/java/project/backend/domain/culturalevent/mapper/CulturalEventMapper.java @@ -7,6 +7,7 @@ import project.backend.domain.culturalevent.dto.CulturalEventCreateDto; import project.backend.domain.culturalevent.dto.CulturalEventListDto; import project.backend.domain.culturalevent.dto.CulturalEventRetrieveDto; +import project.backend.domain.culturalevent.dto.CulturalEventSearchListDto; import project.backend.domain.culturalevent.entity.CulturalEvent; import project.backend.domain.culturalevnetinfo.entity.CulturalEventInfo; import project.backend.domain.member.entity.Member; @@ -29,6 +30,7 @@ public interface CulturalEventMapper { CulturalEventListDto culturalEventToCulturalEventListDto(CulturalEvent culturalEvent); List culturalEventToCulturalEventListDtos(List culturalEventList); + List culturalEventToCulturalEventSearchListDtos(List culturalEventList); } \ No newline at end of file diff --git a/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryCustom.java b/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryCustom.java index 2364479..9bfd47e 100644 --- a/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryCustom.java +++ b/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryCustom.java @@ -8,5 +8,7 @@ public interface CulturalEventRepositoryCustom { List getCulturalEventList(int page, int size, List categories, String ordering, Boolean isOpened, Double latitude, Double longitude); + List getCulturalEventSearchList(int page, int size, String keyword); + List getMemberCulturalEventList(); } diff --git a/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryImpl.java b/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryImpl.java index 6049226..abbecaf 100644 --- a/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryImpl.java +++ b/src/main/java/project/backend/domain/culturalevent/repository/CulturalEventRepositoryImpl.java @@ -1,5 +1,6 @@ package project.backend.domain.culturalevent.repository; +import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.CaseBuilder; import com.querydsl.core.types.dsl.NumberTemplate; @@ -92,6 +93,32 @@ public List getCulturalEventList(int page, int size, List getCulturalEventSearchList(int page, int size, String keyword) { + + // 현재 시간 + LocalDateTime now = LocalDateTime.now(); + ZonedDateTime zonedDateTime = now.atZone(ZoneId.systemDefault()); + Date dateNow = Date.from(zonedDateTime.toInstant()); + + // Query 객체 + JPAQuery culturalEventJPAQuery = queryFactory.selectFrom(culturalEvent); + + // 지난 문화생활 제외 + culturalEventJPAQuery.where(culturalEvent.endDate.after(dateNow)); + + // keyword 검색 + if (keyword != null && !keyword.isEmpty()) { + culturalEventJPAQuery.where(culturalEvent.title.contains(keyword)); + } + + // 인기순 + culturalEventJPAQuery.orderBy(culturalEvent.point.desc()); + + return culturalEventJPAQuery.fetch(); + } + + @Override public List getMemberCulturalEventList() { Member member = memberJwtService.getMember(); @@ -119,7 +146,7 @@ private OrderSpecifier createWeightOrderSpecifier(List hello) { return weight.asc(); } - public List requestRecommend(Double latitude, Double longitude, List culturalEvents) { + private List requestRecommend(Double latitude, Double longitude, List culturalEvents) { // Example logic to generate recommended IDs, should be replaced with actual implementation return Arrays.asList(200L, 201L, 301L); } diff --git a/src/main/java/project/backend/domain/culturalevent/service/CulturalEventService.java b/src/main/java/project/backend/domain/culturalevent/service/CulturalEventService.java index 57a3e2e..208392c 100644 --- a/src/main/java/project/backend/domain/culturalevent/service/CulturalEventService.java +++ b/src/main/java/project/backend/domain/culturalevent/service/CulturalEventService.java @@ -38,6 +38,10 @@ public List getCulturalEventList(int page, int size, List getCulturalEventSearchList(int page, int size, String keyword) { + return culturalEventRepository.getCulturalEventSearchList(page, size, keyword); + } + public CulturalEvent getCulturalEvent(Long id) { return verifiedCulturalEvent(id); } diff --git a/src/main/java/project/backend/domain/member/controller/MemberController.java b/src/main/java/project/backend/domain/member/controller/MemberController.java index 03da456..a96d5a7 100644 --- a/src/main/java/project/backend/domain/member/controller/MemberController.java +++ b/src/main/java/project/backend/domain/member/controller/MemberController.java @@ -30,7 +30,7 @@ @RestController @RequestMapping("/api/members") @RequiredArgsConstructor -@Api(tags = "B. 멤버 API") +@Api(tags = "B. 멤버") public class MemberController { private final MemberService memberService; diff --git a/src/main/java/project/backend/domain/member/dto/MemberSignupDto.java b/src/main/java/project/backend/domain/member/dto/MemberSignupDto.java index 8145795..a1a08d4 100644 --- a/src/main/java/project/backend/domain/member/dto/MemberSignupDto.java +++ b/src/main/java/project/backend/domain/member/dto/MemberSignupDto.java @@ -23,6 +23,7 @@ public class MemberSignupDto { public String nickname; @Email(message = "유효한 이메일 형식을 입력해야 합니다.") + @Size(max = 40, message = "이메일은 최대 40글자까지 작성이 가능해요.") @Schema(description = "이메일", example = "ticats@gmail.com", required = true) public String email; diff --git a/src/main/java/project/backend/global/config/FirebaseConfig.java b/src/main/java/project/backend/global/config/FirebaseConfig.java index ebc13ff..aab5826 100644 --- a/src/main/java/project/backend/global/config/FirebaseConfig.java +++ b/src/main/java/project/backend/global/config/FirebaseConfig.java @@ -3,20 +3,28 @@ import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; +import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InputStream; @Configuration public class FirebaseConfig { + @Value("${firebase.key}") + private String fcmSecretKey; + @Bean public FirebaseApp initializeFirebaseApp() throws IOException { - ClassPathResource resource = new ClassPathResource("firebase-service-key.json"); - InputStream serviceAccount = resource.getInputStream(); + if (fcmSecretKey == null) { + throw new IOException("FCM_SECRET environment variable is not set."); + } + + ByteArrayInputStream serviceAccount = new ByteArrayInputStream(fcmSecretKey.getBytes()); FirebaseOptions options = new FirebaseOptions.Builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ca34854..a607395 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -77,3 +77,6 @@ server: swagger: host: www.ticats.site protocol: https + +firebase: + key: ${FCM_SECRET}