Skip to content

Commit

Permalink
Merge pull request #139 from woowacourse-teams/BE/dev
Browse files Browse the repository at this point in the history
[BE] BE/main 브랜치로 BE/dev변경 사항 적용
  • Loading branch information
reddevilmidzy authored Jul 26, 2024
2 parents de0c7a8 + 87d1405 commit 80db446
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 22 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: PULL_REQUEST

on:
pull_request:
types: [opened]

env:
koust6u: U07D1PWSLSG
kelly6bf: U07DSB12K99
JiHyeonL: U07E3T9PMA4
yechop: U07E3TG6CHE
reddevilmidzy: U07DF0QPUKV
dle234: U07E48NCK4G
greetings1012: U07DPGSCXRA
anttiey: U07DPGSCXRA


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Send HTTP request and extract GitHub IDs
id: extract_github_ids
run: |
response=$(curl -s -H "Content-Type: application/json" \
-H "Github_id: ${{ github.event.pull_request.user.login }}" \
http://43.200.237.127:8080/member)
GITHUB_IDS=$(echo "$response" | jq -r 'map(.githubId) | join(" ")')
echo "GITHUB_IDS=$GITHUB_IDS" >> $GITHUB_ENV
- name: Prepare GitHub IDs for Slack message
id: prepare_slack_message
run: |
GITHUB_IDS_ARRAY=($GITHUB_IDS)
SLACK_USER_MENTIONS=""
for GITHUB_ID in "${GITHUB_IDS_ARRAY[@]}"; do
SLACK_ID="${!GITHUB_ID}"
if [ -n "$SLACK_ID" ]; then
SLACK_USER_MENTIONS+="<@$SLACK_ID> "
fi
done
echo "SLACK_USER_MENTIONS=$SLACK_USER_MENTIONS" >> $GITHUB_ENV
- name: PR opened
id: slack-pr-opened
uses: slackapi/[email protected]
with:
channel-id: 'C07DN3TETSL'
payload: |
{
"text": "Backend PR opened: ${{ github.event.pull_request.html_url }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🔔*PR 요청 왔어요. 코드 리뷰해주세요*🔔 \n<${{ github.event.pull_request.html_url }}|`${{github.event.pull_request.title}}`에 대한 코드 리뷰를 해주세요.>\n${{ env.SLACK_USER_MENTIONS }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: thread store api request
run: |
curl -X POST http://43.200.237.127:8080/github/thread \
-H "Content-Type: application/json" \
-d '{"ts": "${{steps.slack-pr-opened.outputs.ts}}", "url": "${{github.event.pull_request.html_url}}"}'
51 changes: 51 additions & 0 deletions .github/workflows/reivew_submit_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Notify Slack on Pull Request Review Request

on:
pull_request_review:
types: [submitted]

env:
koust6u: U07D1PWSLSG
kelly6bf: U07DSB12K99
JiHyeonL: U07E3T9PMA4
yechop: U07E3TG6CHE
reddevilmidzy: U07DF0QPUKV
dle234: U07E48NCK4G
greetings1012: U07DPGSCXRA
anttiey: U07DPGSCXRA

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get Thread TS from API
id: get_ts
run: |
RESPONSE=$(curl -s -X GET "http://43.200.237.127:8080/github/thread" -H "GITHUB_URL: ${{ github.event.pull_request.html_url }}")
TS=$(echo "$RESPONSE" | jq -r '.ts')
echo "THREAD_TS=$TS" >> $GITHUB_ENV
- name: Send Slack notification
uses: slackapi/[email protected]
with:
channel-id: 'C07DN3TETSL'
payload: |
{
"text": "Code review requested for Backend PR: ${{ github.event.pull_request.html_url }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "📫<@${{ env[format('{0}', env.GITHUB_UID)] }}>님 PR에 대한 리뷰가 도착했어요.📫"
}
}
],
"thread_ts": "${{ env.THREAD_TS }}"
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_UID: ${{ github.event.pull_request.user.login }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.net.URI;

import jakarta.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -22,29 +24,37 @@

@RequiredArgsConstructor
@RestController
@CrossOrigin(origins = "http://localhost:3000")
@CrossOrigin(origins = {"http://localhost:3000", "http://3.35.178.58"})
public class PairRoomController implements PairRoomDocs {

private final PairRoomService service;

@PostMapping("/pair-room")
public ResponseEntity<PairRoomCreateResponse> createPairRoom(
@Valid @RequestBody final PairRoomCreateRequest request
) {
final PairRoomCreateResponse response = new PairRoomCreateResponse(service.save(request));

return ResponseEntity.created(URI.create("/"))
.body(response);
}

@GetMapping("/pair-room")
public ResponseEntity<PairRoomReadResponse> getPairRoom(
@RequestParam("accessCode") final PairRoomReadRequest request) {
@Valid @RequestParam("accessCode") final PairRoomReadRequest request
) {
final PairRoomReadResponse response = PairRoomReadResponse.from(
service.findByAccessCode(request.accessCode()));
return ResponseEntity.ok(response);
}

@PostMapping("/pair-room")
public ResponseEntity<PairRoomCreateResponse> createPairRoom(@RequestBody final PairRoomCreateRequest request) {
final PairRoomCreateResponse response = new PairRoomCreateResponse(service.save(request));
return ResponseEntity.created(URI.create("/"))
.body(response);
return ResponseEntity.ok(response);
}

@DeleteMapping("/pair-room")
public ResponseEntity<Void> deletePairRoom(@RequestParam("accessCode") final PairRoomDeleteRequest request) {
public ResponseEntity<Void> deletePairRoom(
@Valid @RequestParam("accessCode") final PairRoomDeleteRequest request
) {
service.deletePairRoom(request.accessCode());

return ResponseEntity.noContent()
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package site.coduo.pairroom.dto;

import jakarta.validation.constraints.NotBlank;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "페어룸 생성 요청 바디")
public record PairRoomCreateRequest(
@Schema(description = "첫 번째 페어의 이름") String firstPair,
@Schema(description = "두 번째 페어의 이름") String secondPair
@Schema(description = "첫 번째 페어의 이름")
@NotBlank
String firstPair,

@Schema(description = "두 번째 페어의 이름")
@NotBlank
String secondPair
) {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package site.coduo.pairroom.dto;

import jakarta.validation.constraints.NotBlank;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "페어룸 삭제 요청 바디")
public record PairRoomDeleteRequest(
@Schema(description = "페어룸 접근 코드", example = "abcdef") String accessCode
@Schema(description = "페어룸 접근 코드", example = "abcdef")
@NotBlank
String accessCode
) {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package site.coduo.pairroom.dto;

import jakarta.validation.constraints.NotBlank;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "페어룸 조회 요청 바디")
public record PairRoomReadRequest(
@Schema(description = "페어룸 접근 코드", example = "abcdef") String accessCode
@Schema(description = "페어룸 접근 코드", example = "abcdef")
@NotBlank
String accessCode
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand All @@ -23,27 +24,28 @@

@RequiredArgsConstructor
@RestController
@CrossOrigin(origins = {"http://localhost:3000", "http://3.35.178.58"})
public class ReferenceLinkController implements ReferenceLinkDocs {

private final ReferenceLinkService referenceLinkService;

@PostMapping("/reference-link")
public ResponseEntity<Void> create(@Valid @RequestBody final ReferenceLinkCreateRequest request) {
public ResponseEntity<Void> createReferenceLink(@Valid @RequestBody final ReferenceLinkCreateRequest request) {
referenceLinkService.createReferenceLinkCommand(request);

return ResponseEntity.created(URI.create("/"))
.build();
}

@GetMapping("/reference-link")
public ResponseEntity<List<ReferenceLinkResponse>> readAll() {
public ResponseEntity<List<ReferenceLinkResponse>> getReferenceLinks() {
final List<ReferenceLinkResponse> responses = referenceLinkService.readAllReferenceLinkQuery();

return ResponseEntity.ok(responses);
}

@PatchMapping("/reference-link/{id}")
public ResponseEntity<Void> update(
public ResponseEntity<Void> updateReferenceLink(
@PathVariable("id") final long id,
@Valid @RequestBody final ReferenceLinkUpdateRequest request
) {
Expand All @@ -54,7 +56,7 @@ public ResponseEntity<Void> update(


@DeleteMapping("/reference-link/{id}")
public ResponseEntity<Void> delete(@PathVariable("id") final long id) {
public ResponseEntity<Void> deleteReferenceLink(@PathVariable("id") final long id) {
referenceLinkService.deleteReferenceLinkCommand(id);

return ResponseEntity.noContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ public interface ReferenceLinkDocs {
@Operation(summary = "레퍼런스 링크를 생성한다.")
@ApiResponse(responseCode = "200", description = "레퍼런스 링크 생성 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ReferenceLinkCreateRequest.class)))
@ApiResponse(responseCode = "4xx", description = "레퍼런스 링크 생성 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<Void> create(
ResponseEntity<Void> createReferenceLink(
@Parameter(description = "레퍼런스 링크 생성 요청", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE), required = true) ReferenceLinkCreateRequest request
);

@Operation(summary = "모든 레퍼런스 링크를 조회한다.")
@ApiResponse(responseCode = "200", description = "레퍼런스 링크 조회 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ReferenceLinkResponse.class)))
@ApiResponse(responseCode = "4xx", description = "레퍼런스 링크 조회 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<List<ReferenceLinkResponse>> readAll();
ResponseEntity<List<ReferenceLinkResponse>> getReferenceLinks();

@Operation(summary = "레퍼런스 링크를 수정한다.")
@ApiResponse(responseCode = "200", description = "레퍼런스 링크 수정 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE))
@ApiResponse(responseCode = "4xx", description = "레퍼런스 링크 수정 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<Void> update(
ResponseEntity<Void> updateReferenceLink(
@Parameter(description = "레퍼런스 링크 식별자", required = true) long id,
@Parameter(description = "레퍼런스 링크 수정 요청", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) ReferenceLinkUpdateRequest request
);

@Operation(summary = "레퍼런스 링크를 삭제한다.")
@ApiResponse(responseCode = "200", description = "레퍼런스 링크 삭제 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE))
@ApiResponse(responseCode = "4xx", description = "레퍼런스 링크 삭제 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<Void> delete(@Parameter(description = "레퍼런스 링크 식별자", required = true) long id);
ResponseEntity<Void> deleteReferenceLink(@Parameter(description = "레퍼런스 링크 식별자", required = true) long id);
}

0 comments on commit 80db446

Please sign in to comment.