-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from kakao-tech-campus-2nd-step3/feature/19-me…
…mber feat: 회원 관련 API 구현 및 CI 관련 워크플로우 추가
- Loading branch information
Showing
29 changed files
with
973 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: weekly 브랜치 PR에 대한 CI 테스트 | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'weekly/**' | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
checks: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: 프로젝트 코드를 CI 서버로 옮겨오기 | ||
uses: actions/checkout@v4 | ||
|
||
- name: JDK 21 설치 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '21' | ||
|
||
- name: AWS S3 관련 정보를 설정 파일에 주입 | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: ./src/main/resources/application-prod.yml | ||
env: | ||
aws.s3.bucket: ${{ secrets.AWS_S3_BUCKET }} | ||
aws.s3.accessKey: ${{ secrets.AWS_S3_ACCESS_KEY }} | ||
aws.s3.secretKey: ${{ secrets.AWS_S3_SECRET_KEY }} | ||
|
||
- name: 빌드 테스트 수행 | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew clean build | ||
- name: 테스트 수행 결과 보고 | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: 테스트 실패 시, 실패한 코드 라인에 코멘트 자동 등록 | ||
uses: mikepenz/action-junit-report@v3 | ||
if: always() | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
token: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/potatocake/everymoment/config/AwsS3Properties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.potatocake.everymoment.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "aws.s3") | ||
public record AwsS3Properties( | ||
String accessKey, | ||
String secretKey, | ||
String region, | ||
String bucket | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
79 changes: 79 additions & 0 deletions
79
src/main/java/com/potatocake/everymoment/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.potatocake.everymoment.controller; | ||
|
||
import com.potatocake.everymoment.dto.SuccessResponse; | ||
import com.potatocake.everymoment.dto.response.MemberDetailResponse; | ||
import com.potatocake.everymoment.dto.response.MemberResponse; | ||
import com.potatocake.everymoment.dto.response.MemberSearchResponse; | ||
import com.potatocake.everymoment.exception.ErrorCode; | ||
import com.potatocake.everymoment.exception.GlobalException; | ||
import com.potatocake.everymoment.security.MemberDetails; | ||
import com.potatocake.everymoment.service.MemberService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.util.StringUtils; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/members") | ||
@RestController | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@GetMapping | ||
public ResponseEntity<SuccessResponse<MemberSearchResponse>> searchMembers( | ||
@RequestParam(required = false) String nickname, | ||
@RequestParam(required = false) String email, | ||
@RequestParam(required = false) Long key, | ||
@RequestParam(defaultValue = "10") int size) { | ||
|
||
MemberSearchResponse response = memberService.searchMembers(nickname, email, key, size); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok(response)); | ||
} | ||
|
||
@GetMapping("/me") | ||
public ResponseEntity<SuccessResponse<MemberDetailResponse>> myInfo( | ||
@AuthenticationPrincipal MemberDetails memberDetails) { | ||
MemberDetailResponse response = memberService.getMyInfo(memberDetails.getId()); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok(response)); | ||
} | ||
|
||
@GetMapping("/{memberId}") | ||
public ResponseEntity<SuccessResponse<MemberResponse>> memberInfo(@PathVariable Long memberId) { | ||
MemberResponse response = memberService.getMemberInfo(memberId); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok(response)); | ||
} | ||
|
||
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
public ResponseEntity<SuccessResponse<Void>> updateMemberInfo(@AuthenticationPrincipal MemberDetails memberDetails, | ||
@RequestParam(required = false) MultipartFile profileImage, | ||
@RequestParam(required = false) String nickname) { | ||
validateProfileUpdate(profileImage, nickname); | ||
|
||
memberService.updateMemberInfo(memberDetails.getId(), profileImage, nickname); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok()); | ||
} | ||
|
||
private void validateProfileUpdate(MultipartFile profileImage, String nickname) { | ||
if (profileImage == null && !StringUtils.hasText(nickname)) { | ||
throw new GlobalException(ErrorCode.INFO_REQUIRED); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/potatocake/everymoment/dto/response/MemberDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
public class MemberDetailResponse { | ||
|
||
private Long id; | ||
private String profileImageUrl; | ||
private String nickname; | ||
private String email; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/potatocake/everymoment/dto/response/MemberResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Builder | ||
@Getter | ||
public class MemberResponse { | ||
|
||
private Long id; | ||
private String profileImageUrl; | ||
private String nickname; | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/potatocake/everymoment/dto/response/MemberSearchResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@Builder | ||
@Getter | ||
public class MemberSearchResponse { | ||
|
||
private List<MemberResponse> members; | ||
private Long next; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.