forked from vimal-java-dev/vimaltech-contact-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContactController.java
More file actions
35 lines (27 loc) · 1.05 KB
/
ContactController.java
File metadata and controls
35 lines (27 loc) · 1.05 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
package com.vimaltech.contactapi.controller;
import com.vimaltech.contactapi.dto.ApiResponse;
import com.vimaltech.contactapi.dto.ContactRequest;
import com.vimaltech.contactapi.service.ContactService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/api/v1/contact")
@RequiredArgsConstructor
public class ContactController {
private final ContactService contactService;
@PostMapping
public ResponseEntity<ApiResponse> submitContact(
@Valid @RequestBody ContactRequest request) {
contactService.processContact(request);
ApiResponse response = new ApiResponse(
true,
"Message received successfully.",
LocalDateTime.now()
);
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}
}