Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package guru.springframework.msscbrewery.services;

import guru.springframework.msscbrewery.web.model.CustomerDto;
import org.springframework.http.ResponseEntity;

import java.util.UUID;

public interface CustomerService {

CustomerDto getCustomer(UUID customerId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package guru.springframework.msscbrewery.services;

import guru.springframework.msscbrewery.web.model.CustomerDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class CustomerServiceImpl implements CustomerService {

@Override
public CustomerDto getCustomer(UUID customerId) {
return CustomerDto.builder()
.id(customerId)
.name("Moustafa")
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package guru.springframework.msscbrewery.web.controller;

import guru.springframework.msscbrewery.services.CustomerService;
import guru.springframework.msscbrewery.web.model.CustomerDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RequestMapping("/api/v1/customer")
@RestController
public class CustomerController {

private CustomerService customerService;

public CustomerController(CustomerService customerService) {
this.customerService = customerService;
}

@GetMapping({"{customerId}"})
public ResponseEntity<CustomerDto> getCustomer(@PathVariable("customerId") UUID customerId) {
return new ResponseEntity<>(customerService.getCustomer(customerId), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package guru.springframework.msscbrewery.web.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CustomerDto {

private UUID id;
private String name;
}
1 change: 1 addition & 0 deletions target/classes/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@