-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathPaymentController.java
More file actions
40 lines (33 loc) · 1.3 KB
/
PaymentController.java
File metadata and controls
40 lines (33 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.bravo.user.controller;
import com.bravo.user.annotation.SwaggerController;
import com.bravo.user.exception.BadRequestException;
import com.bravo.user.model.dto.PaymentDto;
import com.bravo.user.service.PaymentService;
import com.bravo.user.validator.UserValidator;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@RequestMapping(value = "/payment")
@SwaggerController
public class PaymentController {
private final PaymentService paymentService;
private final UserValidator userValidator;
public PaymentController(PaymentService paymentService, UserValidator userValidator) {
this.paymentService = paymentService;
this.userValidator = userValidator;
}
@GetMapping(value = "/retrieve")
@ResponseBody
public List<PaymentDto> retrieve(
final @RequestParam(required = false) String userId
) {
if (userId != null) {
userValidator.validateId(userId);
return paymentService.retrieveByUserId(userId);
} else {
throw new BadRequestException("'user id' is required!");
}
}
}