-
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.
Browse files
Browse the repository at this point in the history
* โจ feature/#59 : store history ์ถ๊ฐ API ๊ตฌํ Signed-off-by: EunJiJung <[email protected]> * โจ feature/#59 : store history ์ถ๊ฐ http ๋ฉ์๋ ์ ์ Signed-off-by: EunJiJung <[email protected]> * โป๏ธ refactor/#59 : store history yyyy๋ mm์ ๊ธฐ์ค info list๋ก ๋ณ๊ฒฝ Signed-off-by: EunJiJung <[email protected]> * โป๏ธ refactor/#59 : amount util ํ์ผ ์ ๊ฑฐ, amount ๊ณ์ฐ ์ response dto์์ ์ฒ๋ฆฌ Signed-off-by: EunJiJung <[email protected]> * โป๏ธ refactor/#59 : ticket response dto store_ingo -> info๋ก ์คํ ๋ณ๊ฒฝ Signed-off-by: EunJiJung <[email protected]> --------- Signed-off-by: EunJiJung <[email protected]>
- Loading branch information
Showing
10 changed files
with
174 additions
and
12 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
28 changes: 28 additions & 0 deletions
28
...java/com/daon/onjung/account/application/controller/command/StoreCommandV1Controller.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,28 @@ | ||
package com.daon.onjung.account.application.controller.command; | ||
|
||
import com.daon.onjung.account.application.dto.request.CreateStoreHistoryRequestDto; | ||
import com.daon.onjung.account.application.usecase.CreateStoreHistoryUseCase; | ||
import com.daon.onjung.core.dto.ResponseDto; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class StoreCommandV1Controller { | ||
|
||
private final CreateStoreHistoryUseCase createStoreHistoryUseCase; | ||
|
||
/** | ||
* 3.3 ๊ฐ๊ฒ ํ์คํ ๋ฆฌ ๋ฑ๋กํ๊ธฐ | ||
*/ | ||
@PostMapping(value = "/api/v1/store-histories") | ||
public ResponseDto<Void> createStoreHistory( | ||
@RequestBody @Valid CreateStoreHistoryRequestDto requestDto | ||
) { | ||
createStoreHistoryUseCase.execute(requestDto); | ||
return ResponseDto.ok(null); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...in/java/com/daon/onjung/account/application/dto/request/CreateStoreHistoryRequestDto.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,20 @@ | ||
package com.daon.onjung.account.application.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record CreateStoreHistoryRequestDto( | ||
@JsonProperty("store_id") | ||
Long storeId, | ||
|
||
@JsonProperty("action_date") | ||
LocalDate actionDate, | ||
|
||
@JsonProperty("content") | ||
String content, | ||
|
||
@JsonProperty("amount") | ||
Integer amount | ||
) { | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/daon/onjung/account/application/service/CreateStoreHistoryService.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,40 @@ | ||
package com.daon.onjung.account.application.service; | ||
|
||
import com.daon.onjung.account.application.dto.request.CreateStoreHistoryRequestDto; | ||
import com.daon.onjung.account.application.usecase.CreateStoreHistoryUseCase; | ||
import com.daon.onjung.account.domain.Store; | ||
import com.daon.onjung.account.domain.StoreHistory; | ||
import com.daon.onjung.account.domain.service.StoreHistoryService; | ||
import com.daon.onjung.account.repository.mysql.StoreHistoryRepository; | ||
import com.daon.onjung.account.repository.mysql.StoreRepository; | ||
import com.daon.onjung.core.exception.error.ErrorCode; | ||
import com.daon.onjung.core.exception.type.CommonException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CreateStoreHistoryService implements CreateStoreHistoryUseCase { | ||
|
||
private final StoreRepository storeRepository; | ||
private final StoreHistoryRepository storeHistoryRepository; | ||
|
||
private final StoreHistoryService storeHistoryService; | ||
|
||
@Override | ||
@Transactional | ||
public void execute(CreateStoreHistoryRequestDto requestDto) { | ||
Store store = storeRepository.findById(requestDto.storeId()) | ||
.orElseThrow(() -> new CommonException(ErrorCode.NOT_FOUND_RESOURCE)); | ||
|
||
StoreHistory storeHistory = storeHistoryService.createStoreHistory( | ||
requestDto.actionDate(), | ||
requestDto.content(), | ||
requestDto.amount(), | ||
store | ||
); | ||
|
||
storeHistoryRepository.save(storeHistory); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/daon/onjung/account/application/usecase/CreateStoreHistoryUseCase.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.daon.onjung.account.application.usecase; | ||
|
||
import com.daon.onjung.account.application.dto.request.CreateStoreHistoryRequestDto; | ||
import com.daon.onjung.core.annotation.bean.UseCase; | ||
|
||
import java.time.LocalDate; | ||
|
||
@UseCase | ||
public interface CreateStoreHistoryUseCase { | ||
void execute(CreateStoreHistoryRequestDto requestDto); | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/daon/onjung/account/domain/service/StoreHistoryService.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,24 @@ | ||
package com.daon.onjung.account.domain.service; | ||
|
||
import com.daon.onjung.account.domain.Store; | ||
import com.daon.onjung.account.domain.StoreHistory; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Service | ||
public class StoreHistoryService { | ||
public StoreHistory createStoreHistory( | ||
LocalDate actionDate, | ||
String content, | ||
Integer amount, | ||
Store store | ||
) { | ||
return StoreHistory.builder() | ||
.actionDate(actionDate) | ||
.content(content) | ||
.amount(amount) | ||
.store(store) | ||
.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