diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..8c79c15 --- /dev/null +++ b/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.globant + shoppingcart + 0.1 + war + + + 1.8 + 1.8 + + + + + + mysql + mysql-connector-java + 8.0.11 + + + commons-logging + commons-logging + 1.2 + + + org.springframework + spring-core + 5.0.7.RELEASE + + + org.springframework + spring-web + 5.0.7.RELEASE + + + com.fasterxml.jackson.core + jackson-databind + 2.9.6 + + + org.springframework + spring-webmvc + 5.0.7.RELEASE + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-war-plugin + + src/main/resources/WEB-INF/web.xml + + + + + \ No newline at end of file diff --git a/src/main/java/com/globant/config/AppConfiguration.java b/src/main/java/com/globant/config/AppConfiguration.java new file mode 100644 index 0000000..7e54f5e --- /dev/null +++ b/src/main/java/com/globant/config/AppConfiguration.java @@ -0,0 +1,10 @@ +package com.globant.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("com.globant") +public class AppConfiguration { + +} diff --git a/src/main/java/com/globant/controller/ClientController.java b/src/main/java/com/globant/controller/ClientController.java new file mode 100644 index 0000000..e91b015 --- /dev/null +++ b/src/main/java/com/globant/controller/ClientController.java @@ -0,0 +1,54 @@ +package com.globant.controller; + +import com.globant.dto.ClientDTO; +import com.globant.service.ClientService; +import com.globant.service.CRUD; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import java.util.List; + +@RestController +public class ClientController { + + private final CRUD clientService; + + @Autowired + public ClientController(ClientService clientService) { + this.clientService = clientService; + } + + @RequestMapping(value = "/createClient", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ClientDTO create(ClientDTO clientDTO) { + validate(clientDTO); + return clientService.create(clientDTO); + } + + @RequestMapping(value = "/retrieveClient", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ClientDTO read(int clientId) { + return clientService.read(clientId); + } + + @RequestMapping(value = "/updateClient", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + public ClientDTO update(ClientDTO clientDTO) { + validate(clientDTO); + return clientService.update(clientDTO); + } + + @RequestMapping(value = "/deleteClient", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) + public void delete(int clientId) { + clientService.delete(clientId); + } + + @RequestMapping(value = "/retrieveClient", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public List readAll(List clientIds) { + return clientService.readAll(); + } + + private void validate(ClientDTO clientDTO) { + if (clientDTO == null) + throw new IllegalArgumentException("object cannot be null"); + } +} diff --git a/src/main/java/com/globant/controller/ItemController.java b/src/main/java/com/globant/controller/ItemController.java new file mode 100644 index 0000000..db591c2 --- /dev/null +++ b/src/main/java/com/globant/controller/ItemController.java @@ -0,0 +1,7 @@ +package com.globant.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ItemController { +} diff --git a/src/main/java/com/globant/controller/OrderController.java b/src/main/java/com/globant/controller/OrderController.java new file mode 100644 index 0000000..9bffbaa --- /dev/null +++ b/src/main/java/com/globant/controller/OrderController.java @@ -0,0 +1,7 @@ +package com.globant.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class OrderController { +} diff --git a/src/main/java/com/globant/controller/PaymentController.java b/src/main/java/com/globant/controller/PaymentController.java new file mode 100644 index 0000000..4650ea8 --- /dev/null +++ b/src/main/java/com/globant/controller/PaymentController.java @@ -0,0 +1,7 @@ +package com.globant.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class PaymentController { +} diff --git a/src/main/java/com/globant/dao/ClientDAO.java b/src/main/java/com/globant/dao/ClientDAO.java new file mode 100644 index 0000000..4755536 --- /dev/null +++ b/src/main/java/com/globant/dao/ClientDAO.java @@ -0,0 +1,144 @@ + + +package com.globant.dao; + +import com.globant.db.DBConnection; +import com.globant.model.Client; +import org.springframework.stereotype.Repository; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +@Repository +public class ClientDAO implements DataAccessObject { + + private static final String CREATE = "INSERT INTO client(firstName, lastName, description) VALUES (?, ?, ?)"; + private static final String READ = "SELECT * FROM client WHERE IdClient=?"; + private static final String UPDATE = "UPDATE client SET firstName =?, lastName=?, description= ? WHERE idClient=?"; + private static final String DELETE = "DELETE FROM client WHERE idClient=?"; + private static final String READ_ALL = "SELECT * FROM client"; + + public Client create(Client client) { + + try { + DBConnection dbConnection = DBConnection.getInstance ( ); + Connection connection = dbConnection.getConnection ( ); + PreparedStatement statement = connection.prepareStatement (CREATE); + statement.setString (1, client.getName ( )); + statement.setString (2, client.getSurname ( )); + statement.setString (3, client.getDescription ( )); + + ResultSet resultset = statement.executeQuery ( ); + String name = resultset.getString ("firsName"); + String lastname = resultset.getString ("lastName"); + String description = resultset.getString ("description"); + int clientid = resultset.getInt ("idClient"); + + + return new Client ( clientid,name, lastname, description); + + + + } catch (SQLException e) { + System.out.print ("error: client could not be created "+e.getMessage()); + + } + return null; + + } + public Client read( int id) { + + try { + DBConnection dbConnection = DBConnection.getInstance ( ); + Connection connection = dbConnection.getConnection ( ); + PreparedStatement statement = connection.prepareStatement (READ); + statement.setInt (1, id); + + ResultSet resultset = statement.executeQuery ( ); + String name = resultset.getString ("firsName"); + String lastname = resultset.getString ("lastName"); + String description = resultset.getString ("description"); + int clientid = resultset.getInt ("idClient"); + + return new Client (clientid, name, lastname, description); + + } catch (SQLException e) { + System.out.print ("error: client not found "+e.getMessage()); + } + return null; + } + public Client update( Client client){ + try { + DBConnection dbConnection = DBConnection.getInstance ( ); + Connection connection = dbConnection.getConnection ( ); + PreparedStatement statement = connection.prepareStatement (UPDATE); + statement.setString (1, client.getName ( )); + statement.setString (2, client.getSurname ( )); + statement.setString (3, client.getDescription ( )); + statement.setInt (4,client.getId()); + + statement.executeQuery ( ); + return client; + + } catch (SQLException e) { + System.out.print ("error: client has not been updated"+e.getMessage()); + + } + return null; + + } + + + public void delete ( int id ){ + try { + DBConnection dbConnection = DBConnection.getInstance ( ); + Connection connection = dbConnection.getConnection ( ); + PreparedStatement statement = connection.prepareStatement (DELETE); + statement.setInt (1, id); + + statement.executeQuery ( ); + + } catch (SQLException e) { + System.out.print ("error: client not found "+e.getMessage()); + + } + } + public List readAll(){ + + try { + DBConnection dbConnection = DBConnection.getInstance ( ); + Connection connection = dbConnection.getConnection ( ); + PreparedStatement statement = connection.prepareStatement (READ_ALL); + List clients = new ArrayList(); + + ResultSet resultset = statement.executeQuery ( ); + while (resultset.next ()){ + int idClient = resultset.getInt ("idClient"); + String name = resultset.getString ("firsName"); + String lastname = resultset.getString ("lastName"); + String descrption = resultset.getString ("description"); + + Client client= new Client (idClient, name,lastname, descrption); + + + + clients.add (client); + } + + + return clients; + + } catch (SQLException e) { + System.out.print ("error: customers were not found"+e.getMessage()); + + } + return null; + + } + + +} diff --git a/src/main/java/com/globant/dao/DataAccessObject.java b/src/main/java/com/globant/dao/DataAccessObject.java new file mode 100644 index 0000000..a561b0b --- /dev/null +++ b/src/main/java/com/globant/dao/DataAccessObject.java @@ -0,0 +1,11 @@ +package com.globant.dao; + +import java.util.List; + +public interface DataAccessObject{ + T create(T object); + T read(int id ); + T update(T object); + void delete(int id); + List readAll(); +} diff --git a/src/main/java/com/globant/dao/ItemDAO.java b/src/main/java/com/globant/dao/ItemDAO.java new file mode 100644 index 0000000..5324c07 --- /dev/null +++ b/src/main/java/com/globant/dao/ItemDAO.java @@ -0,0 +1,29 @@ +package com.globant.dao; + +import com.globant.model.Item; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class ItemDAO implements DataAccessObject { + public Item create( Item object ) { + return null; + } + + public Item read( int id ) { + return null; + } + + public Item update( Item object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/dao/OrderDAO.java b/src/main/java/com/globant/dao/OrderDAO.java new file mode 100644 index 0000000..03d9d60 --- /dev/null +++ b/src/main/java/com/globant/dao/OrderDAO.java @@ -0,0 +1,29 @@ +package com.globant.dao; + +import com.globant.model.Client; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class OrderDAO implements DataAccessObject { + public Client create( Client object ) { + return null; + } + + public Client read( int id ) { + return null; + } + + public Client update( Client object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/dao/PaymentDAO.java b/src/main/java/com/globant/dao/PaymentDAO.java new file mode 100644 index 0000000..55089a1 --- /dev/null +++ b/src/main/java/com/globant/dao/PaymentDAO.java @@ -0,0 +1,29 @@ +package com.globant.dao; + +import com.globant.model.Payment; +import org.springframework.stereotype.Repository; +import java.util.List; + +@Repository +public class PaymentDAO implements DataAccessObject { + + public Payment create( Payment object ) { + return null; + } + + public Payment read( int id ) { + return null; + } + + public Payment update( Payment object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/db/DBConnection.java b/src/main/java/com/globant/db/DBConnection.java new file mode 100644 index 0000000..b673bbe --- /dev/null +++ b/src/main/java/com/globant/db/DBConnection.java @@ -0,0 +1,36 @@ +package com.globant.db; +import java.sql.*; + + +public class DBConnection { + + private static final String USER_NAME = "root"; + private static final String PASSWORD = "Batata+2018*"; + private static final String DB_CONNECTION_STRING = "jdbc:mysql://localhost:3306/shoppingcart"; + private static DBConnection instance; + + private static Connection connection; + + private DBConnection() throws SQLException { + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + this.connection = DriverManager.getConnection(DB_CONNECTION_STRING, USER_NAME , PASSWORD); + } catch (Exception ex) { + System.out.println("Database Connection Creation Failed : " + ex.getMessage()); + } + } + + public Connection getConnection() throws SQLException { + System.out.println("Connected to database"); + return this.connection; + } + + public static DBConnection getInstance() throws SQLException { + if (instance == null) { + instance = new DBConnection(); + } else if (instance.getConnection().isClosed()) { + instance = new DBConnection(); + } + return instance; + } + } \ No newline at end of file diff --git a/src/main/java/com/globant/dto/ClientDTO.java b/src/main/java/com/globant/dto/ClientDTO.java new file mode 100644 index 0000000..e65380a --- /dev/null +++ b/src/main/java/com/globant/dto/ClientDTO.java @@ -0,0 +1,69 @@ +package com.globant.dto; + +import com.globant.model.Payment; + +import java.util.ArrayList; +import java.util.List; + +public class ClientDTO { + private Integer id; + private String name; + private String surname; + private String description; + private List PaymentList = new ArrayList (); + + public ClientDTO() { + } + + public ClientDTO(Integer id ) { + this.id = id; + } + + public ClientDTO(Integer id, String name, String surmane, String description, List paymentArrayList) { + this.id = id; + this.name = name; + this.surname = surname; + this.description = description; + this.PaymentList = PaymentList; + } + + public Integer getId() { + return id; + } + + public String getName() { + return name; + } + + public String getSurmane() { + return surname; + } + + public String getDescription() { + return description; + } + + public List getPaymentList() { + return PaymentList; + } + + public void setId(Integer id ) { + this.id = id; + } + + public void setName( String name ) { + this.name = name; + } + + public void setSurmane( String surmane ) { + this.surname = surname; + } + + public void setDescription( String description ) { + this.description = description; + } + + public void setPaymentList(List PaymentList) { + this.PaymentList = PaymentList; + } +} diff --git a/src/main/java/com/globant/dto/ItemDTO.java b/src/main/java/com/globant/dto/ItemDTO.java new file mode 100644 index 0000000..0587314 --- /dev/null +++ b/src/main/java/com/globant/dto/ItemDTO.java @@ -0,0 +1,44 @@ +package com.globant.dto; + +public class ItemDTO { + private int id; + private String name; + private float price; + + public ItemDTO() { + } + + public ItemDTO( int id ) { + this.id = id; + } + + public ItemDTO( int id, String name, float price ) { + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public float getPrice() { + return price; + } + + public void setId( int id ) { + this.id = id; + } + + public void setName( String name ) { + this.name = name; + } + + public void setPrice( float price ) { + this.price = price; + } +} diff --git a/src/main/java/com/globant/dto/OrderDTO.java b/src/main/java/com/globant/dto/OrderDTO.java new file mode 100644 index 0000000..bb4dd96 --- /dev/null +++ b/src/main/java/com/globant/dto/OrderDTO.java @@ -0,0 +1,40 @@ +package com.globant.dto; + +import com.globant.model.Item; + +import java.util.ArrayList; +import java.util.List; + +public class OrderDTO { + private int id; + private List ItemList = new ArrayList (); + + public OrderDTO() { + } + + public OrderDTO( int id ) { + this.id = id; + } + + public OrderDTO( int id, List itemList ) { + this.id = id; + ItemList = itemList; + } + + public int getId() { + return id; + } + + public List getItemList() { + return ItemList; + } + + public void setId( int id ) { + this.id = id; + } + + public void setItemList( List itemList ) { + ItemList = itemList; + } +} + diff --git a/src/main/java/com/globant/dto/PaymentDTO.java b/src/main/java/com/globant/dto/PaymentDTO.java new file mode 100644 index 0000000..0d5865d --- /dev/null +++ b/src/main/java/com/globant/dto/PaymentDTO.java @@ -0,0 +1,47 @@ +package com.globant.dto; + + +import com.globant.model.Order; + +public class PaymentDTO { + private int id; + private Order order; + private float amount; + + public PaymentDTO() { + } + + public PaymentDTO( int id ) { + this.id = id; + } + + public PaymentDTO( int id, Order order, float amount ) { + this.id = id; + this.order = order; + this.amount = amount; + } + + public void setId( int id ) { + this.id = id; + } + + public void setOrder( Order order ) { + this.order = order; + } + + public void setAmount( float amount ) { + this.amount = amount; + } + + public int getId() { + return id; + } + + public Order getOrder() { + return order; + } + + public float getAmount() { + return amount; + } +} diff --git a/src/main/java/com/globant/model/Client.java b/src/main/java/com/globant/model/Client.java new file mode 100644 index 0000000..54ea4b0 --- /dev/null +++ b/src/main/java/com/globant/model/Client.java @@ -0,0 +1,91 @@ +package com.globant.model; + +import javax.management.Descriptor; +import java.util.ArrayList; +import java.util.List; + +public class Client { private int id; + private String name; + private String surname; + private String description; + private List PaymentList = new ArrayList (); + + public Client( String name, String surname, String description ) { + this.name = name; + this.surname = surname; + this.description=description; + + } + + public Client( int id, String name, String surname, String description ) { + this.id= id; + this.name = name; + this.surname = surname; + this.description= description; + } + + + public Client( int id ) { + this.id = id; + } + + public Client( int id, String name, String surname, String description, List PaymentList) { + this.id = id; + this.name = name; + this.surname = surname; + this.description = description; + this.PaymentList = PaymentList; + } + + + + public void setId( int id ) { + this.id = id; + } + + public int getId() { + return this.id; + } + + public void setName( String name ) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setSurname( String surname ) { + this.surname =surname ; + } + + public String getSurname() { + return surname; + } + + public void setDescription( String description ) { + this.description = description; + } + + public String getDescription() { + return description; + } + + public List getPaymentList() { + return PaymentList; + } + + public void setPaymentList( ArrayList PaymentList ) { + PaymentList = PaymentList; + } + + @Override + public String toString() { + return "Client{" + + "id_client" + id + + ", name='" + name + '\'' + + ", surmane='" + surname + '\'' + + ", description='" + description + '\'' + + '}'; + } +} diff --git a/src/main/java/com/globant/model/Item.java b/src/main/java/com/globant/model/Item.java new file mode 100644 index 0000000..e42f118 --- /dev/null +++ b/src/main/java/com/globant/model/Item.java @@ -0,0 +1,50 @@ +package com.globant.model; + +public class Item {private int id; + private String name; + private float price; + + public Item() { + } + + public Item( int id ) { + this.id = id; + } + + public Item( int id, String name, float price){ + this.id = id; + this.name = name; + this.price = price; + } + + public void setId( int id ) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setName( String name ) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setPrice( float price ) { + this.price = price; + } + + public float getPrice() { + return price; + } + + @Override + public String toString() { + return "Item{" + + "price=" + price + + '}'; + } +} diff --git a/src/main/java/com/globant/model/Order.java b/src/main/java/com/globant/model/Order.java new file mode 100644 index 0000000..810919e --- /dev/null +++ b/src/main/java/com/globant/model/Order.java @@ -0,0 +1,40 @@ +package com.globant.model; + + import java.util.ArrayList; + import java.util.List; + +public class Order {private int id; + private List ItemList = new ArrayList (); + + public Order() { + } + + public Order( int id ) { + this.id = id; + } + + public Order( int id, List ItemList ) { + this.id = id; + ItemList = ItemList; + } + + public Order( int id, Item item){ + this.id = id; + } + + public void setId( int id ) { + this.id = id; + } + + public int getId() { + return id; + } + + + @Override + public String toString() { + return "Order{" + + "id=" + id + + '}'; + } +} diff --git a/src/main/java/com/globant/model/Payment.java b/src/main/java/com/globant/model/Payment.java new file mode 100644 index 0000000..a128dad --- /dev/null +++ b/src/main/java/com/globant/model/Payment.java @@ -0,0 +1,54 @@ +package com.globant.model; + + + +public class Payment { private int id_payment; + private Order order; + private float amount; + + public Payment() { + } + + public Payment( int id_payment ) { + this.id_payment = id_payment; + } + + public Payment( int id_payment, Order order, float amount){ + this. id_payment= id_payment; + this.order = order; + this.amount = amount; + } + + public void setId( int id_payment ) { + this.id_payment =id_payment ; + } + + public int getid_payment() { + return id_payment; + } + + public void setOrder( Order order ) { + this.order = order; + } + + public Order getOrder() { + return order; + } + + public void setAmount( float amount ) { + this.amount = amount; + } + + public float getAmount() { + return amount; + } + + @Override + public String toString() { + return "Payment{" + + "id_payment=" + id_payment + + ", order=" + order + + ", amount=" + amount + + '}'; + } +} diff --git a/src/main/java/com/globant/service/CRUD.java b/src/main/java/com/globant/service/CRUD.java new file mode 100644 index 0000000..0a41902 --- /dev/null +++ b/src/main/java/com/globant/service/CRUD.java @@ -0,0 +1,11 @@ +package com.globant.service; + +import java.util.List; + +public interface CRUD { + T create (T object) ; + T read (int id ); + T update (T object); + void delete(int id); + List readAll(); +} diff --git a/src/main/java/com/globant/service/ClientService.java b/src/main/java/com/globant/service/ClientService.java new file mode 100644 index 0000000..8eb09fb --- /dev/null +++ b/src/main/java/com/globant/service/ClientService.java @@ -0,0 +1,45 @@ +package com.globant.service; + +import com.globant.dao.ClientDAO; +import com.globant.dao.DataAccessObject; +import com.globant.dto.ClientDTO; +import com.globant.model.Client; +import com.globant.util.DTOUtils; +import com.globant.util.ModelUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +import java.util.List; + +@Service +public class ClientService implements CRUD { + + private final DataAccessObject clientDAO; + + @Autowired + public ClientService(ClientDAO clientDAO) { + this.clientDAO = clientDAO; + } + + public ClientDTO create(ClientDTO clientDTO) { + Client client = clientDAO.create(ModelUtils.toClient(clientDTO)); + return DTOUtils.clientDTO(client); + } + + public ClientDTO read( int id ) { + return null; + } + + public ClientDTO update( ClientDTO object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/service/ItemService.java b/src/main/java/com/globant/service/ItemService.java new file mode 100644 index 0000000..5b1087a --- /dev/null +++ b/src/main/java/com/globant/service/ItemService.java @@ -0,0 +1,28 @@ +package com.globant.service; + +import com.globant.dao.ItemDAO; + +import java.util.List; + +public class ItemService implements CRUD { + + public ItemDAO create( ItemDAO object ) { + return null; + } + + public ItemDAO read( int id ) { + return null; + } + + public ItemDAO update( ItemDAO object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/service/OrderService.java b/src/main/java/com/globant/service/OrderService.java new file mode 100644 index 0000000..efc239e --- /dev/null +++ b/src/main/java/com/globant/service/OrderService.java @@ -0,0 +1,27 @@ +package com.globant.service; + +import com.globant.dto.ClientDTO; + +import java.util.List; + +public class OrderService implements CRUD { + public ClientDTO create( ClientDTO object ) { + return null; + } + + public ClientDTO read( int id ) { + return null; + } + + public ClientDTO update( ClientDTO object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/service/PaymentService.java b/src/main/java/com/globant/service/PaymentService.java new file mode 100644 index 0000000..2f4eaf7 --- /dev/null +++ b/src/main/java/com/globant/service/PaymentService.java @@ -0,0 +1,28 @@ +package com.globant.service; + +import com.globant.dto.PaymentDTO; + +import java.util.List; + +public class PaymentService implements CRUD { + + public PaymentDTO create(PaymentDTO object ) { + return null; + } + + public PaymentDTO read( int id ) { + return null; + } + + public PaymentDTO update( PaymentDTO object ) { + return null; + } + + public void delete( int id ) { + + } + + public List readAll() { + return null; + } +} diff --git a/src/main/java/com/globant/util/DTOUtils.java b/src/main/java/com/globant/util/DTOUtils.java new file mode 100644 index 0000000..bab49cb --- /dev/null +++ b/src/main/java/com/globant/util/DTOUtils.java @@ -0,0 +1,15 @@ +package com.globant.util; + +import com.globant.dto.ClientDTO; +import com.globant.model.Client; + +public final class DTOUtils { + + public static ClientDTO clientDTO(Client client) { + return new ClientDTO(client.getId(), + client.getName(), + client.getSurname(), + client.getDescription(), + client.getPaymentList()); + } +} diff --git a/src/main/java/com/globant/util/ModelUtils.java b/src/main/java/com/globant/util/ModelUtils.java new file mode 100644 index 0000000..6a14f70 --- /dev/null +++ b/src/main/java/com/globant/util/ModelUtils.java @@ -0,0 +1,15 @@ +package com.globant.util; + +import com.globant.dto.ClientDTO; +import com.globant.model.Client; + +public final class ModelUtils { + + public static Client toClient(ClientDTO clientDTO) { + return new Client(clientDTO.getId(), + clientDTO.getName(), + clientDTO.getName(), + clientDTO.getDescription(), + clientDTO.getPaymentList()); + } +} diff --git a/src/main/resources/WEB-INF/web.xml b/src/main/resources/WEB-INF/web.xml new file mode 100644 index 0000000..ec74ea8 --- /dev/null +++ b/src/main/resources/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + spring + org.springframework.web.servlet.DispatcherServlet + 1 + + + spring + / + + \ No newline at end of file