Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 가격 수정 기능 #83

Merged
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3f19d81
fix: Member 중복된 메서드 제거
ajy9851 Oct 28, 2024
92b6853
feat: 주문 내역 조회 api
ajy9851 Oct 28, 2024
95977c2
feat: 주문 상세 내역 조회(참가자) api
ajy9851 Oct 29, 2024
a345c2e
feat: 주문 상세 내역 조회(방장) api
ajy9851 Oct 29, 2024
2ca6a74
rename: order dto 이름 변경
ajy9851 Oct 29, 2024
3e05e52
fix: 충돌 해결
ajy9851 Nov 1, 2024
bbfd92d
feat: 응답헤더로 cookie set (httponly, secure 적용)
westzeroright Nov 2, 2024
e3d6300
Merge pull request #71 from kakao-tech-campus-2nd-step3/refactor/70/l…
westzeroright Nov 4, 2024
76b817b
remove: 중복 파일 제거
nove1080 Nov 4, 2024
77acc76
feat: Point 사용 요청/응답 dto 생성
nove1080 Nov 4, 2024
8224af8
feat: 포인트 차감 API 더미 코드 개발
nove1080 Nov 4, 2024
6f398ab
remove: 사용하지 않는 파일 삭제
nove1080 Nov 5, 2024
61de9d1
feat: data.sql 더미 데이터 추가
nove1080 Nov 5, 2024
a07e72a
feat: 결제 상태 이름으로 조회 메서드 추가
nove1080 Nov 5, 2024
665abd5
feat: 결제 내역 DTO 생성
nove1080 Nov 5, 2024
08eda8d
feat: 결제 내역 조회 기능 구현
nove1080 Nov 5, 2024
f922e67
feat: 결제 내역 조회 API 개발
nove1080 Nov 5, 2024
9b45b76
test: 테스트 코드 유지보수
nove1080 Nov 5, 2024
1b500c1
Merge branch 'weekly_10' of https://github.com/kakao-tech-campus-2nd-…
ajy9851 Nov 6, 2024
4400773
fix: 쓰지 않는 패키지 삭제
rbm0524 Nov 6, 2024
4427bc1
refactor: code와 ENUM값 변환 수정
rbm0524 Nov 6, 2024
4c06a03
refactor: code 추가, 변환 로직 추가
rbm0524 Nov 6, 2024
ed8303f
refactor: 예외 추가, 변환 로직 추가
rbm0524 Nov 6, 2024
0ebeeed
refactor: Spot 전체 조회 로직 수정에 다른 메서드 삭제
rbm0524 Nov 6, 2024
28dea61
refactor: converter 어노테이션 추가
rbm0524 Nov 6, 2024
be92b91
fix: 사용하지 않는 메서드 삭제
rbm0524 Nov 6, 2024
534e04b
refactor: String으로 타입 변환
rbm0524 Nov 6, 2024
b89e120
refactor: Builder 어노테이션 추가
rbm0524 Nov 6, 2024
a2eb986
refactor: String으로 타입 변환
rbm0524 Nov 6, 2024
a4a2ac5
refactor: setter 추가
rbm0524 Nov 6, 2024
b941cec
refactor: Exception refactor
rbm0524 Nov 6, 2024
af5eb74
refactor: Mapping 방식 수정
rbm0524 Nov 6, 2024
5ec5e0c
refactor: 예외 처리 로직 추가, 채워지지 않는 필드에 대한 로직 추가
rbm0524 Nov 6, 2024
818c78d
refactor: String으로 타입 변환
rbm0524 Nov 6, 2024
8ccad08
feat: Exception 추가
rbm0524 Nov 6, 2024
87eadd1
feat: 테스트 코드 작성
rbm0524 Nov 6, 2024
6edc5df
fix: 충돌 해결
ajy9851 Nov 7, 2024
9755d2a
fix: 중복으로 인한 에러 수정
rbm0524 Nov 7, 2024
b955efe
fix: category를 제외한 다른 필드들도 매핑되도록 수정
rbm0524 Nov 7, 2024
f945b67
refactor: 테스트 추가 작성
rbm0524 Nov 7, 2024
bc8fc49
Merge branch 'weekly_10' of https://github.com/kakao-tech-campus-2nd-…
ajy9851 Nov 7, 2024
3d1735a
refactor: dialect 추가
rbm0524 Nov 7, 2024
09bb55f
feat: Category.class를 AbstractCodedEnumConverter에 전달하는 클래스 작성
rbm0524 Nov 7, 2024
9ca780c
fix: Autowired 제거
rbm0524 Nov 7, 2024
e2aec99
refactor: 클래스를 상속해서 Category에 대한 Converter가 동작하도록 수정
rbm0524 Nov 7, 2024
59c7550
feat: OrderDetail 엔티티에 updatePrice 메서드 추가
ajy9851 Nov 7, 2024
47963ef
feat: updateOrderPrice 메서드 추가
ajy9851 Nov 7, 2024
0a21711
feat: 참여자 가격 수정 req 레코드 클래스
ajy9851 Nov 7, 2024
505eb95
fix: CategoryConverter를 사용하는 것으로 수정
rbm0524 Nov 7, 2024
7b83ee7
feat: 가격 수정 엔드포인트 생성
ajy9851 Nov 7, 2024
74acf00
Merge branch 'weekly_10' of https://github.com/kakao-tech-campus-2nd-…
ajy9851 Nov 8, 2024
4a191d5
fix: 어노테이션 수정
ajy9851 Nov 8, 2024
40c7898
refactor: 메서드명 변경
ajy9851 Nov 8, 2024
56dd002
refactor: 메서드명 변경
ajy9851 Nov 8, 2024
cabbdf7
Revert "refactor: 메서드명 변경"
ajy9851 Nov 8, 2024
e5f8442
fix: 잘못 pull한 것들 수정
ajy9851 Nov 8, 2024
6635e7e
chore: coolsms 추가
ajy9851 Nov 8, 2024
3f5cc53
refactor: 주석 제거
ajy9851 Nov 8, 2024
015544d
Merge branch 'weekly_11' into feat/58/get-my-orders
ajy9851 Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -46,9 +48,22 @@ public ResponseEntity<ApiResponse<String>> getToken(@RequestHeader String author
String userKakaoEmail = kakaoAuthService.getKakaoUserEmail(authorizationCode);
Optional<Member> existMember = memberService.findMemberByEmail(userKakaoEmail);
if (existMember.isPresent()) {
return ResponseEntity.ok(
ApiResponse.with(HttpStatus.OK, "로그인 성공", authService.getServiceToken(userKakaoEmail)));
String serviceToken = authService.getServiceToken(userKakaoEmail);

ResponseCookie cookie =
ResponseCookie.from("serviceToken", serviceToken)
.httpOnly(true)
.secure(true)
.path("/")
.sameSite("Strict")
.build();

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.SET_COOKIE, cookie.toString());

return ResponseEntity.ok()
.headers(headers)
.body(ApiResponse.with(HttpStatus.OK, "로그인 성공", serviceToken));
} else {
return ResponseEntity.status(HttpStatus.FOUND)
.location(
Expand All @@ -63,13 +78,20 @@ public ResponseEntity<ApiResponse<String>> signUpMember(
String serviceToken =
authService.register(
email, memberInfoRequest.deliveryName(), memberInfoRequest.phoneNumber());
return ResponseEntity.ok(ApiResponse.with(HttpStatus.OK, "로그인 성공", serviceToken));
}

@PostMapping("/signup")
public ResponseEntity<ApiResponse<String>> signUpMember(
@RequestParam String email, @RequestBody MemberInfoRequest memberInfoRequest) {
return authService.register(
email, memberInfoRequest.deliveryName(), memberInfoRequest.phoneNumber());
ResponseCookie cookie =
ResponseCookie.from("serviceToken", serviceToken)
.httpOnly(true)
.secure(true)
.path("/")
.sameSite("Strict")
.build();

HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.SET_COOKIE, cookie.toString());

return ResponseEntity.ok()
.headers(headers)
.body(ApiResponse.with(HttpStatus.OK, "회원가입 성공", serviceToken));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ordertogether.team14_be.member.application.service;

import com.ordertogether.team14_be.auth.JwtUtil;
import com.ordertogether.team14_be.member.application.dto.MemberInfoResponse;
import com.ordertogether.team14_be.member.application.exception.NotFoundMember;
import com.ordertogether.team14_be.member.persistence.MemberRepository;
Expand Down Expand Up @@ -36,25 +37,6 @@ public MemberInfoResponse findMemberInfo(Long memberId) {
.build();
}

@Transactional(readOnly = true)
public Long getMemberId(String email) {
return memberRepository
.findByEmail(email)
.map(Member::getId)
.orElseThrow(() -> new NoSuchElementException("Member with email " + email + " not found"));
}

@Transactional(readOnly = true)
public MemberInfoResponse findMemberInfo(Long memberId) {
Member member = findMember(memberId);

return MemberInfoResponse.builder()
.deliveryName(member.getDeliveryName())
.phoneNumber(member.getPhoneNumber())
.point(member.getPoint())
.build();
}

@Transactional
public MemberInfoResponse modifyMember(Long memberId, String deliveryName, String phoneNumber) {
Member member = findMember(memberId);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
package com.ordertogether.team14_be.order.details.controller;

import com.ordertogether.team14_be.order.details.dto.create.CreateOrderDetailRequestDto;
import com.ordertogether.team14_be.order.details.dto.create.CreateOrderDetailResponseDto;
import com.ordertogether.team14_be.member.persistence.entity.Member;
import com.ordertogether.team14_be.member.presentation.LoginMember;
import com.ordertogether.team14_be.order.details.dto.create.CreateOrderDetailReq;
import com.ordertogether.team14_be.order.details.dto.create.CreateOrderDetailRes;
import com.ordertogether.team14_be.order.details.dto.get.GetCreatorOrderInfoRes;
import com.ordertogether.team14_be.order.details.dto.get.GetOrdersInfoReq;
import com.ordertogether.team14_be.order.details.dto.get.GetOrdersInfoRes;
import com.ordertogether.team14_be.order.details.dto.get.GetParticipantOrderInfoRes;
import com.ordertogether.team14_be.order.details.dto.update.UpdateOrderPriceReq;
import com.ordertogether.team14_be.order.details.service.OrderDetailService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -19,10 +31,36 @@ public class OrderDetailController {

// 주문 생성
@PostMapping
public ResponseEntity<CreateOrderDetailResponseDto> createOrderDetail(
@RequestBody CreateOrderDetailRequestDto createOrderDetailRequestDto) {
CreateOrderDetailResponseDto createOrderDetailResponseDto =
orderDetailService.createOrderDetail(createOrderDetailRequestDto);
return ResponseEntity.ok(createOrderDetailResponseDto);
public ResponseEntity<CreateOrderDetailRes> createOrderDetail(
@RequestBody CreateOrderDetailReq createOrderDetailReq) {
CreateOrderDetailRes createOrderDetailRes =
orderDetailService.createOrderDetail(createOrderDetailReq);
return ResponseEntity.ok(createOrderDetailRes);
}

@GetMapping
public ResponseEntity<GetOrdersInfoRes> getOrdersInfo(
@LoginMember Member member, @ModelAttribute @Valid GetOrdersInfoReq dto) {
return ResponseEntity.ok(orderDetailService.getOrdersInfo(member, dto));
}

@GetMapping("/participant")
public ResponseEntity<GetParticipantOrderInfoRes> getParticipantOrderInfo(
@LoginMember Member member, @RequestParam(name = "spot-id") Long spotId) {
return ResponseEntity.ok(orderDetailService.getParticipantOrderInfo(member, spotId));
}

@GetMapping("/creator")
public ResponseEntity<GetCreatorOrderInfoRes> getCreatorOrderInfo(
@LoginMember Member member, @RequestParam(name = "spot-id") Long spotId) {
return ResponseEntity.ok(orderDetailService.getCreatorOrderInfo(member, spotId));
}

// 가격 수정
@PutMapping("/price")
public ResponseEntity<Void> updateOrderPrice(
@LoginMember Member member, @ModelAttribute @Valid UpdateOrderPriceReq dto) {
ajy9851 marked this conversation as resolved.
Show resolved Hide resolved
orderDetailService.updateOrderPrice(member, dto);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class CreateOrderDetailRequestDto {
public class CreateOrderDetailReq {
private int price;
private boolean isPayed;
private Long participantId; // 참여자 아이디
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class CreateOrderDetailResponseDto {
public class CreateOrderDetailRes {
private Long id;
private int price;
private boolean isPayed;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ordertogether.team14_be.order.details.dto.get;

import java.util.List;

public record GetCreatorOrderInfoRes(
String category,
String storeName,
int minimumOrderAmount,
String pickUpLocation,
String deliveryStatus,
List<MemberBriefInfo> memberInfo) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.ordertogether.team14_be.order.details.dto.get;

import java.util.List;

public record GetOrdersInfoReq(
Integer page, Integer size, List<String> sort // 첫 번째 - 정렬할 필드명(DB 기준), 두 번째 - 정렬 순서(desc, asc)
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.ordertogether.team14_be.order.details.dto.get;

import java.util.List;

public record GetOrdersInfoRes(int totalPages, long totalElements, List<OrderInfo> ordersInfo) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ordertogether.team14_be.order.details.dto.get;

public record GetParticipantOrderInfoRes(
String category,
String storeName,
int minimumOrderAmount,
String pickUpLocation,
String deliveryStatus,
int price) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.ordertogether.team14_be.order.details.dto.get;

public record MemberBriefInfo(long memberId, String deliveryName, int price, boolean isPayed) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.ordertogether.team14_be.order.details.dto.get;

import com.ordertogether.team14_be.order.details.entity.OrderDetail;
import com.ordertogether.team14_be.spot.entity.Spot;

public record OrderInfo(
Long id,
String category,
String storeName,
int minimumOrderAmount,
String pickUpLocation,
String deliveryStatus,
int price,
boolean isCreator) {

public OrderInfo(Long memberId, OrderDetail order, Spot spot) {
this(
order.getId(),
spot.getCategory().toString(),
spot.getStoreName(),
spot.getMinimumOrderAmount(),
spot.getPickUpLocation(),
spot.getDeliveryStatus(),
order.getPrice(),
spot.getMember().getId().equals(memberId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.ordertogether.team14_be.order.details.dto.update;

public record UpdateOrderPriceReq(Long orderId, int price) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ public class OrderDetail extends BaseTimeEntity {
private int price;

private boolean isPayed;

public void updatePrice(int price) {
this.price = price;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
package com.ordertogether.team14_be.order.details.repository;

import com.ordertogether.team14_be.member.persistence.entity.Member;
import com.ordertogether.team14_be.order.details.entity.OrderDetail;
import com.ordertogether.team14_be.spot.entity.Spot;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface OrderDetailRepository extends JpaRepository<OrderDetail, Long> {}
public interface OrderDetailRepository extends JpaRepository<OrderDetail, Long> {
@EntityGraph(attributePaths = {"spot"})
Page<OrderDetail> findAllByMember(Member member, Pageable pageable);

Optional<OrderDetail> findFirstBySpotAndMember(
Spot spot, Member member); // 한 스팟에 여러 멤버가 못들어가는지 확인하고 First빼야 함
ajy9851 marked this conversation as resolved.
Show resolved Hide resolved

List<OrderDetail> findAllBySpot(Spot spot);
}
Loading