customerNames = new HashSet<>();
+// for (int i = 0; i < 100; i++)
+// {
+// customerNames.add(dataFaker.name()
+// .fullName());
+// }
+//
+// for (String theName : customerNames)
+// {
+// String custcity = dataFaker.address()
+// .city();
+// String tempWorkingarea = dataFaker.address()
+// .cityName();
+// String tempCustcountry = dataFaker.address()
+// .country();
+// String tempGrade = dataFaker.country()
+// .countryCode2();
+// double tempOpeningamt = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// double tempReceiveamt = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// double tempPaymentamt = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// double tempOutstandingamt = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// String tempPhone = dataFaker.phoneNumber()
+// .phoneNumber();
+//
+// Customer fakeCustomer = new Customer(theName,
+// custcity,
+// tempWorkingarea,
+// tempCustcountry,
+// tempGrade,
+// tempOpeningamt,
+// tempReceiveamt,
+// tempPaymentamt,
+// tempOutstandingamt,
+// tempPhone,
+// a10);
+//
+// int randomNumber = random.nextInt(10); // random number 0 through 9
+// for (int i = 0; i < randomNumber; i++)
+// {
+// double tempGetOrdamount = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// double tempGetAdvanceamount = dataFaker.number()
+// .randomDouble(2,
+// 0,
+// 10000);
+// String tempGetOrderdescription = dataFaker.lorem()
+// .characters();
+//
+// Order newOrder = new Order(tempGetOrdamount,
+// tempGetAdvanceamount,
+// fakeCustomer,
+// tempGetOrderdescription);
+//
+// newOrder.getPayments().add(pay1);
+// fakeCustomer.getOrders()
+// .add(newOrder);
+// }
+//
+// // this actually saves the faker data.
+// custrepos.save(fakeCustomer);
+// }
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/config/H2ServerConfiguration.java b/orders/src/main/java/com/lambdaschool/orders/orders/config/H2ServerConfiguration.java
new file mode 100644
index 0000000..e3dc643
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/config/H2ServerConfiguration.java
@@ -0,0 +1,73 @@
+package com.lambdaschool.orders.orders.config;
+
+
+import org.h2.tools.Server;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.sql.SQLException;
+
+/**
+ * Configures H2 access through the JetBrains IntelliJ IDEA IDE.
+ *
+ * Adapted from https://techdev.io/en/developer-blog/querying-the-embedded-h2-database-of-a-spring-boot-application
+ * necessary for using the database tool built into intellij
+ */
+@Configuration
+public class H2ServerConfiguration
+{
+
+ /**
+ * TCP port for remote connections, default 9092.
+ */
+ @Value("${h2.tcp.port:9092}")
+ private String h2TcpPort;
+
+ /**
+ * Web port, default 8082.
+ */
+ @Value("${h2.web.port:8082}")
+ private String h2WebPort;
+
+ /**
+ * TCP connection to connect with SQL clients to the embedded h2 database.
+ *
+ * Connect to "jdbc:h2:tcp://localhost:9092/mem:testdb", username "sa", password empty.
+ *
+ * @return The created TcpServer needed to access H2.
+ * @throws SQLException If the server cannot be created.
+ */
+ @Bean
+ @ConditionalOnExpression("${h2.tcp.enabled:true}")
+ public Server h2TcpServer() throws
+ SQLException
+ {
+ return Server.createTcpServer("-tcp",
+ "-tcpAllowOthers",
+ "-tcpPort",
+ h2TcpPort)
+ .start();
+ }
+
+ /**
+ * Web console for the embedded h2 database.
+ *
+ * Go to http://localhost:8082 and connect to the database "jdbc:h2:mem:testdb", username "sa", password empty.
+ *
+ * @return The created web server needed to access H2.
+ * @throws SQLException If the server cannot be created.
+ */
+ @Bean
+ @ConditionalOnExpression("${h2.web.enabled:true}")
+ public Server h2WebServer() throws
+ SQLException
+ {
+ return Server.createWebServer("-web",
+ "-webAllowOthers",
+ "-webPort",
+ h2WebPort)
+ .start();
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/controllers/AgentController.java b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/AgentController.java
new file mode 100644
index 0000000..915f0bf
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/AgentController.java
@@ -0,0 +1,26 @@
+package com.lambdaschool.orders.orders.controllers;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import com.lambdaschool.orders.orders.services.AgentsService;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+@RestController
+@RequestMapping("/agents")
+public class AgentController {
+ @Autowired
+ AgentsService agentsService;
+
+ // http://localhost:2019/agents/agent/9
+ @GetMapping(value = "agent/{agentid}", produces = {"application/json"})
+ public ResponseEntity> findAgentId(@PathVariable long agentid)
+ {
+ Agent rtnAgent = agentsService.findAgentById(agentid);
+ return new ResponseEntity<>(rtnAgent, HttpStatus.OK);
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/controllers/CustomersController.java b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/CustomersController.java
new file mode 100644
index 0000000..ed2c985
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/CustomersController.java
@@ -0,0 +1,41 @@
+package com.lambdaschool.orders.orders.controllers;
+
+import com.lambdaschool.orders.orders.models.Customer;
+import com.lambdaschool.orders.orders.services.CustomersService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/customers")
+public class CustomersController {
+
+ @Autowired
+ private CustomersService customerService;
+// http://localhost:2019/customers/orders
+ @GetMapping(value = "/orders", produces = {"application/json"})
+ public ResponseEntity> listAllCustomers()
+ {
+ List rtnList = customerService.findAllCustomerOrders();
+ return new ResponseEntity<>(rtnList, HttpStatus.OK);
+ }
+
+ // /customers/customer/{id}
+ @GetMapping(value = "/customer/{custid}", produces = {"application/json"})
+ public ResponseEntity> findCustomerId(@PathVariable long custid)
+ {
+ Customer rtnCust = customerService.findCustomersById(custid);
+ return new ResponseEntity<>(rtnCust, HttpStatus.OK);
+ }
+
+ // /customers/namelike/{likename}
+ @GetMapping(value = "/namelike/{likename}", produces = {"application/json"})
+ public ResponseEntity> findByLikeName(@PathVariable String likename)
+ {
+ List rtnList = customerService.findCustomerLikeName(likename);
+ return new ResponseEntity<>(rtnList, HttpStatus.OK);
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/controllers/OrdersController.java b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/OrdersController.java
new file mode 100644
index 0000000..38c97b8
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/controllers/OrdersController.java
@@ -0,0 +1,26 @@
+package com.lambdaschool.orders.orders.controllers;
+
+import com.lambdaschool.orders.orders.models.Order;
+import com.lambdaschool.orders.orders.services.OrdersService;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+@RestController
+@RequestMapping("/orders")
+public class OrdersController {
+ @Autowired
+ OrdersService ordersService;
+
+// http://localhost:2019/orders/order/7
+@GetMapping(value = "/order/{ordernum}", produces = {"application/json"})
+public ResponseEntity> getOrderByNumber(@PathVariable long ordernum)
+{
+ Order rtnOrder = ordersService.findOrdersById(ordernum);
+ return new ResponseEntity<>(rtnOrder, HttpStatus.OK);
+}
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/models/Agent.java b/orders/src/main/java/com/lambdaschool/orders/orders/models/Agent.java
new file mode 100644
index 0000000..f23f62e
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/models/Agent.java
@@ -0,0 +1,98 @@
+package com.lambdaschool.orders.orders.models;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "agents")
+public class Agent {
+ // AGENTCODE primary key, not null Long
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(nullable = false)
+ private long agentcode;
+ // AGENTNAME string
+ private String agentname;
+ // WORKINGAREA string
+ private String workingarea;
+ // COMMISSION double
+ private double commission;
+ // PHONE string
+ private String phone;
+ // COUNTRY string
+ private String country;
+
+ @OneToMany(mappedBy = "agent", cascade = CascadeType.ALL, orphanRemoval = true)
+ @JsonIgnoreProperties(value = "agent", allowSetters = true)
+ private List customers = new ArrayList<>();
+
+ public Agent() {
+ }
+
+ public Agent(String agentname, String workingarea, double commission, String phone, String country) {
+ this.agentname = agentname;
+ this.workingarea = workingarea;
+ this.commission = commission;
+ this.phone = phone;
+ this.country = country;
+ }
+
+ public List getCustomers() {
+ return customers;
+ }
+
+ public void setCustomers(List customers) {
+ this.customers = customers;
+ }
+
+ public long getAgentcode() {
+ return agentcode;
+ }
+
+ public void setAgentcode(long agentcode) {
+ this.agentcode = agentcode;
+ }
+
+ public String getAgentname() {
+ return agentname;
+ }
+
+ public void setAgentname(String agentname) {
+ this.agentname = agentname;
+ }
+
+ public String getWorkingarea() {
+ return workingarea;
+ }
+
+ public void setWorkingarea(String workingarea) {
+ this.workingarea = workingarea;
+ }
+
+ public double getCommission() {
+ return commission;
+ }
+
+ public void setCommission(double commission) {
+ this.commission = commission;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/models/Customer.java b/orders/src/main/java/com/lambdaschool/orders/orders/models/Customer.java
new file mode 100644
index 0000000..fdbd493
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/models/Customer.java
@@ -0,0 +1,176 @@
+package com.lambdaschool.orders.orders.models;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "customers")
+public class Customer {
+
+ // CUSTCODE primary key, not null Long
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long custcode;
+ // CUSTNAME String, not null
+ @Column(nullable = false)
+ private String custname;
+ // CUSTCITY String
+ private String custcity;
+ // WORKINGAREA String
+ private String workingarea;
+ // CUSTCOUNTRY String
+ private String custcountry;
+ // GRADE String
+ private String grade;
+ // OPENINGAMT double
+ private double openingamt;
+ // RECEIVEAMT double
+ private double receiveamt;
+ // PAYMENTAMT double
+ private double paymentamt;
+ // OUTSTANDINGAMT double
+ private double outstandingamt;
+ // PHONE String
+ private String phone;
+ // AGENTCODE Long foreign key (one agent to many customers) not null
+ @ManyToOne
+ @JoinColumn(name = "agentcode", nullable = false)
+
+ @JsonIgnoreProperties(value = "customers", allowSetters = true)
+ private Agent agent;
+
+ @OneToMany(mappedBy = "customer",
+ cascade = CascadeType.ALL,
+ orphanRemoval = true)
+ @JsonIgnoreProperties(value = "customer",
+ allowSetters = true)
+ private List orders = new ArrayList<>();
+
+ //default constructor
+ public Customer() {
+ }
+
+ public Customer(String custname, String custcity, String workingarea, String custcountry, String grade, double openingamt, double receiveamt, double paymentamt, double outstandingamt, String phone, Agent agent) {
+ this.custname = custname;
+ this.custcity = custcity;
+ this.workingarea = workingarea;
+ this.custcountry = custcountry;
+ this.grade = grade;
+ this.openingamt = openingamt;
+ this.receiveamt = receiveamt;
+ this.paymentamt = paymentamt;
+ this.outstandingamt = outstandingamt;
+ this.phone = phone;
+ this.agent = agent;
+ }
+
+ public List getOrders() {
+ return orders;
+ }
+
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Agent getAgent() {
+ return agent;
+ }
+
+ public void setAgent(Agent agent) {
+ this.agent = agent;
+ }
+
+ public long getCustcode() {
+ return custcode;
+ }
+
+ public void setCustcode(long custcode) {
+ this.custcode = custcode;
+ }
+
+ public String getCustname() {
+ return custname;
+ }
+
+ public void setCustname(String custname) {
+ this.custname = custname;
+ }
+
+ public String getCustcity() {
+ return custcity;
+ }
+
+ public void setCustcity(String custcity) {
+ this.custcity = custcity;
+ }
+
+ public String getWorkingarea() {
+ return workingarea;
+ }
+
+ public void setWorkingarea(String workingarea) {
+ this.workingarea = workingarea;
+ }
+
+ public String getCustcountry() {
+ return custcountry;
+ }
+
+ public void setCustcountry(String custcountry) {
+ this.custcountry = custcountry;
+ }
+
+ public String getGrade() {
+ return grade;
+ }
+
+ public void setGrade(String grade) {
+ this.grade = grade;
+ }
+
+ public double getOpeningamt() {
+ return openingamt;
+ }
+
+ public void setOpeningamt(double openingamt) {
+ this.openingamt = openingamt;
+ }
+
+ public double getReceiveamt() {
+ return receiveamt;
+ }
+
+ public void setReceiveamt(double receiveamt) {
+ this.receiveamt = receiveamt;
+ }
+
+ public double getPaymentamt() {
+ return paymentamt;
+ }
+
+ public void setPaymentamt(double paymentamt) {
+ this.paymentamt = paymentamt;
+ }
+
+ public double getOutstandingamt() {
+ return outstandingamt;
+ }
+
+ public void setOutstandingamt(double outstandingamt) {
+ this.outstandingamt = outstandingamt;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/models/Order.java b/orders/src/main/java/com/lambdaschool/orders/orders/models/Order.java
new file mode 100644
index 0000000..559dad7
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/models/Order.java
@@ -0,0 +1,104 @@
+package com.lambdaschool.orders.orders.models;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "orders")
+public class Order {
+// ORDNUM primary key, not null Long
+// ORDAMOUNT double
+// ADVANCEAMOUNT double
+// CUSTCODE Ler tong foreign key (one customer to many orders) not null
+// ORDERDESCRIPTION String
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(nullable = false)
+ private long ordnum;
+
+
+ private double ordamount;
+ private double advanceamount;
+
+ // Many orders to one customers
+ @ManyToOne
+ @JoinColumn( name = "custcode", nullable = false)
+ @JsonIgnoreProperties(value = "orders", allowSetters = true)
+ private Customer customer;
+
+ @ManyToMany()
+ @JoinTable(name = "orderspayments", joinColumns = @JoinColumn(name = "ordnum"), inverseJoinColumns = @JoinColumn(name = "paymentid"))
+ @JsonIgnoreProperties(value = "orders", allowSetters = true)
+ private Set payments = new HashSet<>();
+
+
+ private String orderdescription;
+
+ public Order() {
+ //default
+ }
+
+ public Order(double ordamount, double advanceamount,Customer customer, String orderdescription) {
+
+ this.ordamount = ordamount;
+ this.advanceamount = advanceamount;
+ this.orderdescription = orderdescription;
+ this.customer = customer;
+
+ }
+
+ public Set getPayments() {
+ return payments;
+ }
+
+ public void setPayments(Set payments) {
+ this.payments = payments;
+ }
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ public String getOrderdescription() {
+ return orderdescription;
+ }
+
+ public void setOrderdescription(String oderdescription) {
+ this.orderdescription = oderdescription;
+ }
+
+ public long getOrdnum() {
+ return ordnum;
+ }
+
+ public void setOrdnum(long ordnum) {
+ this.ordnum = ordnum;
+ }
+
+ public double getOrdamount() {
+ return ordamount;
+ }
+
+ public void setOrdamount(double ordamount) {
+ this.ordamount = ordamount;
+ }
+
+ public double getAdvanceamount() {
+ return advanceamount;
+ }
+
+ public void setAdvanceamount(double advanceamount) {
+ this.advanceamount = advanceamount;
+ }
+
+}
+
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/models/Payment.java b/orders/src/main/java/com/lambdaschool/orders/orders/models/Payment.java
new file mode 100644
index 0000000..88b56aa
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/models/Payment.java
@@ -0,0 +1,57 @@
+package com.lambdaschool.orders.orders.models;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "payments")
+public class Payment {
+// PAYMENTID primary key, not null long
+// TYPE String not null
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long paymentid;
+
+ @Column(nullable = false, unique = true)
+ private String type;
+
+ @ManyToMany(mappedBy = "payments")
+ @JsonIgnoreProperties("payments")
+ private Set orders = new HashSet<>();
+
+ public Payment() {
+ }
+
+ public Payment(String type) {
+ this.type = type;
+ }
+
+ public Set getOrders() {
+ return orders;
+ }
+
+ public void setOrders(Set orders) {
+ this.orders = orders;
+ }
+
+ public long getPaymentid() {
+ return paymentid;
+ }
+
+ public void setPaymentid(long paymentid) {
+ this.paymentid = paymentid;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/repositories/AgentsRepository.java b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/AgentsRepository.java
new file mode 100644
index 0000000..c39091e
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/AgentsRepository.java
@@ -0,0 +1,8 @@
+package com.lambdaschool.orders.orders.repositories;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import org.springframework.data.repository.CrudRepository;
+
+public interface AgentsRepository extends CrudRepository {
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/repositories/CustomersRepository.java b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/CustomersRepository.java
new file mode 100644
index 0000000..cce6aad
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/CustomersRepository.java
@@ -0,0 +1,11 @@
+package com.lambdaschool.orders.orders.repositories;
+
+import com.lambdaschool.orders.orders.models.Customer;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+
+public interface CustomersRepository extends CrudRepository {
+
+ List findByCustnameContainingIgnoringCase(String name);
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/repositories/OrdersRepository.java b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/OrdersRepository.java
new file mode 100644
index 0000000..10de891
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/OrdersRepository.java
@@ -0,0 +1,11 @@
+package com.lambdaschool.orders.orders.repositories;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import com.lambdaschool.orders.orders.models.Order;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+
+public interface OrdersRepository extends CrudRepository{
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/repositories/PaymentRepository.java b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/PaymentRepository.java
new file mode 100644
index 0000000..1c48343
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/repositories/PaymentRepository.java
@@ -0,0 +1,8 @@
+package com.lambdaschool.orders.orders.repositories;
+
+import com.lambdaschool.orders.orders.models.Payment;
+import org.springframework.data.repository.CrudRepository;
+
+public interface PaymentRepository extends CrudRepository {
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentServiceImpl.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentServiceImpl.java
new file mode 100644
index 0000000..27440e2
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentServiceImpl.java
@@ -0,0 +1,29 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import com.lambdaschool.orders.orders.repositories.AgentsRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityNotFoundException;
+
+@Transactional
+@Service(value = "agentsService")
+public class AgentServiceImpl implements AgentsService{
+ @Autowired
+ private AgentsRepository agentrepos;
+
+ @Transactional
+ @Override
+ public Agent save(Agent agent) {
+ return agentrepos.save(agent);
+ }
+
+ @Override
+ public Agent findAgentById(long id) {
+ Agent rtnAgent = agentrepos.findById(id+4)
+ .orElseThrow(()-> new EntityNotFoundException("Agent "+id+" Not Found"));
+ return rtnAgent;
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentsService.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentsService.java
new file mode 100644
index 0000000..4e09baa
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/AgentsService.java
@@ -0,0 +1,11 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Agent;
+
+import java.util.List;
+
+public interface AgentsService {
+ Agent save(Agent agent);
+
+ Agent findAgentById(long id);
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersService.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersService.java
new file mode 100644
index 0000000..15d5194
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersService.java
@@ -0,0 +1,23 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import com.lambdaschool.orders.orders.models.Customer;
+
+import java.util.List;
+
+public interface CustomersService {
+
+
+ // /customers/orders
+ List findAllCustomerOrders();
+
+// Customer save(Customer customer);
+
+ // /customers/customer/{id}
+ Customer findCustomersById(long id);
+
+ // /customers/namelike/{likename}
+ List findCustomerLikeName(String likeName);
+
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersServiceImpl.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersServiceImpl.java
new file mode 100644
index 0000000..6ff3d10
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/CustomersServiceImpl.java
@@ -0,0 +1,44 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Customer;
+import com.lambdaschool.orders.orders.repositories.CustomersRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Transactional
+@Service(value = "customersService")
+public class CustomersServiceImpl implements CustomersService {
+ @Autowired
+ private CustomersRepository custrepos;
+
+// @Transactional
+// @Override
+// public Customer save(Customer customer) {
+// return custrepos.save(customer);
+// }
+
+ @Override
+ public List findAllCustomerOrders() {
+ List rtnList = new ArrayList<>();
+ custrepos.findAll().iterator().forEachRemaining(rtnList::add);
+ return rtnList;
+ }
+
+ @Override
+ public Customer findCustomersById(long id) throws EntityNotFoundException {
+ Customer rtnCust = custrepos.findById(id+16) // idk why buy my seed data is starting at custcode 17, so in order to start from 1, i am adding 16
+ .orElseThrow(() -> new EntityNotFoundException("Customer "+ id + " Not Found"));
+ return rtnCust;
+ }
+
+ @Override
+ public List findCustomerLikeName(String subname) {
+ List rtnList = custrepos.findByCustnameContainingIgnoringCase(subname);
+ return rtnList;
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersService.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersService.java
new file mode 100644
index 0000000..2669667
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersService.java
@@ -0,0 +1,13 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Agent;
+import com.lambdaschool.orders.orders.models.Order;
+
+import java.util.List;
+
+public interface OrdersService {
+ Order save(Order order);
+
+ Order findOrdersById(long id);
+
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersServiceImpl.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersServiceImpl.java
new file mode 100644
index 0000000..dd7460b
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/OrdersServiceImpl.java
@@ -0,0 +1,29 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Order;
+import com.lambdaschool.orders.orders.repositories.OrdersRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.persistence.EntityNotFoundException;
+
+@Transactional
+@Service(value = "ordersService")
+public class OrdersServiceImpl implements OrdersService {
+ @Autowired
+ private OrdersRepository orderrepos;
+
+ @Transactional
+ @Override
+ public Order save(Order order) {
+ return orderrepos.save(order);
+ }
+
+ @Override
+ public Order findOrdersById(long id) {
+ Order rtnOrder = orderrepos.findById(id)
+ .orElseThrow(()-> new EntityNotFoundException("Order "+id+" Not Found"));
+ return rtnOrder;
+ }
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServices.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServices.java
new file mode 100644
index 0000000..c897147
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServices.java
@@ -0,0 +1,7 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Payment;
+
+public interface PaymentServices {
+// Payment save(Payment payment);
+}
diff --git a/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServicesImpl.java b/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServicesImpl.java
new file mode 100644
index 0000000..9bac89e
--- /dev/null
+++ b/orders/src/main/java/com/lambdaschool/orders/orders/services/PaymentServicesImpl.java
@@ -0,0 +1,20 @@
+package com.lambdaschool.orders.orders.services;
+
+import com.lambdaschool.orders.orders.models.Payment;
+import com.lambdaschool.orders.orders.repositories.PaymentRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+@Service(value = "paymentServices")
+public class PaymentServicesImpl implements PaymentServices {
+ @Autowired
+ PaymentRepository payrepos;
+
+// @Transactional
+// @Override
+// public Payment save(Payment payment) {
+// return payrepos.save(payment);
+// }
+}
diff --git a/orders/src/main/resources/application.properties b/orders/src/main/resources/application.properties
new file mode 100644
index 0000000..41a2cbc
--- /dev/null
+++ b/orders/src/main/resources/application.properties
@@ -0,0 +1,25 @@
+# Configurations useful for working with H2
+spring.h2.console.enabled=true
+spring.h2.console.path=/h2-console
+#
+# We set a port that is not frequently used
+server.port=${PORT:2019}
+#
+# Feature that determines what happens when no accessors are found for a type
+# (and there are no annotations to indicate it is meant to be serialized).
+spring.jackson.serialization.fail-on-empty-beans=false
+#
+# keeps a transaction inside of the same entity manager
+# This property register an EntityManager to the current thread,
+# so you will have the same EntityManager until the web request is finished.
+spring.jpa.open-in-view=true
+#
+# What do with the schema
+# drop n create table again, good for testing
+spring.jpa.hibernate.ddl-auto=create
+spring.datasource.initialization-mode=never
+#
+# Good for production!
+# spring.jpa.hibernate.ddl-auto=update
+# spring.datasource.initialization-mode=never
+
diff --git a/orders/src/test/java/com/lambdaschool/orders/orders/OrdersApplicationTests.java b/orders/src/test/java/com/lambdaschool/orders/orders/OrdersApplicationTests.java
new file mode 100644
index 0000000..8b22f03
--- /dev/null
+++ b/orders/src/test/java/com/lambdaschool/orders/orders/OrdersApplicationTests.java
@@ -0,0 +1,13 @@
+package com.lambdaschool.orders.orders;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class OrdersApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}