Commit cc4e0a2a authored by Lefebvre michael's avatar Lefebvre michael

project picsou

parent 55044a91
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="mysql-connector-java-5.1.6-bin" level="project" />
</component>
</module>
\ No newline at end of file
-- creation des tables
drop table if exists RETRAIT;
drop table if exists MOUVEMENT;
drop table if exists CARTE;
drop table if exists COMPTE;
drop table if exists CLIENT;
create table CLIENT(
id INT NOT NULL AUTO_INCREMENT,
nom varchar(20) not null,
prenom varchar(20) not null,
adresse varchar(20) not null,
constraint PK_CLIENT primary key (id) ,
constraint UK_CLIENT_NOM_PRENOM UNIQUE (nom, prenom)
)engine=INNODB AUTO_INCREMENT=3 ;
LOCK TABLES CLIENT WRITE;
INSERT INTO CLIENT VALUES
(1,'GATOR','NATHALIE','LILLE'),
(2,'AFEUX','PIERRE','LENS')
;
UNLOCK TABLES;
create table COMPTE(
id INT NOT NULL AUTO_INCREMENT,
numero VARCHAR(10) not null,
titulaire INT NOT NULL,
date_ouverture DATE NOT NULL ,
plafond REAL DEFAULT 0.0,
bloque CHAR(3) DEFAULT 'non',
solde REAL NOT NULL,
constraint PK_COMPTE primary key (id),
constraint UK_COMPTE_NUM UNIQUE (numero),
constraint FK_COMPTE_T FOREIGN KEY (titulaire) references CLIENT(id)
)engine=INNODB AUTO_INCREMENT=5;
LOCK TABLES COMPTE WRITE;
INSERT INTO COMPTE VALUES
(1,'1234',1,current_date,1000.0,'non',200.0),
(2,'1235',1,current_date,0.0,'non',100.0),
(3,'1236',2,current_date,1500.0,'non',300.0),
(4,'1237',1,current_date,0.0,'non',100.0)
;
UNLOCK TABLES;
create table MOUVEMENT(
id INT NOT NULL AUTO_INCREMENT,
id_compte INT not null,
date_operation TIMESTAMP NOT NULL,
montant REAL NOT NULL,
nature CHAR(2),
constraint PK_MOUVEMENT primary key (id),
constraint FK_MOUVEMENT_IDC foreign key (id_compte) references COMPTE(id)
)engine=INNODB AUTO_INCREMENT=4;
LOCK TABLES MOUVEMENT WRITE;
INSERT INTO MOUVEMENT VALUES
(1,1, current_timestamp, 60.0, 'CR'),
(2,3, current_timestamp, 60.0, 'DB'),
(3,3, current_timestamp, 100.0, 'CB')
;
UNLOCK TABLES;
create table CARTE(
id INT NOT NULL AUTO_INCREMENT,
numero varchar(40) not null,
id_compte INT not null,
date_expiration date not null,
codesecret CHAR(4) not null,
bloque char(3) DEFAULT 'non',
nb_essai INT DEFAULT 0,
constraint PK_CARTE primary key (id) ,
constraint UK_CARTE_NUM UNIQUE (numero) ,
constraint FK_CARTE_IDC foreign key (id_compte) references COMPTE(id)
)engine=INNODB AUTO_INCREMENT=3;
LOCK TABLES CARTE WRITE;
INSERT INTO CARTE VALUES
(1,'GATORCB01',1,'2021-05-07','1234','non',0),
(2,'AFEUXCB01',3,'2019-05-06','5678','non',0)
;
UNLOCK TABLES;
create table RETRAIT(
id INT NOT NULL AUTO_INCREMENT,
id_carte INT NOT NULL ,
date_retrait TIMESTAMP not null,
adresseGAB varchar(20) not null,
montant REAL not null,
etat VARCHAR(10) not null,
id_mouvement INT ,
constraint PK_RETRAIT primary key (id),
constraint FK_RETRAIT_CART foreign key (id_carte) references CARTE(id),
constraint FK_RETRAIT_MOUV foreign key (id_mouvement) references MOUVEMENT(id)
)engine=INNODB AUTO_INCREMENT=2;
LOCK TABLES RETRAIT WRITE;
INSERT INTO RETRAIT VALUES
(1, 2,current_timestamp, 'BP LILLE', 100.0, 'SUCCES',3)
;
UNLOCK TABLES;
package dto;
public class CarteDTO {
}
package dto;
public class ClientDTO {
private int id;
private String nom;
private String prenom;
private String adresse;
}
package dto;
import java.io.Serializable;
import java.sql.Date;
public class CompteDTO implements Serializable {
//numero de version
private static final long serialVersionUID = 1L;
//attributs d'instance pertinents
private int id;
private String numero;
private int idtitulaire;
private String nomPrenomTitulaire;
private Date dateOuverture;
private double plafond;
private String bloque;
private double solde;
//----------------------- G E T T E R S E T T E R -----------------------------
public int getId() {
return id;
}
public String getNumero() {
return numero;
}
private void setNumero(String numero) {
this.numero = numero;
}
public int getIdtitulaire() {
return idtitulaire;
}
private void setIdtitulaire(int idtitulaire) {
this.idtitulaire = idtitulaire;
}
public String getNomPrenomTitulaire() {
return nomPrenomTitulaire;
}
private void setNomPrenomTitulaire(String nomPrenomTitulaire) {
this.nomPrenomTitulaire = nomPrenomTitulaire;
}
public Date getDateOuverture() {
return dateOuverture;
}
private void setDateOuverture(Date dateOuverture) {
this.dateOuverture = dateOuverture;
}
public double getPlafond() {
return plafond;
}
private void setPlafond(double plafond) {
this.plafond = plafond;
}
public String getBloque() {
return bloque;
}
private void setBloque(String bloque) {
this.bloque = bloque;
}
public double getSolde() {
return solde;
}
private void setSolde(double solde) {
this.solde = solde;
}
//-------------------------------- C O N S T R U C T E U R --------------------------------
public CompteDTO(int id, String numero, int idtitulaire, String nomPrenomTitulaire, Date dateOuverture,
double plafond, String bloque, double solde) {
this.id = id;
this.numero = numero;
this.idtitulaire = idtitulaire;
this.nomPrenomTitulaire = nomPrenomTitulaire;
this.dateOuverture = dateOuverture;
this.plafond = plafond;
this.bloque = bloque;
this.solde = solde;
}
//tostring
@Override
public String toString() {
return "CompteDTO{" +
"id=" + id +
", numero='" + numero + '\'' +
", idtitulaire=" + idtitulaire +
", nomPrenomTitulaire='" + nomPrenomTitulaire + '\'' +
", dateOuverture=" + dateOuverture +
", plafond=" + plafond +
", bloque='" + bloque + '\'' +
", solde=" + solde +
'}';
}
}
package dto;
public class MouvementDTO {
}
package dto;
public class RetraitDTO {
}
package exception;
public class ExceptionMetier extends Exception{
public ExceptionMetier(){
super();
}
public ExceptionMetier(String message){
super(message);
}
}
package metier;
import dto.CompteDTO;
import exception.ExceptionMetier;
import java.util.*;
public interface IPicsouDAO {
//gestion des comptes
public List<CompteDTO> findCompteByClient(int idClient);
public CompteDTO findCompteById(int idCompte) throws ExceptionMetier;
//exception du pauvre : renvoyer un status
public void credit(int idCompte, double montant) throws ExceptionMetier;
public void debit(int idCompte, double montant) throws ExceptionMetier;
public void transfert(int idCompteOrigine, int idCompteDestination, double montant) throws ExceptionMetier;
}
This diff is collapsed.
package service;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectPicsou {
//url de connection
private final static String URL = "jdbc:mysql://localhost:3306/picsou";
//utilisatuer de connection
private final static String USER = "michael";
//mot de passe de connection
private final static String PW = "mdppopmichael";
//SINGLETON precoce ou lazzy ici precoce il s'execute automatiquement
private static Connection INSTANCE;
// initialisateur si singleton precoce un bloc static permet d'initialiser les variables de classes
static{
try{
INSTANCE = DriverManager.getConnection(URL,USER,PW);
}catch(SQLException e){
e.printStackTrace();
}
}
//constructeur privé pour singleton lazzy il faudra l'exectuer
/*private ConnectPicsou() {
try{
INSTANCE = DriverManager.getConnection(URL,USER,PW);
}catch(SQLException e){
e.printStackTrace();
}
}*/
public static Connection getInstance(){
//si singleton lazzy a ajouter
/*if (INSTANCE == null){
new ConnectPicsou();
}*/
return INSTANCE;
}
public static void main(String[] args) {
ConnectPicsou.getInstance();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment