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

[refactor] 주문 기능 회원 인증 과정 추가 #28

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

jw427
Copy link
Owner

@jw427 jw427 commented Sep 10, 2024

Issue

PR 타입(하나 이상의 PR 타입을 선택해주세요)

  • 기능 추가
  • 기능 삭제
  • 버그 수정
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트

반영 브랜치

refactor/order_get_delete -> dev

변경 사항

  • 로그인한 회원만 접근 가능
  • 목록 조회 시 본인 주문 목록만 조회 가능
    • 관리자 계정은 모든 회원 주문 목록 조회 가능
  • 상세 정보 조회 시 본인 주문 정보만 조회 가능
    • 관리자 계정은 모든 회원 주문 상세 조회 가능
  • 삭제 시 본인 주문만 삭제 가능

테스트 결과

1. 주문 목록

Request

HTTP : GET
URL: /api/orders?date=2024-09-07&type=PURCHASE&offset=0
  • Request Header
Authorization: “Bearer XXXXXXXXX”

Response : 성공시

  • 관리자 계정으로 조회 - 모든 회원 주문 목록
    200 OK
{
    "success": true,
    "message": "Success to search orders",
    "data": [
        {
            "orderStatus": "ORDER_COMPLETED",
            "totalPrice": 10110,
            "quantity": 50.55,
            "updatedAt": null,
            "goldType": "GOLD_9999"
        },
        {
            "orderStatus": "ORDER_COMPLETED",
            "totalPrice": 1462,
            "quantity": 11.25,
            "updatedAt": null,
            "goldType": "GOLD_999"
        },
        {
            "orderStatus": "ORDER_COMPLETED",
            "totalPrice": 20000,
            "quantity": 100.00,
            "updatedAt": null,
            "goldType": "GOLD_9999"
        }
    ],
    "links": {}
}
  • 회원 계정으로 조회 - 해당 회원 주문 목록
    200 OK
{
    "success": true,
    "message": "Success to search orders",
    "data": [
        {
            "orderStatus": "ORDER_COMPLETED",
            "totalPrice": 20000,
            "quantity": 100.00,
            "updatedAt": null,
            "goldType": "GOLD_9999"
        }
    ],
    "links": {}
}

Response : 실패시

  • 만료된 액세스 토큰인 경우
    401 Unauthorized
{
    "timestamp": "2024-09-10T12:23:22.307+00:00",
    "status": 401,
    "error": "Unauthorized",
    "trace": "org.springframework.web.server.ResponseStatusException: 401 UNAUTHORIZED \"세션이 만료되었습니다. 다시 로그인해주세요.\"\r\n\tat .....(생략)
    "message": "세션이 만료되었습니다. 다시 로그인해주세요.",
    "path": "/api/orders"
}
  • 헤더가 빈 값일 경우
    401 Unauthorized
{
    "status": 401,
    "message": "유효하지 않은 접근입니다."
}

2. 주문 상세 조회

Request

HTTP : GET
URL: /api/orders/:orderId
  • Request Header
Authorization: “Bearer XXXXXXXXX”

Response : 성공시

  • 관리자 계정으로 조회 또는 해당 회원 계정으로 조회
    200 OK
{
    "orderType": "PURCHASE",
    "orderStatus": "ORDER_COMPLETED",
    "totalPrice": 20000,
    "quantity": 100.00,
    "createdAt": "2024-09-10T21:10:36.687847",
    "updatedAt": null,
    "goldType": "GOLD_9999",
    "deliveryResponseDto": {
        "deliveryStatus": "PENDING",
        "deliveryAt": null,
        "address": "서울시 영등포구 여의대방로",
        "recipientName": "원티드",
        "recipientPhone": "01012345678"
    },
    "paymentResponseDto": {
        "paymentStatus": "PENDING",
        "paymentAt": null,
        "paymentAmount": 20000,
        "bankName": "해외은행",
        "bankAccount": "123-45-678901"
    }
}

Response : 실패시

  • 만료된 액세스 토큰인 경우
    401 Unauthorized
{
    "timestamp": "2024-09-10T12:23:22.307+00:00",
    "status": 401,
    "error": "Unauthorized",
    "trace": "org.springframework.web.server.ResponseStatusException: 401 UNAUTHORIZED \"세션이 만료되었습니다. 다시 로그인해주세요.\"\r\n\tat .....(생략)
    "message": "세션이 만료되었습니다. 다시 로그인해주세요.",
    "path": "/api/orders"
}
  • 헤더가 빈 값일 경우
    401 Unauthorized
{
    "status": 401,
    "message": "유효하지 않은 접근입니다."
}
  • 다른 회원의 목록을 조회하려는 경우
    403 Forbidden
{
    "status": 403,
    "message": "접근 권한이 없습니다."
}

3. 주문 삭제

Request

HTTP : DELETE
URL: /api/orders/:orderId
  • Request Header
Authorization: “Bearer XXXXXXXXX”

Response : 성공시

  • 해당 회원 계정으로 삭제
    204 No Content

Response : 실패시

  • 만료된 액세스 토큰인 경우
    401 Unauthorized
{
    "timestamp": "2024-09-10T12:23:22.307+00:00",
    "status": 401,
    "error": "Unauthorized",
    "trace": "org.springframework.web.server.ResponseStatusException: 401 UNAUTHORIZED \"세션이 만료되었습니다. 다시 로그인해주세요.\"\r\n\tat .....(생략)
    "message": "세션이 만료되었습니다. 다시 로그인해주세요.",
    "path": "/api/orders"
}
  • 헤더가 빈 값일 경우
    401 Unauthorized
{
    "status": 401,
    "message": "유효하지 않은 접근입니다."
}
  • 다른 회원의 주문을 삭제하려는 경우
    403 Forbidden
{
    "status": 403,
    "message": "접근 권한이 없습니다."
}

- 로그인한 회원만 접근 가능
- 목록 조회 시 본인 주문 목록만 조회 가능
- 관리자 계정은 모든 회원 주문 목록 조회 가능
- 로그인한 회원만 접근 가능
- 상세 정보 조회 시 본인 주문 정보만 조회 가능
- 관리자 계정은 모든 회원 주문 상세 조회 가능
- 로그인한 회원만 접근 가능
- 삭제 시 본인 주문만 삭제 가능
@jw427 jw427 added the refactor label Sep 10, 2024
@jw427 jw427 self-assigned this Sep 10, 2024
@jw427 jw427 linked an issue Sep 10, 2024 that may be closed by this pull request
4 tasks
@jw427 jw427 merged commit afe65ea into dev Sep 10, 2024
@jw427 jw427 deleted the refactor/order_get_delete branch September 10, 2024 13:35
@jw427 jw427 changed the title Refactor/order get delete [refactor] 주문 기능 회원 인증 과정 추가 Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

주문 기능 회원 인증 과정 추가
1 participant