-
Notifications
You must be signed in to change notification settings - Fork 1
Implementing CRUD APIs for Business Inquiries #412
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1a17092
feat: add BusinessSupportController with initial setup
hgkim-openerd a17c853
feat : 비즈니스 문의 기능 구현
chadongmin aa24b84
test : 단위테스트
chadongmin 97a1db2
test : 통합테스트
chadongmin c6b4812
test : restdocs 추가
chadongmin 9450af0
fix : CursorPageable.of()가 원본 리스트를 수정하는 대신 해당 부분의 하위 리스트(sublist)를 새로…
chadongmin dfa9531
코드리뷰 반영
chadongmin 52ab9ba
Merge branch 'dev' into feat/406
hgkim-openerd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/docs/asciidoc/api/support/business/business-delete.adoc
This file contains hidden or 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,21 @@ | ||
| === 비지니스 문의 삭제 === | ||
|
|
||
| 용자는 등록한 문의글을 삭제할 수 있습니다. | ||
|
|
||
| 물리적으로 삭제되는 것이 아닌 논리 삭제가 수행되며 status 컬럼이 DELETED로 변경됩니. | ||
|
|
||
| PathVariable로 문의글의 id를 전달합니다. | ||
|
|
||
| 존재하지 않는 문의글 id로 요청을 보낸 경우 HELP_NOT_FOUND 예외가 발생합니다. | ||
|
|
||
| 로그인 한 유저만 요청이 가능하며, 문의글의 작성자가 아닌 경우 HELP_NOT_AUTHORIZED 예외가 발생합니다. | ||
|
|
||
| [source] | ||
| ---- | ||
| DELETE /api/v1/business-support/{id} | ||
| ---- | ||
|
|
||
| [discrete] | ||
| ==== 응답 파라미터 ==== | ||
| include::{snippets}/support/business/delete/response-fields.adoc[] | ||
| include::{snippets}/support/business/delete/response-body.adoc[] |
26 changes: 26 additions & 0 deletions
26
src/docs/asciidoc/api/support/business/business-modify.adoc
This file contains hidden or 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,26 @@ | ||
| === 비지니스 문의 수정 === | ||
|
|
||
| 사용자는 등록한 비지니스 문의글을 수정할 수 있습니다. | ||
|
|
||
| 수정하고자 하는 문의글 `제목`, `내용`, `타입` 은 null일 수 없습니다 | ||
|
|
||
| PathVariable로 문의글의 id를 전달합니다. | ||
|
|
||
| 존재하지 않는 문의글 id로 요청을 보낸 경우 HELP_NOT_FOUND 예외가 발생합니다. | ||
|
|
||
| 로그인 한 유저만 요청이 가능하며, 문의글의 작성자가 아닌 경우 HELP_NOT_AUTHORIZED 예외가 발생합니다. | ||
|
|
||
| [source] | ||
| ---- | ||
| PATCH /api/v1/business-support/{id} | ||
| ---- | ||
|
|
||
| [discrete] | ||
| ==== 요청 파라미터 ==== | ||
| include::{snippets}/support/business/modify/request-fields.adoc[] | ||
| include::{snippets}/support/business/modify/request-body.adoc[] | ||
|
|
||
| [discrete] | ||
| ==== 응답 파라미터 ==== | ||
| include::{snippets}/support/business/modify/response-fields.adoc[] | ||
| include::{snippets}/support/business/modify/response-body.adoc[] |
25 changes: 25 additions & 0 deletions
25
src/docs/asciidoc/api/support/business/business-read-detail.adoc
This file contains hidden or 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,25 @@ | ||
| === 비지니스 문의 상세 조회 === | ||
|
|
||
| 사용자는 등록한 비지니스 문의글 상세조회 할 수 있습니다. | ||
|
|
||
| PathVariable로 문의글의 id를 전달합니다. | ||
|
|
||
| 로그인 한 유저만 조회가 가능합니다. | ||
|
|
||
| 존재하지 않는 문의글 id로 요청을 보낸 경우 HELP_NOT_FOUND 예외가 발생합니다. | ||
|
|
||
| [source] | ||
| ---- | ||
| GET /api/v1/business-support/{id} | ||
| ---- | ||
|
|
||
| [discrete] | ||
| ==== 요청 파라미터 ==== | ||
|
|
||
| - PathVariable id : 문의 아이디 | ||
|
|
||
| [discrete] | ||
| ==== 응답 파라미터 ==== | ||
|
|
||
| include::{snippets}/support/business/read-detail/response-fields.adoc[] | ||
| include::{snippets}/support/business/read-detail/response-body.adoc[] |
18 changes: 18 additions & 0 deletions
18
src/docs/asciidoc/api/support/business/business-read-list.adoc
This file contains hidden or 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 @@ | ||
| === 비지니스 문의 목록 조회 === | ||
|
|
||
| 사용자는 등록한 비지니스 문의글의 목록을 조회할 수 있습니다. | ||
|
|
||
| 로그인 한 유저만 조회가 가능합니다. | ||
|
|
||
| QueryParam으로 cursor와 pageSize를 전달하며, default 값은 cursor는 0, pageSize는 10입니다. | ||
|
|
||
| [source] | ||
| ---- | ||
| GET /api/v1/business-support | ||
| ---- | ||
|
|
||
| [discrete] | ||
| ==== 응답 파라미터 ==== | ||
|
|
||
| include::{snippets}/support/business/read-list/response-fields.adoc[] | ||
| include::{snippets}/support/business/read-list/response-body.adoc[] |
20 changes: 20 additions & 0 deletions
20
src/docs/asciidoc/api/support/business/business-register.adoc
This file contains hidden or 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,20 @@ | ||
| === 비지니스 문의 등록 === | ||
|
|
||
| 사용자는 비지니스 관련 문의를 등록할 수 있습니다. | ||
|
|
||
| [source] | ||
| ---- | ||
| POST /api/v1/business-support | ||
| ---- | ||
|
|
||
| [discrete] | ||
| ==== 요청 파라미터 ==== | ||
|
|
||
| include::{snippets}/support/business/register/request-fields.adoc[] | ||
| include::{snippets}/support/business/register/request-body.adoc[] | ||
|
|
||
| [discrete] | ||
| ==== 응답 파라미터 ==== | ||
|
|
||
| include::{snippets}/support/business/register/response-fields.adoc[] | ||
| include::{snippets}/support/business/register/response-body.adoc[] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
16 changes: 16 additions & 0 deletions
16
src/main/java/app/bottlenote/support/business/constant/BusinessResultMessage.java
This file contains hidden or 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 app.bottlenote.support.business.constant; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum BusinessResultMessage { | ||
| REGISTER_SUCCESS("비지니스 문의가 등록되었습니다"), | ||
| MODIFY_SUCCESS("비지니스 문의가 수정되었습니다"), | ||
| DELETE_SUCCESS("비지니스 문의가 삭제되었습니다"); | ||
|
|
||
| private final String description; | ||
|
|
||
| BusinessResultMessage(String description) { | ||
| this.description = description; | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/app/bottlenote/support/business/constant/ContactType.java
This file contains hidden or 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,8 @@ | ||
| package app.bottlenote.support.business.constant; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum ContactType { | ||
| EMAIL, PHONE, ETC; | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/java/app/bottlenote/support/business/controller/BusinessSupportController.java
This file contains hidden or 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,65 @@ | ||
| package app.bottlenote.support.business.controller; | ||
|
|
||
| import app.bottlenote.global.data.response.CollectionResponse; | ||
| import app.bottlenote.global.data.response.GlobalResponse; | ||
| import app.bottlenote.global.security.SecurityContextUtil; | ||
| import app.bottlenote.support.business.dto.request.BusinessSupportPageableRequest; | ||
| import app.bottlenote.support.business.dto.request.BusinessSupportUpsertRequest; | ||
| import app.bottlenote.support.business.dto.response.BusinessInfoResponse; | ||
| import app.bottlenote.support.business.dto.response.BusinessSupportDetailItem; | ||
| import app.bottlenote.support.business.service.BusinessSupportService; | ||
| import app.bottlenote.user.exception.UserException; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.ModelAttribute; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import static app.bottlenote.user.exception.UserExceptionCode.REQUIRED_USER_ID; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/business-support") | ||
| @RequiredArgsConstructor | ||
| public class BusinessSupportController { | ||
|
|
||
| private final BusinessSupportService service; | ||
|
|
||
| @PostMapping | ||
| public ResponseEntity<?> register(@Valid @RequestBody BusinessSupportUpsertRequest req) { | ||
| Long userId = SecurityContextUtil.getUserIdByContext().orElseThrow(() -> new UserException(REQUIRED_USER_ID)); | ||
| return GlobalResponse.ok(service.register(req, userId)); | ||
| } | ||
|
|
||
| @GetMapping | ||
| public ResponseEntity<?> getAllList(@ModelAttribute BusinessSupportPageableRequest req) { | ||
| Long userId = SecurityContextUtil.getUserIdByContext().orElseThrow(() -> new UserException(REQUIRED_USER_ID)); | ||
| CollectionResponse<BusinessInfoResponse> collection = service.getList(req, userId); | ||
| return GlobalResponse.ok(collection); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public ResponseEntity<?> getDetail(@PathVariable Long id) { | ||
| Long userId = SecurityContextUtil.getUserIdByContext().orElseThrow(() -> new UserException(REQUIRED_USER_ID)); | ||
| BusinessSupportDetailItem item = service.getDetail(id, userId); | ||
| return GlobalResponse.ok(item); | ||
| } | ||
|
|
||
| @PatchMapping("/{id}") | ||
| public ResponseEntity<?> modify(@PathVariable Long id, @Valid @RequestBody BusinessSupportUpsertRequest req) { | ||
| Long userId = SecurityContextUtil.getUserIdByContext().orElseThrow(() -> new UserException(REQUIRED_USER_ID)); | ||
| return GlobalResponse.ok(service.modify(id, req, userId)); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public ResponseEntity<?> delete(@PathVariable Long id) { | ||
| Long userId = SecurityContextUtil.getUserIdByContext().orElseThrow(() -> new UserException(REQUIRED_USER_ID)); | ||
| return GlobalResponse.ok(service.delete(id, userId)); | ||
| } | ||
| } |
86 changes: 86 additions & 0 deletions
86
src/main/java/app/bottlenote/support/business/domain/BusinessSupport.java
This file contains hidden or 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,86 @@ | ||
| package app.bottlenote.support.business.domain; | ||
|
|
||
| import app.bottlenote.common.domain.BaseEntity; | ||
| import app.bottlenote.support.business.constant.ContactType; | ||
| import app.bottlenote.support.constant.StatusType; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.hibernate.annotations.Comment; | ||
|
|
||
| @Getter | ||
| @Entity(name = "business_support") | ||
| @Table(name = "business_supports") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class BusinessSupport extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Comment("문의자") | ||
| @Column(name = "user_id", nullable = false) | ||
| private Long userId; | ||
|
|
||
| @Comment("문의 내용") | ||
| @Column(name = "content", nullable = false) | ||
| private String content; | ||
|
|
||
| @Comment("연락 방식") | ||
| @Column(name = "contact_way") | ||
| @Enumerated(EnumType.STRING) | ||
| private ContactType contactWay; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "status") | ||
| @Comment("문의 타입") | ||
| private StatusType status = StatusType.WAITING; | ||
|
|
||
| @Column(name = "admin_id") | ||
| @Comment("어드민 ID") | ||
| private Long adminId; | ||
|
|
||
| @Column(name = "response_content") | ||
| @Comment("문의 답변 내용") | ||
| private String responseContent; | ||
|
|
||
| @Builder | ||
| private BusinessSupport(Long id, Long userId, String content, ContactType contactWay, Long adminId, String responseContent) { | ||
| this.id = id; | ||
| this.userId = userId; | ||
| this.content = content; | ||
| this.contactWay = contactWay; | ||
| this.adminId = adminId; | ||
| this.responseContent = responseContent; | ||
| } | ||
|
|
||
| public static BusinessSupport create(Long userId, String content, ContactType contactWay) { | ||
| return BusinessSupport.builder() | ||
| .userId(userId) | ||
| .content(content) | ||
| .contactWay(contactWay) | ||
| .build(); | ||
| } | ||
|
|
||
| public void update(String content, ContactType contactWay) { | ||
| this.content = content; | ||
| this.contactWay = contactWay; | ||
| } | ||
|
|
||
| public void delete() { | ||
| this.status = StatusType.DELETED; | ||
| } | ||
|
|
||
| public boolean isMyPost(Long userId) { | ||
| return this.userId.equals(userId); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...main/java/app/bottlenote/support/business/dto/request/BusinessSupportPageableRequest.java
This file contains hidden or 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 app.bottlenote.support.business.dto.request; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| public record BusinessSupportPageableRequest(Long cursor, Long pageSize) { | ||
| @Builder | ||
| public BusinessSupportPageableRequest { | ||
| cursor = cursor != null ? cursor : 0L; | ||
| pageSize = pageSize != null ? pageSize : 10L; | ||
| } | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/main/java/app/bottlenote/support/business/dto/request/BusinessSupportUpsertRequest.java
This file contains hidden or 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 app.bottlenote.support.business.dto.request; | ||
|
|
||
| import app.bottlenote.support.business.constant.ContactType; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record BusinessSupportUpsertRequest( | ||
| @Size(max = 500) | ||
| String content, | ||
|
|
||
| ContactType contactWay | ||
| ) { | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.