Skip to content

Commit

Permalink
Feat: 문화생활 검색
Browse files Browse the repository at this point in the history
  • Loading branch information
rrosiee committed Jun 1, 2024
1 parent a43525d commit 8d1368d
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 17 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM openjdk:11

# JAR 파일을 컨테이너로 복사
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

# 애플리케이션 실행
ENTRYPOINT ["java", "-jar", "/app.jar"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CulturalEvent> culturalEventList = culturalEventService.getCulturalEventSearchList(page, size, keyword);
List<CulturalEventSearchListDto> CulturalEventSearchListDtoList = culturalEventMapper.culturalEventToCulturalEventSearchListDtos(culturalEventList);
return ResponseEntity.status(HttpStatus.OK).body(CulturalEventSearchListDtoList);
}

@ApiOperation(value = "문화생활 객체 조회")
@GetMapping("/{id}")
public ResponseEntity getCulturalEvent(@Positive @PathVariable Long id) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,7 @@ public interface CulturalEventMapper {
CulturalEventListDto culturalEventToCulturalEventListDto(CulturalEvent culturalEvent);

List<CulturalEventListDto> culturalEventToCulturalEventListDtos(List<CulturalEvent> culturalEventList);
List<CulturalEventSearchListDto> culturalEventToCulturalEventSearchListDtos(List<CulturalEvent> culturalEventList);


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
public interface CulturalEventRepositoryCustom {
List<CulturalEvent> getCulturalEventList(int page, int size, List<CategoryTitle> categories, String ordering, Boolean isOpened, Double latitude, Double longitude);

List<CulturalEvent> getCulturalEventSearchList(int page, int size, String keyword);

List<CulturalEvent> getMemberCulturalEventList();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -92,6 +93,32 @@ public List<CulturalEvent> getCulturalEventList(int page, int size, List<Categor
return culturalEventJPAQuery.fetch();
}

@Override
public List<CulturalEvent> 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<CulturalEvent> 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<CulturalEvent> getMemberCulturalEventList() {
Member member = memberJwtService.getMember();
Expand Down Expand Up @@ -119,7 +146,7 @@ private OrderSpecifier<Double> createWeightOrderSpecifier(List<Long> hello) {
return weight.asc();
}

public List<Long> requestRecommend(Double latitude, Double longitude, List<CulturalEvent> culturalEvents) {
private List<Long> requestRecommend(Double latitude, Double longitude, List<CulturalEvent> culturalEvents) {
// Example logic to generate recommended IDs, should be replaced with actual implementation
return Arrays.asList(200L, 201L, 301L);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public List<CulturalEvent> getCulturalEventList(int page, int size, List<Categor
return culturalEventRepository.getCulturalEventList(page, size, categories, ordering, isOpened, latitude, longitude);
}

public List<CulturalEvent> getCulturalEventSearchList(int page, int size, String keyword) {
return culturalEventRepository.getCulturalEventSearchList(page, size, keyword);
}

public CulturalEvent getCulturalEvent(Long id) {
return verifiedCulturalEvent(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@RestController
@RequestMapping("/api/members")
@RequiredArgsConstructor
@Api(tags = "B. 멤버 API")
@Api(tags = "B. 멤버")
public class MemberController {

private final MemberService memberService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class MemberSignupDto {
public String nickname;

@Email(message = "유효한 이메일 형식을 입력해야 합니다.")
@Size(max = 40, message = "이메일은 최대 40글자까지 작성이 가능해요.")
@Schema(description = "이메일", example = "[email protected]", required = true)
public String email;

Expand Down
16 changes: 12 additions & 4 deletions src/main/java/project/backend/global/config/FirebaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ server:
swagger:
host: www.ticats.site
protocol: https

firebase:
key: ${FCM_SECRET}

0 comments on commit 8d1368d

Please sign in to comment.