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/#33 Project API #37

Merged
merged 6 commits into from
Aug 13, 2024
Merged

Feat/#33 Project API #37

merged 6 commits into from
Aug 13, 2024

Conversation

tidavid1
Copy link
Member

๐Ÿš€ ๊ฐœ๋ฐœ ์‚ฌํ•ญ

  • Project ๊ด€๋ จ API ์—”๋“œํฌ์ธํŠธ ๊ตฌํ˜„
    • ํ”„๋กœ์ ํŠธ ์กฐํšŒ (GET)
    • ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ (POST)
    • ํ”„๋กœ์ ํŠธ ์ˆ˜์ • (PUT)
    • ํ”„๋กœ์ ํŠธ ์‚ญ์ œ (DELETE)
  • Project Controller ๋ฐ ๊ด€๋ จ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ

์ด์Šˆ ๋ฒˆํ˜ธ

ํŠน์ด ์‚ฌํ•ญ ๐Ÿซถ

  • ๋ชจ๋“  API ์‘๋‹ต์€ ApiCommonResponse ํ˜•์‹์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.
  • ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ์‹œ HTTP ์ƒํƒœ ์ฝ”๋“œ 201(Created)์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

API ๋ฌธ์„œํ™”

1. ํ”„๋กœ์ ํŠธ ์กฐํšŒ

  • ์—”๋“œํฌ์ธํŠธ: GET /v1/projects/{name}
  • ์„ค๋ช…: ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์œผ๋กœ ํ”„๋กœ์ ํŠธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
  • ์‘๋‹ต ์˜ˆ์‹œ:
    {
      "statusCode": 200,
      "message": "Success",
      "data": {
        "id": 1,
        "name": "projectName",
        "createdAt": "2024-08-13T10:00:00"
      }
    }

2. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

  • ์—”๋“œํฌ์ธํŠธ: POST /v1/projects
  • ์„ค๋ช…: ์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
  • ์š”์ฒญ ๋ณธ๋ฌธ:
    {
      "name": "newProjectName"
    }
  • ์‘๋‹ต ์˜ˆ์‹œ:
    {
      "statusCode": 201,
      "message": "Success",
      "data": {
        "id": 1,
        "name": "newProjectName",
        "createdAt": "2024-08-13T10:00:00"
      }
    }

3. ํ”„๋กœ์ ํŠธ ์ˆ˜์ •

  • ์—”๋“œํฌ์ธํŠธ: PUT /v1/projects/{id}
  • ์„ค๋ช…: ๊ธฐ์กด ํ”„๋กœ์ ํŠธ์˜ ์ •๋ณด๋ฅผ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ์š”์ฒญ ๋ณธ๋ฌธ:
    {
      "name": "updatedProjectName"
    }
  • ์‘๋‹ต ์˜ˆ์‹œ:
    {
      "statusCode": 200,
      "message": "Success",
      "data": {
        "id": 1,
        "name": "updatedProjectName",
        "createdAt": "2024-08-13T10:00:00"
      }
    }

4. ํ”„๋กœ์ ํŠธ ์‚ญ์ œ

  • ์—”๋“œํฌ์ธํŠธ: DELETE /v1/projects/{id}
  • ์„ค๋ช…: ์ง€์ •๋œ ID์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
  • ์‘๋‹ต ์˜ˆ์‹œ:
    {
      "statusCode": 200,
      "message": "Success",
      "data": 1
    }

- ProjectService.updateProjectValues์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.
- ๊ณตํ†ต ์‘๋‹ต ๊ทœ๊ฒฉ์ธ ApiCommonResponse๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.
- Project API Controller๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. (URI: `/v1/projects`)
  - GET `/{name}`: ํ”„๋กœ์ ํŠธ ์กฐํšŒ
  - POST `/`: ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
  - PUT `/{id}`: ํ”„๋กœ์ ํŠธ ์ˆ˜์ •
  - DELETE `/{id}`: ํ”„๋กœ์ ํŠธ ์ œ๊ฑฐ
- `@WebMvcTest` ๊ธฐ๋ฐ˜ ProjectController ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
@tidavid1 tidavid1 requested a review from a team August 13, 2024 06:50
@tidavid1 tidavid1 self-assigned this Aug 13, 2024
@tidavid1 tidavid1 changed the base branch from main to dev August 13, 2024 06:50
- ProjectService MockBean ์ด๋™
@tidavid1 tidavid1 added the โญ๏ธ Feat ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด๋‚˜ ์š”์ฒญ label Aug 13, 2024
Copy link
Member

@LuizyHub LuizyHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ‘

public static ApiCommonResponse<Void> createFailResponse(HttpStatus httpStatus,
String message) {
return new ApiCommonResponse<>(httpStatus.value(), message);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ณตํ†ต ์—๋Ÿฌ ํ•ธ๋“ค๋Ÿฌ๋„ ๋‚˜์ค‘์— ๋งŒ๋“ค์–ด์š”

@LuizyHub
Copy link
Member

์ด์Šˆ์— ์ฒดํฌ๋ฐ•์Šค ์ฑ„์›Œ์ฃผ์„ธ์š”~

Copy link
Member

@miiiinju1 miiiinju1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ข‹์•„์š”~

Comment on lines +32 to +38
@PostMapping
public ResponseEntity<ApiCommonResponse<ProjectCommonResponse>> create(
@RequestBody ProjectCreateRequest request) {
ApiCommonResponse<ProjectCommonResponse> response = ApiCommonResponse.createApiResponse(
HttpStatus.CREATED, "Success", projectService.createProject(request.name()));
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‹จ์ˆœํ•œ status๋ฅผ CREATED๋กœ ์„ค์ •ํ•˜๋Š” ์ž‘์—…์ด๋ผ๋ฉด

  @ResponseStatus(HttpStatus.CREATED)

๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์–ด๋–จ๊นŒ์š”?!!

@miiiinju1 miiiinju1 merged commit 6815a2a into dev Aug 13, 2024
1 check passed
@miiiinju1 miiiinju1 deleted the feat/#33 branch August 13, 2024 08:58
miiiinju1 pushed a commit that referenced this pull request Aug 13, 2024
* chore: ๋ฉ”์„œ๋“œ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ณ€๊ฒฝ

- ProjectService.updateProjectValues์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.

* feat: ๊ณตํ†ต ์‘๋‹ต ๊ทœ๊ฒฉ ๊ตฌํ˜„

- ๊ณตํ†ต ์‘๋‹ต ๊ทœ๊ฒฉ์ธ ApiCommonResponse๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

* feat: Project Controller ๊ตฌํ˜„

- Project API Controller๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. (URI: `/v1/projects`)
  - GET `/{name}`: ํ”„๋กœ์ ํŠธ ์กฐํšŒ
  - POST `/`: ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
  - PUT `/{id}`: ํ”„๋กœ์ ํŠธ ์ˆ˜์ •
  - DELETE `/{id}`: ํ”„๋กœ์ ํŠธ ์ œ๊ฑฐ

* test: Project Controller ํ…Œ์ŠคํŠธ

- `@WebMvcTest` ๊ธฐ๋ฐ˜ ProjectController ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

* chore: ControllerTestSupport ์ˆ˜์ •

- ProjectService MockBean ์ด๋™
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
โญ๏ธ Feat ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด๋‚˜ ์š”์ฒญ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[๐Ÿ’ก FEAT] Project API ๊ตฌํ˜„
3 participants