Skip to content

Commit

Permalink
Merge branch 'dev' into s05PartageVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony97421 authored Jan 25, 2024
2 parents a63c6b1 + c90f81c commit 34d7b70
Show file tree
Hide file tree
Showing 50 changed files with 233 additions and 290 deletions.
6 changes: 3 additions & 3 deletions backend/database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ DROP TABLE IF EXISTS `Film`;
CREATE TABLE
`Film` (
`id` INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
`miniature_url` VARCHAR(255) NOT NULL,
`miniature_url` VARCHAR(255),
`miniature_filename` VARCHAR(255),
`cover_url` VARCHAR(255) NOT NULL,
`cover_url` VARCHAR(255),
`cover_filename` VARCHAR(255),
`title` VARCHAR(255) NOT NULL,
`videoUrl` VARCHAR(255),
`videoUrl` VARCHAR(255) NOT NULL,
`duration` INT NOT NULL,
`year` VARCHAR(4) NOT NULL,
`description` VARCHAR(700) NOT NULL,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 2 additions & 2 deletions backend/src/controllers/categorieParFilmControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const browseFilmsForSpecificCategorie = async (request, response, next) => {
try {
// Fetch all items from the database
const films =
await tables.Categorie_par_film.readAllFilmsForSpecificCategorie(
await tables.categorie_par_film.readAllFilmsForSpecificCategorie(
request.params.id
);

Expand All @@ -23,7 +23,7 @@ const destroy = async (req, response, next) => {
const { id } = req.params;
try {
// Delete the item from the database
const result = await tables.Categorie_par_film.delete({
const result = await tables.categorie_par_film.delete({
id,
});

Expand Down
14 changes: 7 additions & 7 deletions backend/src/controllers/filmControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const tables = require("../tables");

const browse = async (req, res, next) => {
try {
const films = await tables.Film.readAll();
const films = await tables.film.readAll();
res.json(films);
} catch (err) {
next(err);
Expand All @@ -11,7 +11,7 @@ const browse = async (req, res, next) => {

const read = async (req, res, next) => {
try {
const film = await tables.Film.read(req.params.id);
const film = await tables.film.read(req.params.id);
if (film == null) {
res.sendStatus(404);
} else {
Expand All @@ -26,7 +26,7 @@ const edit = async (req, res, next) => {
const { id } = req.params;
req.body.id = id;
try {
const result = await tables.Film.update(req.body);
const result = await tables.film.update(req.body);
if (result) {
// res.json(result);
res.sendStatus(204);
Expand All @@ -42,8 +42,8 @@ const add = async (req, res, next) => {
if (req.body.images.length === 2) {
const miniature = req.body.images[0];
const cover = req.body.images[1];
req.body.urlImage = miniature;
req.body.cover = cover;
req.body.miniature_filename = miniature;
req.body.cover_filename = cover;
} else {
res.status(403).send({ message: "Fichier manquant" });
}
Expand Down Expand Up @@ -83,7 +83,7 @@ const add = async (req, res, next) => {
} else {
res
.status(500)
.send({ message: "Erreur lors de l'insertion du categories" });
.send({ message: "Erreur lors de l'insertion de la categorie" });
}
} else {
res.status(500).send({ message: "Erreur lors de l'insertion du film" });
Expand All @@ -96,7 +96,7 @@ const add = async (req, res, next) => {
const destroy = async (req, res, next) => {
const { id } = req.params;
try {
const [result] = await tables.Film.delete(id);
const [result] = await tables.film.delete(id);
if (result.affectedRows) {
res.sendStatus(200);
} else {
Expand Down
52 changes: 46 additions & 6 deletions backend/src/models/CategorieParFilmManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,52 @@ class CategorieParFilmManager extends AbstractManager {
constructor() {
// Call the constructor of the parent class (AbstractManager)
// and pass the table name "categorieParFilm" as configuration
super({ table: "Categorie_par_film" });
super({ table: "categorie_par_film" });
}

// The C of CRUD - Create operation
async create({ filmId, categoriesIds }) {
// prepa querySQLString et array de dependances
let querySQL = `insert into ${this.table} (filmId, categorieId, unique_key) values`;
const arrDep = [];

categoriesIds.forEach((catId, index) => {
const unique_key = `${filmId}-${catId}`;
if (index === 0) querySQL += " (?, ?, ?)";
else querySQL += ", (?, ?, ?)";

arrDep.push(filmId, catId, unique_key);
});
// console.log("querySQL =>", querySQL);
// console.log("arrDep =>", arrDep);

// Execute the SQL INSERT query to add a new categorieParFilm to the "categorieParFilm" table
const result = await this.database.query(`${querySQL};`, arrDep);

// Return the ID of the newly inserted categorieParFilm
return result;
}

async readAll() {
// Execute the SQL SELECT query to retrieve all categories from the "categorie" table
const [rows] = await this.database.query(
`SELECT f.title, c.name FROM ${this.table} fc INNER JOIN categorie c ON c.id = fc.categorieId INNER JOIN film f ON f.id = fc.filmId `
);
// Return the array of categories
return rows;
}

// The Rs of CRUD - Read operations
// ? get all categories for a specific film
async readAllCategoriesForSpecificFilm(idFilm) {
// Execute the SQL SELECT query to retrieve all categories from the "categorie" table
const [rows] = await this.database.query(
`select categorie.name from categorie inner join ${this.table} on categorie.id = ${this.table}.categorieId where ${this.table}.filmId = ?`,
[idFilm]
);
// Return the array of categories
return rows;
}

// ? get all films for a specific categorie
async readAllFilmsForSpecificCategorie(idCategorie) {
Expand All @@ -22,18 +62,18 @@ class CategorieParFilmManager extends AbstractManager {
return rows;
}

async delete({ id }) {
// The D of CRUD - Delete operation

async delete({ filmId, categorieId }) {
// Execute the SQL DELETE query to remove an categorieParFilm by its ID
const [result] = await this.database.query(
`delete from ${this.table} where filmId = ?`,
[id]
`delete from ${this.table} where filmId = ? and categorieId = ?`,
[filmId, categorieId]
);

// Return the number of affected rows
return result;
}

// The D of CRUD - Delete operation
}

// Ready to export the manager
Expand Down
8 changes: 2 additions & 6 deletions backend/src/models/FilmManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ const AbstractManager = require("./AbstractManager");

class FilmManager extends AbstractManager {
constructor() {
super({ table: "Film" });
super({ table: "film" });
}

async create({
miniature_url,
miniature_filename,
cover_url,
cover_filename,
title,
videoUrl,
Expand All @@ -18,11 +16,9 @@ class FilmManager extends AbstractManager {
isAvailable,
}) {
const [result] = await this.database.query(
`insert into ${this.table} (miniature_url, miniature_filename, cover_url, cover_filename, title, videoUrl, duration, year, description, isAvailable) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
`insert into ${this.table} (miniature_filename, cover_filename, title, videoUrl, duration, year, description, isAvailable) values (?, ?, ?, ?, ?, ?, ?, ?)`,
[
miniature_url,
miniature_filename,
cover_url,
cover_filename,
title,
videoUrl,
Expand Down
24 changes: 12 additions & 12 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added frontend/src/assets/icons/pub_spotify.jpg
Loading

0 comments on commit 34d7b70

Please sign in to comment.