Skip to content

Commit 63c7378

Browse files
committed
feat : rest api 바우처 전체조회
1 parent 2b69413 commit 63c7378

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.prgrms.kdtspringdemo.voucher.controller;
2+
3+
import org.prgrms.kdtspringdemo.voucher.domain.Voucher;
4+
import org.prgrms.kdtspringdemo.voucher.domain.dto.VoucherViewDto;
5+
import org.prgrms.kdtspringdemo.voucher.service.VoucherService;
6+
import org.springframework.http.HttpStatus;
7+
import org.springframework.http.ResponseEntity;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RestController;
11+
12+
import java.util.List;
13+
14+
@RestController
15+
@RequestMapping("/api/v1/voucher")
16+
public class VoucherRestController {
17+
private final VoucherService voucherService;
18+
19+
public VoucherRestController(VoucherService voucherService) {
20+
this.voucherService = voucherService;
21+
}
22+
23+
@GetMapping("/vouchers")
24+
ResponseEntity<List<VoucherViewDto>> showAllVouchers() {
25+
final List<VoucherViewDto> vouchers = voucherService.findAll().stream()
26+
.map(VoucherViewDto::new).toList();
27+
return new ResponseEntity<>(vouchers, HttpStatus.OK);
28+
29+
}
30+
31+
}

0 commit comments

Comments
 (0)