Multi-Module Project With Spring Boot
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
package com.javadevjournal;
|
||||||
|
|
||||||
|
//@SpringBootApplication
|
||||||
|
public class JDJCore {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.javadevjournal.data.customer;
|
||||||
|
|
||||||
|
public class Customer {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String id;
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public Customer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Customer(String firstName, String lastName, String id, String email) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.id = id;
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.javadevjournal.service.customer;
|
||||||
|
|
||||||
|
import com.javadevjournal.data.customer.Customer;
|
||||||
|
|
||||||
|
public interface CustomerService {
|
||||||
|
|
||||||
|
Customer getCustomerById(final String id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.javadevjournal.service.customer;
|
||||||
|
|
||||||
|
import com.javadevjournal.data.customer.Customer;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service("customerService")
|
||||||
|
public class DefaultCustomerService implements CustomerService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Customer getCustomerById(String id) {
|
||||||
|
return new Customer("Test","Customer",id,"contact-us@javadevjournal.com");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.javadevjournal.controller;
|
||||||
|
|
||||||
|
import com.javadevjournal.data.customer.Customer;
|
||||||
|
import com.javadevjournal.service.customer.CustomerService;
|
||||||
|
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 javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/customers")
|
||||||
|
public class CustomerController {
|
||||||
|
|
||||||
|
@Resource(name = "customerService")
|
||||||
|
CustomerService customerService;
|
||||||
|
|
||||||
|
@GetMapping("/customer/{id}")
|
||||||
|
public Customer getCustomer(@PathVariable String id){
|
||||||
|
return customerService.getCustomerById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user