-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat(#51): 후원 관련 엔티티 칼럼 설정 및 엔티티간 매핑 * Feat(#51): 커스텀 예외 설정 * Feat(#51): 후원 및 응원 api 개발 * Feat(#51): 후원 및 응원 관련 dto 작성 * Feat(#51): 후원 홈 목록 조회 관련 API 개발 * Feat(#51): 이미지, 후원사URL 데이터 추가 * Feat(#51): swagger 설명 추가 * Refactor(#51): Support 객체 생성 부분 리팩토링 * Refactor(#51): 이미지 변수명 변경 * Feat(#51): 마음 결제 API 구현 * Feat(#51): 후원시 사용자의 마음 갯수 반영 * Refactor(#51): 네이밍 변경 및 커스텀 예외 추가 * Refactor(#51): dto 폴더 위치 오류 수정 * Rename(#51): 폴더명 오타 수정
- Loading branch information
Showing
9 changed files
with
116 additions
and
6 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/numberone/backend/domain/member/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,39 @@ | ||
package com.numberone.backend.domain.member.controller; | ||
|
||
import com.numberone.backend.domain.member.dto.request.BuyHeartRequest; | ||
import com.numberone.backend.domain.member.dto.response.HeartCntResponse; | ||
import com.numberone.backend.domain.member.service.MemberService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Tag(name = "members", description = "사용자 관련 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/members") | ||
public class MemberController { | ||
private final MemberService memberService; | ||
|
||
@PostMapping("/heart") | ||
@Operation(summary = "마음 구입하기", description = """ | ||
구입한 마음 갯수를 body에 담아 전달해주세요. | ||
response 에는 구입한 후에 사용자의 현재 마음 갯수가 저장되어 있습니다. | ||
""") | ||
public ResponseEntity<HeartCntResponse> buyHeart(@RequestBody @Valid BuyHeartRequest buyHeartRequest, Authentication authentication) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(memberService.buyHeart(buyHeartRequest, authentication.getName())); | ||
} | ||
|
||
@GetMapping("/heart") | ||
@Operation(summary = "사용자의 현재 마음 갯수 가져오기", description = """ | ||
사용자의 현재 마음 갯수가 response로 전달됩니다. | ||
""") | ||
public ResponseEntity<HeartCntResponse> getHeart(Authentication authentication) { | ||
return ResponseEntity.ok(memberService.getHeart(authentication.getName())); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/numberone/backend/domain/member/dto/request/BuyHeartRequest.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,11 @@ | ||
package com.numberone.backend.domain.member.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
public class BuyHeartRequest { | ||
@NotNull(message = "구입한 마음 갯수를 입력해주세요") | ||
private Integer heartCnt; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/numberone/backend/domain/member/dto/response/HeartCntResponse.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,18 @@ | ||
package com.numberone.backend.domain.member.dto.response; | ||
|
||
import com.numberone.backend.domain.member.entity.Member; | ||
import lombok.*; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@AllArgsConstructor | ||
@Builder | ||
public class HeartCntResponse { | ||
private Integer heartCnt; | ||
|
||
public static HeartCntResponse of(Member member) { | ||
return HeartCntResponse.builder() | ||
.heartCnt(member.getHeartCnt()) | ||
.build(); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/numberone/backend/exception/badrequest/BadRequestHeartException.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.numberone.backend.exception.badrequest; | ||
|
||
import com.numberone.backend.exception.context.ExceptionContext; | ||
|
||
import static com.numberone.backend.exception.context.CustomExceptionContext.BAD_REQUEST_HEART; | ||
|
||
public class BadRequestHeartException extends BadRequestException{ | ||
|
||
public BadRequestHeartException() { | ||
super(BAD_REQUEST_HEART); | ||
} | ||
} |
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