Ajoue d'un lien avec une base de donnée sur le localhost (mamp) grace à l'api, fin de tous les savers et les loaders a part ceux des matchs, fin de la partie reseaux lorsque l'utilisateur envoie et reçoit un message
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ace46ab432
commit
0f97baac5d
@ -1,19 +1,22 @@
|
||||
# Rederection if URL not found
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILEANME} !-f
|
||||
RewriteCond %{REQUEST_FILEANME} !-d
|
||||
RewriteRule (.+) index.php?p=$1 [QSA,L]
|
||||
</IfModule>
|
||||
# # Rederection if URL not found
|
||||
|
||||
# Redirecting 403 errors to index.php (does not work)
|
||||
ErrorDocument 403 http://localhost:8888/api-rest/index.php
|
||||
# <IfModule mod_rewrite.c>
|
||||
# RewriteEngine on
|
||||
# RewriteCond %{REQUEST_FILEANME} !-f
|
||||
# RewriteCond %{REQUEST_FILEANME} !-d
|
||||
# RewriteRule (.+) index.php?p=$1 [QSA,L]
|
||||
# </IfModule>
|
||||
|
||||
# Refusing access to all files ending with php
|
||||
Require all denied
|
||||
# # Redirecting 403 errors to index.php (does not work)
|
||||
# #ErrorDocument 403 http://localhost:8888/api-rest/index.php
|
||||
|
||||
# Allowing access to index.php
|
||||
<Files index.php>
|
||||
Require all granted
|
||||
</Files>
|
||||
# # Refusing access to all files ending with php
|
||||
|
||||
|
||||
# # Allowing access to index.php
|
||||
# <Files index.php>
|
||||
# Require all granted
|
||||
# </Files>
|
||||
|
||||
# Require all denied
|
||||
|
||||
|
@ -0,0 +1,430 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.1.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Hôte : localhost:8889
|
||||
-- Généré le : ven. 30 déc. 2022 à 14:14
|
||||
-- Version du serveur : 5.7.34
|
||||
-- Version de PHP : 7.4.21
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `bobParty`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_E_GAME_GAM`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_E_GAME_GAM` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`GAM_NAME` varchar(50) DEFAULT NULL,
|
||||
`GAM_IMAGE` varchar(50) DEFAULT NULL,
|
||||
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
|
||||
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_E_MATCH_MTC`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_E_MATCH_MTC` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`MTC_IN_GAME` tinyint(1) DEFAULT NULL,
|
||||
`FK_GAME` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_H_CONVERSATION_COV`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_H_CONVERSATION_COV` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`COV_NAME` varchar(20) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_H_CONVERSATION_COV`
|
||||
--
|
||||
|
||||
INSERT INTO `T_H_CONVERSATION_COV` (`PK_ID`, `COV_NAME`) VALUES
|
||||
(32, 'Wesh la conv');
|
||||
|
||||
--
|
||||
-- Déclencheurs `T_H_CONVERSATION_COV`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `before_delete_conversation` BEFORE DELETE ON `T_H_CONVERSATION_COV` FOR EACH ROW DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE
|
||||
FROM T_J_CONTAIN_MESSAGE_CMG
|
||||
WHERE FK_CONVERSATION=OLD.PK_ID)
|
||||
$$
|
||||
DELIMITER ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_H_MESSAGE_MSG`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_H_MESSAGE_MSG` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`MSG_MESSAGE` text,
|
||||
`FK_SENDER` int(11) DEFAULT NULL,
|
||||
`MSG_DATEENVOIE` datetime NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_H_MESSAGE_MSG`
|
||||
--
|
||||
|
||||
INSERT INTO `T_H_MESSAGE_MSG` (`PK_ID`, `MSG_MESSAGE`, `FK_SENDER`, `MSG_DATEENVOIE`) VALUES
|
||||
(21, 'tom a créé une conversation', 1, '2022-12-29 00:00:00'),
|
||||
(25, 'Salut test', 1, '2022-12-30 09:39:15'),
|
||||
(57, 'Salut by', 1, '2022-12-30 11:01:17'),
|
||||
(58, 'Wesh', 1, '2022-12-30 11:12:04'),
|
||||
(59, 'Salut', 1, '2022-12-30 11:15:44'),
|
||||
(60, 'Bonjour', 1, '2022-12-30 11:15:52'),
|
||||
(61, 'Wesh', 1, '2022-12-30 11:16:25'),
|
||||
(62, 'Bite', 1, '2022-12-30 11:17:38'),
|
||||
(63, 'Cc', 2, '2022-12-30 11:21:04'),
|
||||
(64, 'Cc', 2, '2022-12-30 11:21:06'),
|
||||
(65, 'Bonjour', 2, '2022-12-30 11:24:58'),
|
||||
(66, 'Hé ho', 2, '2022-12-30 11:25:02'),
|
||||
(68, 'Salut ça va marcher', 1, '2022-12-30 11:55:21');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_H_SKIN_SKI`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_H_SKIN_SKI` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`SKI_NAME` varchar(50) NOT NULL,
|
||||
`SKI_IMAGE` varchar(200) NOT NULL,
|
||||
`SKI_PRICE` varchar(30) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_H_SKIN_SKI`
|
||||
--
|
||||
|
||||
INSERT INTO `T_H_SKIN_SKI` (`PK_ID`, `SKI_NAME`, `SKI_IMAGE`, `SKI_PRICE`) VALUES
|
||||
(1, 'Bob', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png', '0'),
|
||||
(2, 'Bob blue', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png', '100'),
|
||||
(3, 'Bob green', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png', '100'),
|
||||
(4, 'Bob BW', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png', '100');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_J_CONTAIN_MESSAGE_CMG`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_J_CONTAIN_MESSAGE_CMG` (
|
||||
`FK_CONVERSATION` int(11) NOT NULL,
|
||||
`FK_MESSAGE` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_J_CONTAIN_MESSAGE_CMG`
|
||||
--
|
||||
|
||||
INSERT INTO `T_J_CONTAIN_MESSAGE_CMG` (`FK_CONVERSATION`, `FK_MESSAGE`) VALUES
|
||||
(32, 21),
|
||||
(32, 25),
|
||||
(32, 57),
|
||||
(32, 58),
|
||||
(32, 59),
|
||||
(32, 60),
|
||||
(32, 61),
|
||||
(32, 62),
|
||||
(32, 63),
|
||||
(32, 64),
|
||||
(32, 65),
|
||||
(32, 66),
|
||||
(32, 68);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_J_DISCUSS_DIS`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_J_DISCUSS_DIS` (
|
||||
`FK_USER` int(11) NOT NULL,
|
||||
`FK_CONVERSATION` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_J_DISCUSS_DIS`
|
||||
--
|
||||
|
||||
INSERT INTO `T_J_DISCUSS_DIS` (`FK_USER`, `FK_CONVERSATION`) VALUES
|
||||
(1, 32),
|
||||
(2, 32),
|
||||
(3, 32);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_J_OWN_SKIN_OWN`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_J_OWN_SKIN_OWN` (
|
||||
`FK_USER` int(11) NOT NULL,
|
||||
`FK_SKIN` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_J_OWN_SKIN_OWN`
|
||||
--
|
||||
|
||||
INSERT INTO `T_J_OWN_SKIN_OWN` (`FK_USER`, `FK_SKIN`) VALUES
|
||||
(1, 1),
|
||||
(1, 2),
|
||||
(1, 3),
|
||||
(2, 1),
|
||||
(3, 1),
|
||||
(6, 1),
|
||||
(7, 1),
|
||||
(8, 1),
|
||||
(10, 1),
|
||||
(11, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_J_PLAY_MATCH_PLM`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_J_PLAY_MATCH_PLM` (
|
||||
`FK_USER` int(11) NOT NULL,
|
||||
`FK_MATCH` int(11) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `T_S_USER_USR`
|
||||
--
|
||||
|
||||
CREATE TABLE `T_S_USER_USR` (
|
||||
`PK_ID` int(11) NOT NULL,
|
||||
`USR_USERNAME` varchar(50) NOT NULL,
|
||||
`USR_PASSWORD` varchar(50) NOT NULL,
|
||||
`USR_NATIONALITY` varchar(20) NOT NULL,
|
||||
`USR_SEX` varchar(30) NOT NULL,
|
||||
`USR_DATE_OF_BIRTH` date DEFAULT NULL,
|
||||
`USR_CURRENT_NB_COINS` int(11) DEFAULT '0',
|
||||
`USR_TOTAL_NB_COINS` int(11) DEFAULT '0',
|
||||
`USR_NB_GAMES_PLAYED` int(11) DEFAULT '0',
|
||||
`FK_CURRENT_SKIN` int(11) DEFAULT '1'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
-- Déchargement des données de la table `T_S_USER_USR`
|
||||
--
|
||||
|
||||
INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATIONALITY`, `USR_SEX`, `USR_DATE_OF_BIRTH`, `USR_CURRENT_NB_COINS`, `USR_TOTAL_NB_COINS`, `USR_NB_GAMES_PLAYED`, `FK_CURRENT_SKIN`) VALUES
|
||||
(1, 'tom', 't', 'Anglais(e)', 'M', '2003-07-01', 100, 600, 12, 2),
|
||||
(2, 'leilla20', 'l', 'France', 'F', '2003-11-22', 0, 0, 0, 1),
|
||||
(3, 'test', 't', 'Français(e)', 'H', '1999-12-27', 0, 0, 0, 1),
|
||||
(6, 'LEBg', 'belleBite63*', 'Espagnol(e)', 'Autre', '2001-12-27', 0, 0, 0, 1),
|
||||
(7, 'DYLAN', 'argGR65**', 'Anglais(e)', 'Autre', '2002-12-27', 0, 0, 0, 1),
|
||||
(8, 'Marche', 'je45tE**', 'Anglais(e)', 'Femme', '1999-12-27', 0, 0, 0, 1),
|
||||
(10, 'dsqdz', 'AEZQzze1*', 'Francais(e)', 'null', '2005-12-27', 0, 0, 0, 1),
|
||||
(11, 'qdsqdz', 'dqzA12****', 'Francais(e)', 'Homme', '2002-12-27', 0, 0, 0, 1);
|
||||
|
||||
--
|
||||
-- Déclencheurs `T_S_USER_USR`
|
||||
--
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1)
|
||||
$$
|
||||
DELIMITER ;
|
||||
|
||||
--
|
||||
-- Index pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `T_E_GAME_GAM`
|
||||
--
|
||||
ALTER TABLE `T_E_GAME_GAM`
|
||||
ADD PRIMARY KEY (`PK_ID`),
|
||||
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`,`GAM_IMAGE`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_E_MATCH_MTC`
|
||||
--
|
||||
ALTER TABLE `T_E_MATCH_MTC`
|
||||
ADD PRIMARY KEY (`PK_ID`),
|
||||
ADD KEY `FK_GAME` (`FK_GAME`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_H_CONVERSATION_COV`
|
||||
--
|
||||
ALTER TABLE `T_H_CONVERSATION_COV`
|
||||
ADD PRIMARY KEY (`PK_ID`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_H_MESSAGE_MSG`
|
||||
--
|
||||
ALTER TABLE `T_H_MESSAGE_MSG`
|
||||
ADD PRIMARY KEY (`PK_ID`),
|
||||
ADD KEY `FK_SENDER` (`FK_SENDER`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_H_SKIN_SKI`
|
||||
--
|
||||
ALTER TABLE `T_H_SKIN_SKI`
|
||||
ADD PRIMARY KEY (`PK_ID`),
|
||||
ADD UNIQUE KEY `SKI_NAME` (`SKI_NAME`),
|
||||
ADD UNIQUE KEY `SKI_IMAGE` (`SKI_IMAGE`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_J_CONTAIN_MESSAGE_CMG`
|
||||
--
|
||||
ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
|
||||
ADD PRIMARY KEY (`FK_CONVERSATION`,`FK_MESSAGE`),
|
||||
ADD KEY `FK_MESSAGE` (`FK_MESSAGE`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_J_DISCUSS_DIS`
|
||||
--
|
||||
ALTER TABLE `T_J_DISCUSS_DIS`
|
||||
ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`),
|
||||
ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_J_OWN_SKIN_OWN`
|
||||
--
|
||||
ALTER TABLE `T_J_OWN_SKIN_OWN`
|
||||
ADD PRIMARY KEY (`FK_SKIN`,`FK_USER`),
|
||||
ADD KEY `FK_USER` (`FK_USER`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_J_PLAY_MATCH_PLM`
|
||||
--
|
||||
ALTER TABLE `T_J_PLAY_MATCH_PLM`
|
||||
ADD PRIMARY KEY (`FK_USER`,`FK_MATCH`),
|
||||
ADD KEY `FK_MATCH` (`FK_MATCH`);
|
||||
|
||||
--
|
||||
-- Index pour la table `T_S_USER_USR`
|
||||
--
|
||||
ALTER TABLE `T_S_USER_USR`
|
||||
ADD PRIMARY KEY (`PK_ID`),
|
||||
ADD UNIQUE KEY `USR_USERNAME` (`USR_USERNAME`),
|
||||
ADD KEY `FK_CURRENT_SKIN` (`FK_CURRENT_SKIN`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_E_GAME_GAM`
|
||||
--
|
||||
ALTER TABLE `T_E_GAME_GAM`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_E_MATCH_MTC`
|
||||
--
|
||||
ALTER TABLE `T_E_MATCH_MTC`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_H_CONVERSATION_COV`
|
||||
--
|
||||
ALTER TABLE `T_H_CONVERSATION_COV`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=47;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_H_MESSAGE_MSG`
|
||||
--
|
||||
ALTER TABLE `T_H_MESSAGE_MSG`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_H_SKIN_SKI`
|
||||
--
|
||||
ALTER TABLE `T_H_SKIN_SKI`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `T_S_USER_USR`
|
||||
--
|
||||
ALTER TABLE `T_S_USER_USR`
|
||||
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
|
||||
|
||||
--
|
||||
-- Contraintes pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_E_MATCH_MTC`
|
||||
--
|
||||
ALTER TABLE `T_E_MATCH_MTC`
|
||||
ADD CONSTRAINT `t_e_match_mtc_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_H_MESSAGE_MSG`
|
||||
--
|
||||
ALTER TABLE `T_H_MESSAGE_MSG`
|
||||
ADD CONSTRAINT `t_h_message_msg_ibfk_1` FOREIGN KEY (`FK_SENDER`) REFERENCES `T_S_USER_USR` (`PK_ID`);
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_J_CONTAIN_MESSAGE_CMG`
|
||||
--
|
||||
ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
|
||||
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_1` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_2` FOREIGN KEY (`FK_MESSAGE`) REFERENCES `T_H_MESSAGE_MSG` (`PK_ID`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_J_DISCUSS_DIS`
|
||||
--
|
||||
ALTER TABLE `T_J_DISCUSS_DIS`
|
||||
ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_J_OWN_SKIN_OWN`
|
||||
--
|
||||
ALTER TABLE `T_J_OWN_SKIN_OWN`
|
||||
ADD CONSTRAINT `t_j_own_skin_own_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `t_j_own_skin_own_ibfk_2` FOREIGN KEY (`FK_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_J_PLAY_MATCH_PLM`
|
||||
--
|
||||
ALTER TABLE `T_J_PLAY_MATCH_PLM`
|
||||
ADD CONSTRAINT `t_j_play_match_plm_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT `t_j_play_match_plm_ibfk_2` FOREIGN KEY (`FK_MATCH`) REFERENCES `T_E_MATCH_MTC` (`PK_ID`) ON DELETE CASCADE;
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `T_S_USER_USR`
|
||||
--
|
||||
ALTER TABLE `T_S_USER_USR`
|
||||
ADD CONSTRAINT `t_s_user_usr_ibfk_1` FOREIGN KEY (`FK_CURRENT_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
@ -1,16 +1,21 @@
|
||||
import { FakeSaverConversation } from "./src/services/conversationService/fakeSaverConversation";
|
||||
import { LoaderConversationApi } from "./src/services/conversationService/loaderConversationApi";
|
||||
import ManagerConversation from "./src/services/conversationService/managerConversation";
|
||||
import { SaverConversationApi } from "./src/services/conversationService/saverConversationApi";
|
||||
import LoaderGameApi from "./src/services/gameService/loaderGameApi";
|
||||
import ManagerGame from "./src/services/gameService/managerGame";
|
||||
import LoaderMatchApi from "./src/services/matchServices/loaderMatchApi";
|
||||
import ManagerMatch from "./src/services/matchServices/managerMatch";
|
||||
import SaverMatchApi from "./src/services/matchServices/saverMatchApi";
|
||||
import LoaderSkinApi from "./src/services/skinService/loaderSkinApi";
|
||||
import ManagerSkin from "./src/services/skinService/managerSkin";
|
||||
import FakeSaverUser from "./src/services/userServices/fakeSaverUser";
|
||||
import LoaderUserApi from "./src/services/userServices/loaderUserApi";
|
||||
import ManagerUser from "./src/services/userServices/managerUser";
|
||||
import SaverUserApi from "./src/services/userServices/saverUserApi";
|
||||
|
||||
export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser);
|
||||
export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation);
|
||||
export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new SaverUserApi);
|
||||
export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new SaverConversationApi);
|
||||
export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi);
|
||||
export const MANAGER_GAME = new ManagerGame(new LoaderGameApi);
|
||||
export const MANAGER_SKIN = new ManagerSkin(new LoaderSkinApi);
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { io } = require("socket.io-client");
|
||||
|
||||
|
||||
export const socket = io("http://192.168.1.25:3000");
|
||||
export const socket = io("http://192.168.1.54:3000");
|
@ -0,0 +1,109 @@
|
||||
import { each } from "jquery";
|
||||
import { MANAGER_USER } from "../../../appManagers";
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { Message } from "../../core/message";
|
||||
import { User } from "../../core/User/user";
|
||||
import ISaverConversation from "./ISaverConversation";
|
||||
|
||||
export class SaverConversationApi implements ISaverConversation{
|
||||
|
||||
private axios = require('axios').default;
|
||||
|
||||
async saveConversation(name: string, user:User, tabId:number[], firstMessage:string, messageDate:Date): Promise<Conversation | null>{
|
||||
|
||||
let conv:Conversation | null=null;
|
||||
let url='http://localhost:8888/api-rest/index.php/postConversation/' + name + "/" +user.getId();
|
||||
tabId.forEach(id => {
|
||||
url=url + "," + id;
|
||||
});
|
||||
await this.axios({
|
||||
method: 'post',
|
||||
url: url,
|
||||
})
|
||||
.then(async (response: any) => {
|
||||
let tabUser:User[]=[];
|
||||
const id=response.data;
|
||||
const message:Message|null=await this.addMessage(id, firstMessage, messageDate, user);
|
||||
let end=new Promise<void>((resolve, reject) => {
|
||||
tabId.forEach(async id => {
|
||||
let tmp:User|null=await MANAGER_USER.getLoaderUser().loadByID(id);
|
||||
if (tmp!=null){
|
||||
tabUser.push(tmp);
|
||||
}
|
||||
if (tabUser.length===tabId.length){
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
await Promise.all([end]);
|
||||
if (message!=null){
|
||||
conv=new Conversation(id, tabUser, [message], name);
|
||||
}
|
||||
});
|
||||
return conv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async addMessage(idConv:number, content: string, messageDate:Date, user: User): Promise<Message | null> {
|
||||
let message:Message | null=null;
|
||||
let url='http://localhost:8888/api-rest/index.php/addMessageToConversation/' + content + "/" + user.getId() + "/" + idConv + "/" + messageDate.toISOString().split('T')[0] + " " + messageDate.getHours() + ":" + messageDate.getMinutes() + ":" + messageDate.getSeconds();
|
||||
await this.axios({
|
||||
method: 'put',
|
||||
url: url,
|
||||
})
|
||||
.then(async (response: any) => {
|
||||
const id=response.data;
|
||||
message=new Message(id, content, user, messageDate);
|
||||
});
|
||||
return message;
|
||||
}
|
||||
|
||||
addUserToConversation(c: Conversation, id: number): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
deleteUserToConversation(c: Conversation, u: User): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
|
||||
async deleteConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
async updateConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function jsonToConversation(response:any) {
|
||||
let conv:Conversation | null=null;
|
||||
const tabUser:User[]=[];
|
||||
const tabMessage:Message[]=[];
|
||||
let first = new Promise<void>((resolve,reject) => {
|
||||
response.data.listIdUsers.forEach(async (id: number) => {
|
||||
const user:User | null= await MANAGER_USER.getLoaderUser().loadByID(id);
|
||||
if (user!=null){
|
||||
tabUser.push(user);
|
||||
}
|
||||
if(response.data.listIdUsers.length===tabUser.length){
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
let second= new Promise<void> ((resolve, reject) => {
|
||||
response.data.tabMessages.forEach(async (message: { idSender: number; id: number; content: string; dateEnvoie: string | number | Date; }) => {
|
||||
const sender:User | null= await MANAGER_USER.getLoaderUser().loadByID(message.idSender);
|
||||
if (sender!=null){
|
||||
tabMessage.push(new Message(message.id, message.content, sender, new Date(message.dateEnvoie)));
|
||||
}
|
||||
if(response.data.tabMessages.length===tabMessage.length){
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
await Promise.all([first, second]);
|
||||
conv = new Conversation(response.data.id, tabUser, tabMessage, response.data.name);
|
||||
return conv;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { Message } from "../../core/message";
|
||||
|
||||
export default interface ILoaderMessage{
|
||||
|
||||
/**
|
||||
* loadAllMessage methode that load every Message from the data management system
|
||||
* return an array of Message
|
||||
*/
|
||||
loadAllMessage(): Promise<Message[]>;
|
||||
|
||||
/**
|
||||
* loadByID methode that load a Message from the data management system by its id
|
||||
* id the id we want to search
|
||||
* return a Message if found, if not null
|
||||
*/
|
||||
loadByID(id:string): Promise<Message | null>;
|
||||
|
||||
/**
|
||||
* loadByUser methode that load an array of Message from the data management system using a Conversation
|
||||
* c the Conversation we want the Messages of
|
||||
* return an array of Message
|
||||
*/
|
||||
loadByConversation(c:Conversation): Promise<Message[]>;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import { Message } from "../../core/message";
|
||||
|
||||
export default interface ISaverMessage{
|
||||
|
||||
/**
|
||||
* saveMessage methode that save a Message in the data management system
|
||||
* m the Message we want to save
|
||||
*/
|
||||
|
||||
saveMessage(m:Message): Promise<void>;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { Skin } from "../../core/skin";
|
||||
|
||||
export default interface ILoaderSkin{
|
||||
|
||||
/**
|
||||
* loadAllSkin methode that load every Skin from the data management system
|
||||
* return an array of Skin
|
||||
*/
|
||||
loadAllSkin(): Promise<Skin[]>;
|
||||
|
||||
/**
|
||||
* loadByID methode that load a Skin from the data management system by its id
|
||||
* id the id we want to search
|
||||
* return a Skin if found, if not null
|
||||
*/
|
||||
loadByID(id:number): Promise<Skin | null>;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import { Skin } from "../../core/skin";
|
||||
import ILoaderSkin from "./ILoaderSkin";
|
||||
|
||||
export default class LoaderSkinApi implements ILoaderSkin{
|
||||
|
||||
private axios = require('axios').default;
|
||||
|
||||
/**
|
||||
* loadAllSkin methode that load every Skin from the data management system
|
||||
* return an array of Skin
|
||||
*/
|
||||
async loadAllSkin(): Promise<Skin[]>{
|
||||
let tabSkin: Skin[]=[];
|
||||
const url='http://localhost:8888/api-rest/index.php/getSkins';
|
||||
await this.axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
})
|
||||
.then(function (response: any) {
|
||||
if (response.data != null && response.data != undefined){
|
||||
response.data.forEach((skins: { id: number; name: string; source: string; cost: number; }) => {
|
||||
tabSkin.push(new Skin(skins.id, skins.name, skins.source, skins.cost));
|
||||
});
|
||||
}
|
||||
});
|
||||
return tabSkin;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadByID methode that load a Skin from the data management system by its id
|
||||
* id the id we want to search
|
||||
* return a Skin if found, if not null
|
||||
*/
|
||||
async loadByID(id:number): Promise<Skin | null>{
|
||||
let skin: Skin | null= null;
|
||||
const url='http://localhost:8888/api-rest/index.php/getSkins';
|
||||
await this.axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
})
|
||||
.then(function (response: any) {
|
||||
if (response.data != null && response.data != undefined){
|
||||
skin=new Skin(response.data.currentSkin.id, response.data.currentSkin.name, response.data.currentSkin.source, response.data.currentSkin.cost);
|
||||
}
|
||||
});
|
||||
return skin;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
import { Skin } from "../../core/skin";
|
||||
import ILoaderSkin from "./ILoaderSkin";
|
||||
|
||||
export default class ManagerSkin{
|
||||
|
||||
private tabSkin: Skin[]=[];
|
||||
|
||||
private loaderSkin: ILoaderSkin;
|
||||
|
||||
constructor(loader:ILoaderSkin){
|
||||
this.loaderSkin=loader;
|
||||
}
|
||||
|
||||
getTabSkin(){
|
||||
return this.tabSkin;
|
||||
}
|
||||
|
||||
setTabSkin(tab:Skin[]){
|
||||
this.tabSkin=tab;
|
||||
}
|
||||
|
||||
getLoaderSkin(){
|
||||
return this.loaderSkin;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
/* This script does:
|
||||
|
||||
* create tables of the database
|
||||
* creates the sequences for the ids(with AUTO_INCREMENT)
|
||||
* create the triggers and trigger functions
|
||||
|
||||
*/
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
/* TABLES' CREATION */
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
/* ----- ENTITIES TABLES -----*/
|
||||
|
||||
/* -- Table User -- */
|
||||
CREATE TABLE T_S_USER_USR (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
USR_USERNAME varchar(50) UNIQUE NOT NULL,
|
||||
USR_PASSWORD varchar(50) NOT NULL,
|
||||
USR_NATIONALITY varchar(20) NOT NULL,
|
||||
USR_SEX char(1) NOT NULL,
|
||||
USR_DATE_OF_BIRTH date,
|
||||
USR_CURRENT_NB_COINS int DEFAULT 0,
|
||||
USR_TOTAL_NB_COINS int DEFAULT 0,
|
||||
USR_NB_GAMES_PLAYED int DEFAULT 0,
|
||||
FK_CURRENT_SKIN int
|
||||
REFERENCES T_H_SKIN_SKI(PK_ID)
|
||||
);
|
||||
|
||||
/* -- Table Skin -- */
|
||||
CREATE TABLE T_H_SKIN_SKI (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
SKI_NAME varchar(50) UNIQUE NOT NULL,
|
||||
SKI_IMAGE varchar(50) UNIQUE NOT NULL,
|
||||
SKI_PRICE varchar(30)
|
||||
);
|
||||
|
||||
/* -- Table Game -- */
|
||||
CREATE TABLE T_E_GAME_GAM (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
GAM_NAME varchar(50) UNIQUE,
|
||||
GAM_IMAGE varchar(50) UNIQUE,
|
||||
GAM_NB_PLAYER_MIN int,
|
||||
GAM_NB_PLAYER_MAX int
|
||||
);
|
||||
|
||||
/* -- Table Match -- */
|
||||
CREATE TABLE T_E_MATCH_MTC (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
MTC_IN_GAME boolean,
|
||||
FK_GAME int
|
||||
REFERENCES T_E_GAME_GAM(PK_ID)
|
||||
);
|
||||
|
||||
/* -- Table Conversation -- */
|
||||
CREATE TABLE T_H_CONVERSATION_COV (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
COV_NAME varchar(20)
|
||||
);
|
||||
|
||||
/* -- Table Message -- */
|
||||
CREATE TABLE T_H_MESSAGE_MSG (
|
||||
PK_ID int AUTO_INCREMENT PRIMARY KEY,
|
||||
MSG_MESSAGE text,
|
||||
FK_SENDER int
|
||||
REFERENCES T_S_USER_USR(PK_ID)
|
||||
);
|
||||
|
||||
/* ----- JUNCTURE TABLES ----- */
|
||||
|
||||
/* -- Juncture own skin -- */
|
||||
CREATE TABLE T_J_OWN_SKIN_OWN (
|
||||
FK_USER int ,
|
||||
FOREIGN KEY (FK_USER)
|
||||
REFERENCES T_S_USER_USR(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
FK_SKIN int ,
|
||||
FOREIGN KEY (FK_SKIN)
|
||||
REFERENCES T_H_SKIN_SKI(PK_ID),
|
||||
PRIMARY KEY(FK_SKIN, FK_USER)
|
||||
);
|
||||
|
||||
/* -- Juncture play match -- */
|
||||
CREATE TABLE T_J_PLAY_MATCH_PLM (
|
||||
FK_USER int ,
|
||||
FOREIGN KEY (FK_USER )
|
||||
REFERENCES T_S_USER_USR(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
FK_MATCH int ,
|
||||
FOREIGN KEY (FK_MATCH)
|
||||
REFERENCES T_E_MATCH_MTC(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
PRIMARY KEY (FK_USER,FK_MATCH)
|
||||
);
|
||||
|
||||
/* -- Juncture discuss -- */
|
||||
CREATE TABLE T_J_DISCUSS_DIS (
|
||||
FK_USER int ,
|
||||
FOREIGN KEY (FK_USER)
|
||||
REFERENCES T_S_USER_USR(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
FK_CONVERSATION int ,
|
||||
FOREIGN KEY (FK_CONVERSATION)
|
||||
REFERENCES T_H_CONVERSATION_COV(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
PRIMARY KEY(FK_USER,FK_CONVERSATION)
|
||||
);
|
||||
|
||||
/* -- Juncture contain message -- */
|
||||
CREATE TABLE T_J_CONTAIN_MESSAGE_CMG (
|
||||
FK_CONVERSATION int,
|
||||
FOREIGN KEY (FK_CONVERSATION)
|
||||
REFERENCES T_H_CONVERSATION_COV(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
FK_MESSAGE int,
|
||||
FOREIGN KEY (FK_MESSAGE)
|
||||
REFERENCES T_H_MESSAGE_MSG(PK_ID)
|
||||
ON DELETE CASCADE,
|
||||
PRIMARY KEY (FK_CONVERSATION,FK_MESSAGE)
|
||||
);
|
||||
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
/* TRIGGERS' CREATION */
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
/* ----- USER's trigger ----- */
|
||||
|
||||
/* -- after insert -> add basic skin into the list of skin -- */
|
||||
CREATE TRIGGER after_insert_user
|
||||
AFTER INSERT
|
||||
ON T_S_USER_USR
|
||||
FOR EACH ROW
|
||||
INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1);
|
||||
|
||||
|
||||
|
||||
/* ----- CONVERSATION's trigger ----- */
|
||||
|
||||
CREATE TRIGGER before_delete_conversation
|
||||
BEFORE DELETE
|
||||
ON T_H_CONVERSATION_COV
|
||||
FOR EACH ROW
|
||||
DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE
|
||||
FROM T_J_CONTAIN_MESSAGE_CMG
|
||||
WHERE FK_CONVERSATION=OLD.PK_ID);
|
Loading…
Reference in new issue