-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat : 정산 내역 조회 및 계좌 등록, 조회 추가 #494
- Loading branch information
1 parent
2c5fca3
commit d139302
Showing
36 changed files
with
1,464 additions
and
41 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,42 @@ | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
:toc: left | ||
:toclevels: 2 | ||
:sectlinks: | ||
:docinfo: shared-head | ||
|
||
[[Account]] | ||
= 계좌 정보 API | ||
|
||
== 계좌 조회 | ||
=== HTTP Request | ||
include::{snippets}/adjustment/getaccount/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/getaccount/request-headers.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/getaccount/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/getaccount/response-fields.adoc[] | ||
|
||
== 계좌 조회(계좌 미등록 시) | ||
=== HTTP Request | ||
include::{snippets}/adjustment/getaccountnull/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/getaccountnull/request-headers.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/getaccountnull/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/getaccountnull/response-fields.adoc[] | ||
|
||
== 계좌 생성/수정 (put 요청입니다.) | ||
=== HTTP Request | ||
include::{snippets}/adjustment/calculateamount/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/calculateamount/request-headers.adoc[] | ||
==== Request Query Parameters | ||
include::{snippets}/adjustment/calculateamount/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/calculateamount/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/calculateamount/response-fields.adoc[] |
51 changes: 51 additions & 0 deletions
51
Server/src/docs/asciidoc/snippets/adjustment/adjustment.adoc
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 @@ | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
:toc: left | ||
:toclevels: 2 | ||
:sectlinks: | ||
:docinfo: shared-head | ||
|
||
[[Adjustment]] | ||
= 정산 내역 API | ||
|
||
IMPORTANT: month 를 null 로 주면 연도별 조회, year 을 null 로 주면 전체 조회 | ||
|
||
[[Adjustment-list]] | ||
== 비디오별 정산 내역 | ||
=== HTTP Request | ||
include::{snippets}/adjustment/adjustment/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/adjustment/request-headers.adoc[] | ||
==== Request Query Parameters | ||
include::{snippets}/adjustment/adjustment/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/adjustment/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/adjustment/response-fields.adoc[] | ||
|
||
[[Adjustment-total]] | ||
== 특정 월의 정산 총 금액 및 월별 정산 내역 | ||
=== HTTP Request | ||
include::{snippets}/adjustment/calculateamount/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/calculateamount/request-headers.adoc[] | ||
==== Request Query Parameters | ||
include::{snippets}/adjustment/calculateamount/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/calculateamount/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/calculateamount/response-fields.adoc[] | ||
|
||
[[Adjustment-totalyear]] | ||
== 특정 연도의 정산 총 금액 및 월별 정산 내역 | ||
=== HTTP Request | ||
include::{snippets}/adjustment/calculateamountyear/http-request.adoc[] | ||
==== Request Headers | ||
include::{snippets}/adjustment/calculateamountyear/request-headers.adoc[] | ||
==== Request Query Parameters | ||
include::{snippets}/adjustment/calculateamountyear/request-parameters.adoc[] | ||
=== HTTP Response | ||
include::{snippets}/adjustment/calculateamountyear/http-response.adoc[] | ||
==== Response Fields | ||
include::{snippets}/adjustment/calculateamountyear/response-fields.adoc[] |
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,36 @@ | ||
<script> | ||
function ready(callbackFunc) { | ||
if (document.readyState !== 'loading') { | ||
// Document is already ready, call the callback directly | ||
callbackFunc(); | ||
} else if (document.addEventListener) { | ||
// All modern browsers to register DOMContentLoaded | ||
document.addEventListener('DOMContentLoaded', callbackFunc); | ||
} else { | ||
// Old IE browsers | ||
document.attachEvent('onreadystatechange', function () { | ||
if (document.readyState === 'complete') { | ||
callbackFunc(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function openPopup(event) { | ||
|
||
const target = event.target; | ||
if (target.className !== "popup") { | ||
return; | ||
} | ||
|
||
event.preventDefault(); | ||
const screenX = event.screenX; | ||
const screenY = event.screenY; | ||
window.open(target.href, target.text, `left=${screenX}, top=${screenY}, width=500, height=600, status=no, menubar=no, toolbar=no, resizable=no`); | ||
} | ||
|
||
ready(function () { | ||
const el = document.getElementById("content"); | ||
el.addEventListener("click", event => openPopup(event), false); | ||
}); | ||
</script> |
6 changes: 6 additions & 0 deletions
6
Server/src/docs/asciidoc/snippets/common/adjustmentstatus.adoc
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,6 @@ | ||
:doctype: book | ||
:icons: font | ||
|
||
[[VideoStatus]] | ||
|
||
include::{snippets}/common/enums/custom-response-fields-AdjustmentStatus.adoc[] |
This file was deleted.
Oops, something went wrong.
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
13 changes: 13 additions & 0 deletions
13
Server/src/main/java/com/server/domain/account/repository/AccountRepository.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,13 @@ | ||
package com.server.domain.account.repository; | ||
|
||
import com.server.domain.account.domain.Account; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AccountRepository extends JpaRepository<Account, Long> { | ||
|
||
@Query("select a from Account a where a.member.memberId = :memberId") | ||
Optional<Account> findByMemberId(Long memberId); | ||
} |
103 changes: 103 additions & 0 deletions
103
Server/src/main/java/com/server/domain/adjustment/controller/AdjustmentController.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,103 @@ | ||
package com.server.domain.adjustment.controller; | ||
|
||
import com.server.domain.adjustment.controller.dto.request.AccountUpdateApiRequest; | ||
import com.server.domain.adjustment.service.AdjustmentService; | ||
import com.server.domain.adjustment.service.dto.response.AccountResponse; | ||
import com.server.domain.adjustment.service.dto.response.ToTalAdjustmentResponse; | ||
import com.server.domain.order.controller.dto.request.AdjustmentSort; | ||
import com.server.domain.adjustment.service.dto.response.AdjustmentResponse; | ||
import com.server.global.annotation.LoginId; | ||
import com.server.global.exception.businessexception.orderexception.AdjustmentDateException; | ||
import com.server.global.reponse.ApiPageResponse; | ||
import com.server.global.reponse.ApiSingleResponse; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.Max; | ||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.Positive; | ||
import java.net.URI; | ||
|
||
@RestController | ||
@RequestMapping("/adjustments") | ||
@Validated | ||
public class AdjustmentController { | ||
|
||
private final AdjustmentService adjustmentService; | ||
|
||
public AdjustmentController(AdjustmentService adjustmentService) { | ||
this.adjustmentService = adjustmentService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<ApiPageResponse<AdjustmentResponse>> adjustment( | ||
@RequestParam(defaultValue = "1") @Positive(message = "{validation.positive}") int page, | ||
@RequestParam(defaultValue = "10") @Positive(message = "{validation.positive}") int size, | ||
@RequestParam(required = false) @Min(value = 1) @Max(value = 12) Integer month, | ||
@RequestParam(required = false) @Min(value = 2020) Integer year, | ||
@RequestParam(defaultValue = "video-created-date") AdjustmentSort sort, | ||
@LoginId Long loginMemberId) { | ||
|
||
checkValidDate(month, year); | ||
|
||
Page<AdjustmentResponse> response = adjustmentService.adjustment(loginMemberId, page - 1, size, month, year, sort.getSort()); | ||
|
||
return ResponseEntity.ok(ApiPageResponse.ok(response, getAdjustmentMessage(month, year))); | ||
} | ||
|
||
@GetMapping("/total-adjustment") | ||
public ResponseEntity<ApiSingleResponse<ToTalAdjustmentResponse>> calculateAmount( | ||
@RequestParam(required = false) @Min(value = 1) @Max(value = 12) Integer month, | ||
@RequestParam(required = false) @Min(value = 2020) Integer year, | ||
@LoginId Long loginMemberId) { | ||
|
||
checkValidDate(month, year); | ||
|
||
ToTalAdjustmentResponse total = adjustmentService.totalAdjustment(loginMemberId, month, year); | ||
|
||
return ResponseEntity.ok(ApiSingleResponse.ok(total, getAdjustmentMessage(month, year))); | ||
} | ||
|
||
@GetMapping("/account") | ||
public ResponseEntity<ApiSingleResponse<AccountResponse>> getAccount( | ||
@LoginId Long loginMemberId) { | ||
|
||
AccountResponse account = adjustmentService.getAccount(loginMemberId); | ||
|
||
String message = account.getName().equals("계좌 정보가 없습니다.") ? "계좌 정보가 없습니다." : "계좌 정보 조회 성공"; | ||
|
||
return ResponseEntity.ok(ApiSingleResponse.ok(account, message)); | ||
} | ||
|
||
@PutMapping("/account") | ||
public ResponseEntity<ApiSingleResponse<Void>> updateAccount( | ||
@RequestBody @Valid AccountUpdateApiRequest request, | ||
@LoginId Long loginMemberId) { | ||
|
||
adjustmentService.updateAccount(loginMemberId, request.toServiceRequest()); | ||
|
||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
private void checkValidDate(Integer month, Integer year) { | ||
if(month != null && year == null) { | ||
throw new AdjustmentDateException(); | ||
} | ||
} | ||
|
||
private String getAdjustmentMessage(Integer month, Integer year) { | ||
if(month == null && year == null) { | ||
return "전체 정산 내역"; | ||
} | ||
|
||
if(month != null && year != null) { | ||
return year + "년 " + month + "월 정산 내역"; | ||
} | ||
|
||
return year + "년 정산 내역"; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ain/java/com/server/domain/adjustment/controller/dto/request/AccountUpdateApiRequest.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,32 @@ | ||
package com.server.domain.adjustment.controller.dto.request; | ||
|
||
import com.server.domain.adjustment.service.dto.request.AccountUpdateServiceRequest; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
public class AccountUpdateApiRequest { | ||
|
||
@NotBlank(message = "{validation.account.name.notBlank}") | ||
private String name; | ||
@NotBlank(message = "{validation.account.account.notBlank}") | ||
private String account; | ||
@NotBlank(message = "{validation.account.bank.notBlank}") | ||
private String bank; | ||
|
||
public AccountUpdateServiceRequest toServiceRequest() { | ||
return AccountUpdateServiceRequest.builder() | ||
.name(name) | ||
.account(account) | ||
.bank(bank) | ||
.build(); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.