From 684b3face63b29b31dd7223bb4460125bfa2f360 Mon Sep 17 00:00:00 2001 From: Soyeon-Cha <7103sy@naver.com> Date: Sat, 16 Mar 2024 22:08:05 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/stop/service/StopService.java | 118 +++++++++++------- 1 file changed, 73 insertions(+), 45 deletions(-) diff --git a/src/main/java/EBus/EBusback/domain/stop/service/StopService.java b/src/main/java/EBus/EBusback/domain/stop/service/StopService.java index a915b70..ef1cffa 100644 --- a/src/main/java/EBus/EBusback/domain/stop/service/StopService.java +++ b/src/main/java/EBus/EBusback/domain/stop/service/StopService.java @@ -156,6 +156,7 @@ public StopTimetable getStopTimetable(Integer stopId){ // 주간 상행 for (TimeTableDay dayUp : dayUps) { int plus1 = 0; + // 주간 연협 상행 (stopId: 1,2,3,4,5) if (Objects.equals(dayUp.getRoute().toString(), "RCB")) { if (stopId == 1) { plus1 = 0; @@ -172,12 +173,17 @@ else if (stopId == 4) { else if (stopId == 5) { plus1 = 7; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route(dayUp.getRoute().toString()) - .time(dayUp.getDepartureTime().plusMinutes(plus1)) - .build(); - ups.add(timeDto); + + if(stopId==1|stopId==2|stopId==3|stopId==4|stopId==5){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route(dayUp.getRoute().toString()) + .time(dayUp.getDepartureTime().plusMinutes(plus1)) + .build(); + ups.add(timeDto); + } } + + // 주간 한우리 상행 (stopId: 1,2,3,6) else if (Objects.equals(dayUp.getRoute().toString(), "HANWOORI")) { if (stopId == 1) { plus1 = 0; @@ -192,17 +198,19 @@ else if (stopId == 6) { plus1 = 7; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route(dayUp.getRoute().toString()) - .time(dayUp.getDepartureTime().plusMinutes(plus1)) - .build(); - ups.add(timeDto); + if(stopId==1|stopId==2|stopId==3|stopId==6){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route(dayUp.getRoute().toString()) + .time(dayUp.getDepartureTime().plusMinutes(plus1)) + .build(); + ups.add(timeDto); + } } } - // 주간 하행 for (TimeTableDay dayDown : dayDowns) { int plus2 = 0; + // 주간 연협 하행 (stopId: 1,2,3,4,5) if (Objects.equals(dayDown.getRoute().toString(), "RCB")) { if (stopId == 1) { plus2 = 7; @@ -219,12 +227,17 @@ else if (stopId == 4) { else if (stopId == 5) { plus2 = 0; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("MAIN_GATE") - .time(dayDown.getDepartureTime().plusMinutes(plus2)) - .build(); - downs.add(timeDto); + + if(stopId==1|stopId==2|stopId==3|stopId==4|stopId==5){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("MAIN_GATE") + .time(dayDown.getDepartureTime().plusMinutes(plus2)) + .build(); + downs.add(timeDto); + } } + + // 주간 한우리 상행 (stopId: 1,2,3,6) else if (Objects.equals(dayDown.getRoute().toString(), "HANWOORI")){ if (stopId == 1) { plus2 = 7; @@ -238,15 +251,18 @@ else if (stopId == 3) { else if (stopId == 6) { plus2 = 0; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("MAIN_GATE") - .time(dayDown.getDepartureTime().plusMinutes(plus2)) - .build(); - downs.add(timeDto); + + if(stopId==1|stopId==2|stopId==3|stopId==6){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("MAIN_GATE") + .time(dayDown.getDepartureTime().plusMinutes(plus2)) + .build(); + downs.add(timeDto); + } } } - // 평일 야간 상행 + // 평일 야간 상행 (stopId: 2,6,7,8) for (TimeTableNight weekdayNightUp : weekdayNightUps) { int plus3 = 0; if (stopId == 8) { @@ -261,14 +277,17 @@ else if (stopId == 6){ else if (stopId == 7){ plus3 = 7; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("E_HOUSE") - .time(weekdayNightUp.getDepartureTime().plusMinutes(plus3)) - .build(); - ups.add(timeDto); + + if(stopId==2|stopId==6|stopId==7|stopId==8){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("E_HOUSE") + .time(weekdayNightUp.getDepartureTime().plusMinutes(plus3)) + .build(); + ups.add(timeDto); + } } - // 평일 야간 하행 + // 평일 야간 하행 (stopId: 2,6,7,8) for (TimeTableNight weekdayNightDown : weekdayNightDowns) { int plus4 = 0; if (stopId == 8) { @@ -283,17 +302,20 @@ else if (stopId == 6){ else if (stopId == 7){ plus4 = 0; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("ART_DESIGN") - .time(weekdayNightDown.getDepartureTime().plusMinutes(plus4)) - .build(); - downs.add(timeDto); + + if(stopId==2|stopId==6|stopId==7|stopId==8){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("ART_DESIGN") + .time(weekdayNightDown.getDepartureTime().plusMinutes(plus4)) + .build(); + downs.add(timeDto); + } } } // 토 : 야간 상하행 전체 else if (dayOfWeekNumber == 6) { - // 토요일 야간 상행 + // 토요일 야간 상행 (stopId: 2,6,7,8) for (TimeTableNight satNightUp : satNightUps) { int plus5 = 0; if (stopId == 8) { @@ -308,14 +330,17 @@ else if (stopId == 6){ else if (stopId == 7){ plus5 = 7; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("E_HOUSE") - .time(satNightUp.getDepartureTime().plusMinutes(plus5)) - .build(); - ups.add(timeDto); + + if(stopId==2|stopId==6|stopId==7|stopId==8){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("E_HOUSE") + .time(satNightUp.getDepartureTime().plusMinutes(plus5)) + .build(); + ups.add(timeDto); + } } - // 토요일 야간 하행 + // 토요일 야간 하행 (stopId: 2,6,7,8) for (TimeTableNight satNightDown : satNightDowns) { int plus6 = 0; if (stopId == 8) { @@ -330,11 +355,14 @@ else if (stopId == 6){ else if (stopId == 7){ plus6 = 0; } - TimeResponseDto timeDto = TimeResponseDto.builder() - .route("ART_DESIGN") - .time(satNightDown.getDepartureTime().plusMinutes(plus6)) - .build(); - downs.add(timeDto); + + if(stopId==2|stopId==6|stopId==7|stopId==8){ + TimeResponseDto timeDto = TimeResponseDto.builder() + .route("ART_DESIGN") + .time(satNightDown.getDepartureTime().plusMinutes(plus6)) + .build(); + downs.add(timeDto); + } } } From 875233eb428e77ff58dd6fc66a60a3cd09960646 Mon Sep 17 00:00:00 2001 From: yeji Date: Sat, 16 Mar 2024 23:02:17 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20role?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/controller/MemberController.java | 13 +++++++++++++ .../domain/member/service/MemberService.java | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/main/java/EBus/EBusback/domain/member/controller/MemberController.java b/src/main/java/EBus/EBusback/domain/member/controller/MemberController.java index 5018bc0..9a59423 100644 --- a/src/main/java/EBus/EBusback/domain/member/controller/MemberController.java +++ b/src/main/java/EBus/EBusback/domain/member/controller/MemberController.java @@ -1,11 +1,13 @@ package EBus.EBusback.domain.member.controller; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import EBus.EBusback.domain.member.entity.Role; import EBus.EBusback.domain.member.service.MemberService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -32,4 +34,15 @@ public String changeToAdmin() { memberService.changeToAdmin(); return "관리자로 변경되었습니다."; } + + @Operation(summary = "사용자 role 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "조회 성공"), + @ApiResponse(responseCode = "401", description = "로그인 필요") + }) + @GetMapping("/role") + @ResponseStatus(HttpStatus.OK) + public Role getRole() { + return memberService.getRole(); + } } diff --git a/src/main/java/EBus/EBusback/domain/member/service/MemberService.java b/src/main/java/EBus/EBusback/domain/member/service/MemberService.java index 2d2c5a5..2e6e29a 100644 --- a/src/main/java/EBus/EBusback/domain/member/service/MemberService.java +++ b/src/main/java/EBus/EBusback/domain/member/service/MemberService.java @@ -5,6 +5,7 @@ import org.springframework.web.server.ResponseStatusException; import EBus.EBusback.domain.member.entity.Member; +import EBus.EBusback.domain.member.entity.Role; import EBus.EBusback.domain.member.repository.MemberRepository; import EBus.EBusback.global.SecurityUtil; import EBus.EBusback.global.exception.ErrorCode; @@ -24,4 +25,12 @@ public void changeToAdmin() { member.changeRole(); } + + public Role getRole() { + Member member = SecurityUtil.getCurrentUser(); + if (member == null) + throw new ResponseStatusException(ErrorCode.NON_LOGIN.getStatus(), ErrorCode.NON_LOGIN.getMessage()); + + return member.getRole(); + } } From 5eab0f342805290731d70e8fe0a3934e994ee64f Mon Sep 17 00:00:00 2001 From: yeji Date: Sat, 16 Mar 2024 23:13:45 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=88=98=20=EA=B3=84=EC=82=B0=ED=95=98=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EBusback/domain/heart/repository/HeartRepository.java | 3 +++ .../java/EBus/EBusback/domain/heart/service/HeartService.java | 4 ++++ .../java/EBus/EBusback/domain/post/service/PostService.java | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/EBus/EBusback/domain/heart/repository/HeartRepository.java b/src/main/java/EBus/EBusback/domain/heart/repository/HeartRepository.java index c50ea39..be4d2aa 100644 --- a/src/main/java/EBus/EBusback/domain/heart/repository/HeartRepository.java +++ b/src/main/java/EBus/EBusback/domain/heart/repository/HeartRepository.java @@ -1,5 +1,6 @@ package EBus.EBusback.domain.heart.repository; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,5 +13,7 @@ public interface HeartRepository extends JpaRepository { Optional findByMemberAndPost(Member member, Post post); + List findAllByPostAndIsValid(Post post, Boolean isValid); + Boolean existsByMemberAndPostAndIsValid(Member member, Post post, Boolean isValid); } diff --git a/src/main/java/EBus/EBusback/domain/heart/service/HeartService.java b/src/main/java/EBus/EBusback/domain/heart/service/HeartService.java index dcdddd4..c2578cf 100644 --- a/src/main/java/EBus/EBusback/domain/heart/service/HeartService.java +++ b/src/main/java/EBus/EBusback/domain/heart/service/HeartService.java @@ -51,4 +51,8 @@ public String createOrRemoveHeart(Long postId) { public Boolean existsHeart(Member member, Post post) { return heartRepository.existsByMemberAndPostAndIsValid(member, post, true); } + + public Integer getHeartCount(Post post) { + return heartRepository.findAllByPostAndIsValid(post, true).size(); + } } diff --git a/src/main/java/EBus/EBusback/domain/post/service/PostService.java b/src/main/java/EBus/EBusback/domain/post/service/PostService.java index 23d3aa8..7981308 100644 --- a/src/main/java/EBus/EBusback/domain/post/service/PostService.java +++ b/src/main/java/EBus/EBusback/domain/post/service/PostService.java @@ -50,7 +50,7 @@ public PostDetailResponseDto findPost(Long postId) { .orElseThrow(() -> new ResponseStatusException( ErrorCode.NO_POST_EXIST.getStatus(), ErrorCode.NO_POST_EXIST.getMessage())); Member member = SecurityUtil.getCurrentUser(); - return new PostDetailResponseDto(new PostCreateResponseDto(post), post.getHeartList().size(), + return new PostDetailResponseDto(new PostCreateResponseDto(post), heartService.getHeartCount(post), findPostMemberInfo(post, member)); } @@ -68,7 +68,7 @@ public PostMemberDto findPostMemberInfo(Post post, Member member) { public List findPostList(Boolean isSuggestion) { List postList = postRepository.findAllByIsSuggestion(isSuggestion); return postList.stream() - .map(post -> new PostOutlineResponseDto(post, post.getHeartList().size())) + .map(post -> new PostOutlineResponseDto(post, heartService.getHeartCount(post))) .collect(Collectors.toList()); }