-
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.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/main/java/com/example/whopper/interfaces/history/HistoryController.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,41 @@ | ||
package com.example.whopper.interfaces.history; | ||
|
||
import com.example.whopper.application.history.usecase.CreateHistoryUseCase; | ||
import com.example.whopper.application.history.usecase.DeleteHistoryUseCase; | ||
import com.example.whopper.application.history.usecase.ViewHistoryUseCase; | ||
import com.example.whopper.common.annotation.OnlyTeacher; | ||
import com.example.whopper.interfaces.history.dto.HistoryResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/history") | ||
class HistoryController { | ||
private final CreateHistoryUseCase createHistoryUseCase; | ||
private final ViewHistoryUseCase viewHistoryUseCase; | ||
private final DeleteHistoryUseCase deleteHistoryUseCase; | ||
|
||
@OnlyTeacher | ||
@GetMapping | ||
List<HistoryResponse> viewAll() { | ||
return viewHistoryUseCase.viewAll(); | ||
} | ||
|
||
@OnlyTeacher | ||
@PostMapping | ||
void create(@RequestBody CreateHistoryRequest request) { | ||
createHistoryUseCase.create(request.date(), request.content()); | ||
} | ||
|
||
@OnlyTeacher | ||
@PutMapping("/del") | ||
void deleteById(@RequestBody DeleteHistoryRequest request) { | ||
deleteHistoryUseCase.deleteById(request.id()); | ||
} | ||
|
||
record DeleteHistoryRequest(String id) {} | ||
record CreateHistoryRequest(String date, String content) {} | ||
} |