Skip to content

Commit

Permalink
add: controller 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Aug 25, 2024
1 parent f681039 commit 00d9f99
Showing 1 changed file with 41 additions and 0 deletions.
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) {}
}

0 comments on commit 00d9f99

Please sign in to comment.