From 66cc6bb5c0c5fd0f8aaa978140683ec7f6332166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=98=81?= Date: Sat, 23 Nov 2024 17:15:15 +0900 Subject: [PATCH 1/4] =?UTF-8?q?deploy:=20=EB=B3=80=EA=B2=BD=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EB=B0=98=EC=98=81=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=BB=A4=EB=B0=8B=20(#102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 장바구니 추가 기능 구현 * feat: 장바구니 조회 기능 구현 * feat: 상품 주문과 식권 사용 기능 구현 * style: 포인트트랜잭션 레포지토리명 변경 * deploy: 재배포 * deploy: 재배포2 * deploy: 로그인 로직 수정에 따른 재배포 * deploy: 로그인 로직 수정에 따른 재배포2 * feat: 식권 사용 기능 구현 * feat: yml 수정 사항 반영 * feat: 식권 사용 로직 수정 * feat: 주문 로직 수정 완료 * fix: 장바구니에 아무것도 없을 때 주문 시 active 되는 현상 수정 * feat: 주문 완료 시 리턴 값 수정 * feat: 내 그룹 조회 기능 구현 * feat: 기본 프로필 이미지 url 추가 * feat: 그룹 멤버 전체 조회 기능 구현 * feat: 1인당 사용 가능 금액 설정 컬럼 추가 * feat: 내 지갑 조회 기능 구현 * feat: 선결제 기능 구현 * feat: 유저 홈 화면 조회 기능 구현 * feat: 그룹 상세 조회 기능 구현 * feat: 가게 상세 조회 쿼리 수정 * deploy: 변경사항 반영을 위한 커밋 --- .../java/com/jangburich/domain/menu/service/MenuService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jangburich/domain/menu/service/MenuService.java b/src/main/java/com/jangburich/domain/menu/service/MenuService.java index d42fc6f..b212fe1 100644 --- a/src/main/java/com/jangburich/domain/menu/service/MenuService.java +++ b/src/main/java/com/jangburich/domain/menu/service/MenuService.java @@ -62,7 +62,7 @@ public void updateMenu(String customOAuthUser, Long menuId, MenuUpdateRequestDTO menu.setPrice(menuUpdateRequestDTO.getPrice()); menuRepository.save(menu); - } + }// @Transactional public void deleteMenu(String customOAuthUser, Long id) { From 2bef14837ee631dba582b59b4f2c2a2b728b71d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=98=81?= Date: Sat, 23 Nov 2024 17:15:42 +0900 Subject: [PATCH 2/4] =?UTF-8?q?deploy:=20=EB=B3=80=EA=B2=BD=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EB=B0=98=EC=98=81=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=BB=A4=EB=B0=8B=20(#102)=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 장바구니 추가 기능 구현 * feat: 장바구니 조회 기능 구현 * feat: 상품 주문과 식권 사용 기능 구현 * style: 포인트트랜잭션 레포지토리명 변경 * deploy: 재배포 * deploy: 재배포2 * deploy: 로그인 로직 수정에 따른 재배포 * deploy: 로그인 로직 수정에 따른 재배포2 * feat: 식권 사용 기능 구현 * feat: yml 수정 사항 반영 * feat: 식권 사용 로직 수정 * feat: 주문 로직 수정 완료 * fix: 장바구니에 아무것도 없을 때 주문 시 active 되는 현상 수정 * feat: 주문 완료 시 리턴 값 수정 * feat: 내 그룹 조회 기능 구현 * feat: 기본 프로필 이미지 url 추가 * feat: 그룹 멤버 전체 조회 기능 구현 * feat: 1인당 사용 가능 금액 설정 컬럼 추가 * feat: 내 지갑 조회 기능 구현 * feat: 선결제 기능 구현 * feat: 유저 홈 화면 조회 기능 구현 * feat: 그룹 상세 조회 기능 구현 * feat: 가게 상세 조회 쿼리 수정 * deploy: 변경사항 반영을 위한 커밋 --- .../java/com/jangburich/domain/menu/service/MenuService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jangburich/domain/menu/service/MenuService.java b/src/main/java/com/jangburich/domain/menu/service/MenuService.java index d42fc6f..b212fe1 100644 --- a/src/main/java/com/jangburich/domain/menu/service/MenuService.java +++ b/src/main/java/com/jangburich/domain/menu/service/MenuService.java @@ -62,7 +62,7 @@ public void updateMenu(String customOAuthUser, Long menuId, MenuUpdateRequestDTO menu.setPrice(menuUpdateRequestDTO.getPrice()); menuRepository.save(menu); - } + }// @Transactional public void deleteMenu(String customOAuthUser, Long id) { From 8e15b3c6f28ec24eb33571ca0e9f1ca45f49708c Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Sat, 23 Nov 2024 17:43:15 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20team=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=85=EB=A0=A5=EC=8B=9C=20team=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/team/application/TeamService.java | 94 ++++++++++++------- .../team/dto/response/TeamCodeResponse.java | 33 +++++++ .../team/presentation/TeamController.java | 32 ++++--- 3 files changed, 114 insertions(+), 45 deletions(-) create mode 100644 src/main/java/com/jangburich/domain/team/dto/response/TeamCodeResponse.java diff --git a/src/main/java/com/jangburich/domain/team/application/TeamService.java b/src/main/java/com/jangburich/domain/team/application/TeamService.java index 21af0c6..aeacc6b 100644 --- a/src/main/java/com/jangburich/domain/team/application/TeamService.java +++ b/src/main/java/com/jangburich/domain/team/application/TeamService.java @@ -1,15 +1,13 @@ package com.jangburich.domain.team.application; -import com.jangburich.domain.common.Status; -import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse; -import com.jangburich.domain.team.dto.response.MyTeamResponse; -import com.jangburich.domain.team.dto.response.TeamMemberResponse; import java.util.ArrayList; import java.util.List; import java.util.Optional; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.jangburich.domain.common.Status; import com.jangburich.domain.team.domain.Team; import com.jangburich.domain.team.domain.TeamLeader; import com.jangburich.domain.team.domain.TeamType; @@ -17,6 +15,10 @@ import com.jangburich.domain.team.domain.repository.TeamRepository; import com.jangburich.domain.team.domain.repository.UserTeamRepository; import com.jangburich.domain.team.dto.request.RegisterTeamRequest; +import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse; +import com.jangburich.domain.team.dto.response.MyTeamResponse; +import com.jangburich.domain.team.dto.response.TeamCodeResponse; +import com.jangburich.domain.team.dto.response.TeamMemberResponse; import com.jangburich.domain.user.domain.User; import com.jangburich.domain.user.repository.UserRepository; import com.jangburich.global.payload.Message; @@ -88,10 +90,10 @@ public Message joinTeam(String userId, String joinCode) { public List getMyTeamByCategory(String userId, String category) { User user = userRepository.findByProviderId(userId) - .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); + .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); List teams = teamRepository.findAllByUserAndStatus(user, Status.ACTIVE) - .orElseThrow(() -> new IllegalArgumentException("해당하는 팀을 찾을 수 없습니다.")); + .orElseThrow(() -> new IllegalArgumentException("해당하는 팀을 찾을 수 없습니다.")); List myTeamResponses = new ArrayList<>(); @@ -101,20 +103,21 @@ public List getMyTeamByCategory(String userId, String category) int peopleCount = userTeamRepository.countByTeam(team); List profileImageUrls = userTeamRepository.findAllByTeam(team).stream() - .map(userTeam -> Optional.ofNullable(userTeam.getUser().getProfileImageUrl()).orElse(DEFAULT_PROFILE_IMAGE_URL)) - .toList(); + .map(userTeam -> Optional.ofNullable(userTeam.getUser().getProfileImageUrl()) + .orElse(DEFAULT_PROFILE_IMAGE_URL)) + .toList(); if ("ALL".equalsIgnoreCase(category) || - ("LEADER".equalsIgnoreCase(category) && isMeLeader) || - ("MEMBER".equalsIgnoreCase(category) && !isMeLeader)) { + ("LEADER".equalsIgnoreCase(category) && isMeLeader) || + ("MEMBER".equalsIgnoreCase(category) && !isMeLeader)) { MyTeamResponse response = new MyTeamResponse( - team.getName(), - team.getTeamType().toString(), - false, // isLiked는 임의로 false로 설정 - peopleCount, - isMeLeader, - profileImageUrls + team.getName(), + team.getTeamType().toString(), + false, // isLiked는 임의로 false로 설정 + peopleCount, + isMeLeader, + profileImageUrls ); myTeamResponses.add(response); } @@ -125,45 +128,68 @@ public List getMyTeamByCategory(String userId, String category) public MyTeamDetailsResponse getTeamDetailsById(String userId, Long teamId) { User user = userRepository.findByProviderId(userId) - .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); + .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); Team team = teamRepository.findById(teamId) - .orElseThrow(() -> new IllegalArgumentException("해당 팀을 찾을 수 없습니다.")); + .orElseThrow(() -> new IllegalArgumentException("해당 팀을 찾을 수 없습니다.")); if (!team.getTeamLeader().getUser_id().equals(user.getUserId())) { // 일반 구성원 MyTeamDetailsResponse myTeamDetailsAsMember = teamRepository.findMyTeamDetailsAsMember(user.getUserId(), - teamId); + teamId); return myTeamDetailsAsMember; } // 팀 리더일 때 MyTeamDetailsResponse myTeamDetailsAsLeader = teamRepository.findMyTeamDetailsAsLeader(user.getUserId(), - teamId); + teamId); return myTeamDetailsAsLeader; } public List getTeamMembers(String userId, Long teamId) { User user = userRepository.findByProviderId(userId) - .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); + .orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다.")); Team team = teamRepository.findById(teamId) - .orElseThrow(() -> new IllegalArgumentException("해당하는 팀을 찾을 수 없습니다.")); + .orElseThrow(() -> new IllegalArgumentException("해당하는 팀을 찾을 수 없습니다.")); List userTeams = userTeamRepository.findAllByTeamAndStatus(team, Status.ACTIVE); return userTeams.stream() - .map(userTeam -> { - User teamMember = userTeam.getUser(); - - return new TeamMemberResponse( - teamMember.getUserId(), - teamMember.getName(), - teamMember.getUserId().equals(user.getUserId()), - team.getTeamLeader().getUser_id().equals(teamMember.getUserId()), - Optional.ofNullable(teamMember.getProfileImageUrl()).orElse(DEFAULT_PROFILE_IMAGE_URL) - ); - }) - .toList(); + .map(userTeam -> { + User teamMember = userTeam.getUser(); + + return new TeamMemberResponse( + teamMember.getUserId(), + teamMember.getName(), + teamMember.getUserId().equals(user.getUserId()), + team.getTeamLeader().getUser_id().equals(teamMember.getUserId()), + Optional.ofNullable(teamMember.getProfileImageUrl()).orElse(DEFAULT_PROFILE_IMAGE_URL) + ); + }) + .toList(); + } + + public TeamCodeResponse getTeamsWithSecretCode(String secretCode) { + Team team = teamRepository.findBySecretCode(secretCode) + .orElseThrow(() -> new RuntimeException("시크릿 코드가 존재하지 않습니다.")); + + long count = userTeamRepository.findAllByTeam(team).size(); + + List profileImages = userTeamRepository.findAllByTeam(team) + .stream() + .map(userTeam -> userTeam.getUser().getProfileImageUrl()) + .limit(3) + .toList(); + + TeamCodeResponse teamCodeResponse = new TeamCodeResponse( + team.getName(), + team.getCreatedAt(), + team.getTeamType(), + count, + profileImages, + team.getStatus()); + + return teamCodeResponse; } } diff --git a/src/main/java/com/jangburich/domain/team/dto/response/TeamCodeResponse.java b/src/main/java/com/jangburich/domain/team/dto/response/TeamCodeResponse.java new file mode 100644 index 0000000..992732d --- /dev/null +++ b/src/main/java/com/jangburich/domain/team/dto/response/TeamCodeResponse.java @@ -0,0 +1,33 @@ +package com.jangburich.domain.team.dto.response; + +import java.time.LocalDateTime; +import java.util.List; + +import com.jangburich.domain.common.Status; +import com.jangburich.domain.team.domain.TeamType; + +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +public class TeamCodeResponse { + private String teamName; + private LocalDateTime createdAt; + private TeamType teamType; + private Long teamMembers; + private List teamMemberProfileImages; + private Status status; + + @Builder + public TeamCodeResponse(String teamName, LocalDateTime createdAt, TeamType teamType, Long teamMembers, + List teamMemberProfileImages, Status status) { + this.teamName = teamName; + this.createdAt = createdAt; + this.teamType = teamType; + this.teamMembers = teamMembers; + this.teamMemberProfileImages = teamMemberProfileImages; + this.status = status; + } +} diff --git a/src/main/java/com/jangburich/domain/team/presentation/TeamController.java b/src/main/java/com/jangburich/domain/team/presentation/TeamController.java index c65e0b8..1be370b 100644 --- a/src/main/java/com/jangburich/domain/team/presentation/TeamController.java +++ b/src/main/java/com/jangburich/domain/team/presentation/TeamController.java @@ -1,9 +1,7 @@ package com.jangburich.domain.team.presentation; -import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse; -import com.jangburich.domain.team.dto.response.MyTeamResponse; -import com.jangburich.domain.team.dto.response.TeamMemberResponse; import java.util.List; + import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -15,6 +13,10 @@ import com.jangburich.domain.team.application.TeamService; import com.jangburich.domain.team.dto.request.RegisterTeamRequest; +import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse; +import com.jangburich.domain.team.dto.response.MyTeamResponse; +import com.jangburich.domain.team.dto.response.TeamCodeResponse; +import com.jangburich.domain.team.dto.response.TeamMemberResponse; import com.jangburich.global.payload.Message; import com.jangburich.global.payload.ResponseCustom; import com.jangburich.utils.parser.AuthenticationParser; @@ -53,27 +55,35 @@ public ResponseCustom joinTeam( @Operation(summary = "내가 속한 그룹 조회", description = "내가 속한 그룹을 카테고리(ALL, LEADER, MEMBER) 별로 조회한다.") @GetMapping public ResponseCustom> getMyTeamByCategory( - Authentication authentication, - @RequestParam(required = false, defaultValue = "ALL") String category + Authentication authentication, + @RequestParam(required = false, defaultValue = "ALL") String category ) { - return ResponseCustom.OK(teamService.getMyTeamByCategory(AuthenticationParser.parseUserId(authentication), category)); + return ResponseCustom.OK( + teamService.getMyTeamByCategory(AuthenticationParser.parseUserId(authentication), category)); } @Operation(summary = "그룹(팀) 상세 조회", description = "내가 속한 팀의 정보를 상세 조회합니다.") @GetMapping("/{teamId}") public ResponseCustom getTeamDetailsById( - Authentication authentication, - @PathVariable Long teamId + Authentication authentication, + @PathVariable Long teamId ) { - return ResponseCustom.OK(teamService.getTeamDetailsById(AuthenticationParser.parseUserId(authentication), teamId)); + return ResponseCustom.OK( + teamService.getTeamDetailsById(AuthenticationParser.parseUserId(authentication), teamId)); } @Operation(summary = "그룹(팀) 멤버 전체 조회", description = "그룹(팀)에 소속된 모든 멤버를 조회합니다.") @GetMapping("/{teamId}/members") public ResponseCustom> getTeamMembers( - Authentication authentication, - @PathVariable Long teamId + Authentication authentication, + @PathVariable Long teamId ) { return ResponseCustom.OK(teamService.getTeamMembers(AuthenticationParser.parseUserId(authentication), teamId)); } + + @Operation(summary = "그룹(팀) 비밀코드 조회", description = "비밀코드를 입력하면, 그 팀을 조회하는 api 입니다.") + @GetMapping("/info/{secretCode}") + public ResponseCustom getTeamWithSecretCode(@PathVariable String secretCode) { + return ResponseCustom.OK(teamService.getTeamsWithSecretCode(secretCode)); + } } \ No newline at end of file From 17717f87ec96fcc07d98bdced7916ffb96cbe7bb Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Sat, 23 Nov 2024 19:33:06 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix=20:=20user=20join=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jangburich/domain/user/service/UserService.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/jangburich/domain/user/service/UserService.java b/src/main/java/com/jangburich/domain/user/service/UserService.java index b8aa1b5..6f677cd 100644 --- a/src/main/java/com/jangburich/domain/user/service/UserService.java +++ b/src/main/java/com/jangburich/domain/user/service/UserService.java @@ -54,11 +54,6 @@ public class UserService { private long refreshTokenExpiration; public KakaoApiResponseDTO getUserInfo(String accessToken) { - User user = userRepository.findByProviderId(accessToken) - .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); - - - String userInfoUrl = "https://kapi.kakao.com/v2/user/me"; HttpHeaders headers = new HttpHeaders(); @@ -80,7 +75,7 @@ public User getUserInfos(String accessToken) { @Transactional public TokenResponseDTO joinUser(String kakaoaccessToken) { KakaoApiResponseDTO userInfo = getUserInfo(kakaoaccessToken); - + System.out.println("userInfo = " + userInfo); User user = userRepository.findByProviderId("kakao_" + userInfo.getId()).orElse(null); if (user == null) { user = userRepository.save(User.create("kakao_" + userInfo.getId(), userInfo.getProperties().getNickname(),