mirror of
				https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
				synced 2025-10-31 17:13:10 +00:00 
			
		
		
		
	Ajouts des classes de services du serveur; Update diagrammes de classe; Ajout TODO
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | package com.pqt.server; | ||||||
|  |  | ||||||
|  | public class Server { | ||||||
|  |     public static void main(String[] args){ | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,23 @@ | |||||||
|  | package com.pqt.server.module.account; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.user_account.Account; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO ajouter logs | ||||||
|  | public class AccountService { | ||||||
|  |  | ||||||
|  | 	private IAccountDao dao; | ||||||
|  |  | ||||||
|  |     public AccountService() { | ||||||
|  |         //TODO add dao instanciation | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public boolean isAccountConnected(Account acc) { | ||||||
|  | 		return dao.isAccountConnected(acc); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public boolean setAccountConnected(Account acc, boolean connected) { | ||||||
|  | 		return dao.setAccountConnected(acc, connected); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | package com.pqt.server.module.account; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.user_account.Account; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO créer implémentaiton | ||||||
|  | public interface IAccountDao { | ||||||
|  |  | ||||||
|  | 	boolean isAccountConnected(Account acc); | ||||||
|  |  | ||||||
|  | 	boolean setAccountConnected(Account acc, boolean connected); | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,37 @@ | |||||||
|  | package com.pqt.server.module.client; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.members.Client; | ||||||
|  |  | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.HashSet; | ||||||
|  | import java.util.Set; | ||||||
|  |  | ||||||
|  | //TODO écrire javadoc | ||||||
|  | //TODO ajouter logs | ||||||
|  | public class ClientService { | ||||||
|  |  | ||||||
|  |     private Set<Client> clientCache; | ||||||
|  |  | ||||||
|  |     public ClientService(){ | ||||||
|  |         clientCache = new HashSet<>(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	public boolean isClientRegistered(Client client) { | ||||||
|  | 		return clientCache.contains(client); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void registerClient(Client client) { | ||||||
|  |         if(clientCache.contains(client)){ | ||||||
|  |             refreshClientTimestamp(client); | ||||||
|  |             clientCache.add(client); | ||||||
|  |         } | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public Date getLastClientAction(Client client) { | ||||||
|  | 		return client.getLastUpdate(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void refreshClientTimestamp(Client client) { | ||||||
|  |         client.setLastUpdate(new Date()); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | package com.pqt.server.module.sale; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.sale.Sale; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO Créer implémentation | ||||||
|  | public interface ISaleDao { | ||||||
|  |  | ||||||
|  | 	long submitSale(Sale sale); | ||||||
|  |  | ||||||
|  | 	void submitSaleRevert(long id); | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,22 @@ | |||||||
|  | package com.pqt.server.module.sale; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.sale.Sale; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO ajouter logs | ||||||
|  | public class SaleService { | ||||||
|  |  | ||||||
|  |     private ISaleDao dao; | ||||||
|  |  | ||||||
|  |     public SaleService() { | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public long submitSale(Sale sale) { | ||||||
|  | 		return dao.submitSale(sale); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void submitSaleRevert(long id) { | ||||||
|  |         dao.submitSaleRevert(id); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,43 @@ | |||||||
|  | package com.pqt.server.module.state; | ||||||
|  |  | ||||||
|  | public class ServerState { | ||||||
|  |  | ||||||
|  | 	private int port; | ||||||
|  |  | ||||||
|  | 	private boolean serverState; | ||||||
|  |  | ||||||
|  | 	public ServerState() { | ||||||
|  | 		port = -1; | ||||||
|  | 		serverState = false; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public ServerState(int port) { | ||||||
|  | 		this.port = port; | ||||||
|  | 		serverState = false; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public ServerState(ServerState clone){ | ||||||
|  | 	    this.serverState = clone.serverState; | ||||||
|  | 	    this.port = clone.port; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | 	public int getPort() { | ||||||
|  | 		return port; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void setPort(int port) { | ||||||
|  | 		this.port = port; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public boolean isServerState() { | ||||||
|  | 		return serverState; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void setServerState(boolean serverState) { | ||||||
|  | 		this.serverState = serverState; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |     public ServerState copy() { | ||||||
|  |         return new ServerState(this); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -0,0 +1,40 @@ | |||||||
|  | package com.pqt.server.module.state; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.members.DataServer; | ||||||
|  |  | ||||||
|  | import java.util.Date; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO Ajouter logs | ||||||
|  | public class ServerStateService { | ||||||
|  |  | ||||||
|  | 	private ServerState serverState; | ||||||
|  | 	private DataServer server; | ||||||
|  |  | ||||||
|  | 	public ServerStateService() { | ||||||
|  | 	    this.server = new DataServer(); | ||||||
|  | 	    this.serverState = new ServerState(); | ||||||
|  |  | ||||||
|  | 	    //TODO config adresse IP | ||||||
|  |         //this.server.setAddress(...); | ||||||
|  |  | ||||||
|  |         this.server.setLastUpdate(new Date()); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void startServer() { | ||||||
|  |         serverState.setServerState(true); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void stopServer() { | ||||||
|  |         serverState.setServerState(false); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void changeConnectionPort(int port) { | ||||||
|  |         serverState.setPort(port); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public ServerState getServerStateCopy() { | ||||||
|  | 		return serverState.copy(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,46 @@ | |||||||
|  | package com.pqt.server.module.statistics; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.product.Product; | ||||||
|  | import com.pqt.server.module.stock.StockService; | ||||||
|  | import com.pqt.server.module.sale.SaleService; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO Ajouter logs | ||||||
|  | //TODO écrire contenu méthodes | ||||||
|  | public class StatisticsService { | ||||||
|  |  | ||||||
|  |     private StockService stockService; | ||||||
|  |     private SaleService saleService; | ||||||
|  |  | ||||||
|  |     public StatisticsService(StockService stockService, SaleService saleService) { | ||||||
|  |         this.stockService = stockService; | ||||||
|  |         this.saleService = saleService; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public int getTotalAmountSale() { | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public double getTotalMoneyMade() { | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public double getTotalSaleWorth() { | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public List<Product> getTopPopularProducts(int amount) { | ||||||
|  | 		return null; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public int getTotalAmountStaffSales() { | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public int getTotalAmountGuestSale() { | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,50 @@ | |||||||
|  | package com.pqt.server.module.stock; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.product.Product; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | //TODO écrire contenu méthodes | ||||||
|  | public class HibernateStockDao implements IStockDao { | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @see com.pqt.server.module.stock.IStockDao#getProductList() | ||||||
|  | 	 */ | ||||||
|  | 	public List<Product> getProductList() { | ||||||
|  | 		return null; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @see com.pqt.server.module.stock.IStockDao#getProduct(long) | ||||||
|  | 	 */ | ||||||
|  | 	public Product getProduct(long id) { | ||||||
|  | 		return null; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @see com.pqt.server.module.stock.IStockDao#addProduct(com.pqt.core.entities.product.Product) | ||||||
|  | 	 */ | ||||||
|  | 	public void addProduct(Product product) { | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @see com.pqt.server.module.stock.IStockDao#removeProduct(long) | ||||||
|  | 	 */ | ||||||
|  | 	public void removeProduct(long id) { | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * @see com.pqt.server.module.stock.IStockDao#modifyProduct(long, com.pqt.core.entities.product.Product) | ||||||
|  | 	 */ | ||||||
|  | 	public void modifyProduct(long id, Product product) { | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,20 @@ | |||||||
|  | package com.pqt.server.module.stock; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.product.Product; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | //TODO écrire javadoc | ||||||
|  | public interface IStockDao { | ||||||
|  |  | ||||||
|  | 	public List<Product> getProductList(); | ||||||
|  |  | ||||||
|  | 	public Product getProduct(long id); | ||||||
|  |  | ||||||
|  | 	public void addProduct(Product product); | ||||||
|  |  | ||||||
|  | 	public void removeProduct(long id); | ||||||
|  |  | ||||||
|  | 	public void modifyProduct(long id, Product product); | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,36 @@ | |||||||
|  | package com.pqt.server.module.stock; | ||||||
|  |  | ||||||
|  | import com.pqt.core.entities.product.Product; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | //TODO écrire Javadoc | ||||||
|  | //TODO ajouter logs | ||||||
|  | public class StockService { | ||||||
|  |  | ||||||
|  |     private IStockDao dao; | ||||||
|  |  | ||||||
|  |     public StockService() { | ||||||
|  |         dao = new HibernateStockDao(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public List<Product> getProductList() { | ||||||
|  | 		return dao.getProductList(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public Product getProduct(long id) { | ||||||
|  | 		return dao.getProduct(id); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void addProduct(Product product) { | ||||||
|  |         dao.addProduct(product); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void removeProduct(long id) { | ||||||
|  |         dao.removeProduct(id); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void modifyProduct(long id, Product product) { | ||||||
|  |         dao.modifyProduct(id, product); | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user