Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#49-api
Browse files Browse the repository at this point in the history
  • Loading branch information
k000927 authored Aug 6, 2024
2 parents c7eada6 + fa62f5c commit f780f60
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Deploy to EC2 with Docker Compose

on:
push:
pull_request:
branches:
- fix/#44-casper
- dev

env:
AWS_REGION: ap-northeast-2
Expand Down
4 changes: 3 additions & 1 deletion Server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ dependencies {

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")}
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
annotationProcessor('org.projectlombok:lombok')

}

tasks.named('test') {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import JGS.CasperEvent.domain.event.dto.ResponseDto.RushEventListAndServerTimeResponse;
import JGS.CasperEvent.domain.event.service.eventService.RushEventService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -22,10 +23,10 @@ public ResponseEntity<RushEventListAndServerTimeResponse> getRushEventListAndSer
}

// 밸런스 게임 참여 여부 조회
// @GetMapping("/{eventId}/applied")
// public ResponseEntity<Boolean> checkUserParticipationInRushEvent(@PathVariable Long eventId,
// @CookieValue String userData) {
//
// return ResponseEntity.ok(rushEventService.isExists(eventId, userData));
// }
@GetMapping("/{eventId}/applied")
public ResponseEntity<Boolean> checkUserParticipationInRushEvent(HttpServletRequest httpServletRequest, @PathVariable("eventId") Long eventId) {

String userId = httpServletRequest.getAttribute("userId").toString();
return ResponseEntity.ok(rushEventService.isExists(eventId, userId));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package JGS.CasperEvent.domain.event.repository.participantsRepository;

import JGS.CasperEvent.domain.event.entity.participants.RushParticipants;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface RushParticipantsRepository {
public interface RushParticipantsRepository extends JpaRepository<RushParticipants, String> {
@Query("SELECT CASE WHEN COUNT(rp) > 0 THEN TRUE ELSE FALSE END " +
"FROM RushParticipants rp " +
"WHERE rp.rushEvent.rushEventId = :eventId AND rp.id = :userId")
boolean existsByRushEventIdAndUserId(@Param("eventId") Long eventId, @Param("userId") String userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
import JGS.CasperEvent.domain.event.dto.ResponseDto.RushEventListAndServerTimeResponse;
import JGS.CasperEvent.domain.event.entity.event.RushEvent;
import JGS.CasperEvent.domain.event.repository.eventRepository.RushEventRepository;
import JGS.CasperEvent.domain.event.repository.participantsRepository.RushParticipantsRepository;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class RushEventService {

private final RushEventRepository rushEventRepository;
private final RushParticipantsRepository rushParticipantsRepository;

public RushEventService(RushEventRepository rushEventRepository) {
public RushEventService(RushEventRepository rushEventRepository, RushParticipantsRepository rushParticipantsRepository) {
this.rushEventRepository = rushEventRepository;
this.rushParticipantsRepository = rushParticipantsRepository;
}

public RushEventListAndServerTimeResponse getAllRushEvents() {
Expand All @@ -29,10 +31,7 @@ public RushEventListAndServerTimeResponse getAllRushEvents() {
return new RushEventListAndServerTimeResponse(rushEventDtoList, LocalDateTime.now());
}

// public boolean isExists(Long eventId, String userData) {
// RushEvent rushEvent = findByIdOrElseThrow(rushEventRepository, eventId, CustomErrorCode.NO_RUSH_EVENT);
//
//
// }

public boolean isExists(Long eventId, String userId) {
return rushParticipantsRepository.existsByRushEventIdAndUserId(eventId, userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@RequiredArgsConstructor
public class JwtAuthorizationFilter implements Filter {

private final String[] whiteListUris = new String[]{"/event/auth", "/event/rush", "/event/lottery/caspers", "/admin/join", "/admin/auth", "/h2", "/h2/*"};
private final String[] whiteListUris = new String[]{"/event/auth", "/event/rush", "/event/lottery/caspers", "/admin/join", "/admin/auth", "/h2", "/h2/*", "/swagger-ui/*", "/v3/api-docs", "/v3/api-docs/*"};
private final String[] blackListUris = new String[]{"/event/rush/*"};

private final JwtProvider jwtProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Claims getClaims(String token) {


public Date getExpireDateAccessToken() {
long expireTimeMils = 1000L * 60 * 60 * 24 * 7 * 365;
long expireTimeMils = 1000L * 60 * 60 * 24 * 365;
return new Date(System.currentTimeMillis() + expireTimeMils);
}

Expand Down

0 comments on commit f780f60

Please sign in to comment.