aa
This commit is contained in:
parent
4f8e9bcaff
commit
024835ec58
@ -131,6 +131,11 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
// },
|
// },
|
||||||
// as: { singular: 'multimedia', plural: 'multimedias' }});
|
// as: { singular: 'multimedia', plural: 'multimedias' }});
|
||||||
|
|
||||||
|
Event.Multimedias = Event.hasMany(models.Multimedia, {
|
||||||
|
foreignKey: 'entityId',
|
||||||
|
as: { singular: 'multimedia', plural: 'multimedias' }
|
||||||
|
});
|
||||||
|
|
||||||
Event.Reservations = Event.hasMany(models.EventReservation, { foreignKey: 'eventId', as: "reservations" });
|
Event.Reservations = Event.hasMany(models.EventReservation, { foreignKey: 'eventId', as: "reservations" });
|
||||||
Event.Inscriptions = Event.hasMany(models.EventInscription, { foreignKey: 'eventId', as: "inscriptions" });
|
Event.Inscriptions = Event.hasMany(models.EventInscription, { foreignKey: 'eventId', as: "inscriptions" });
|
||||||
Event.Questions = Event.hasMany(models.EventQuestion, { foreignKey: 'eventId', as: "questions" });
|
Event.Questions = Event.hasMany(models.EventQuestion, { foreignKey: 'eventId', as: "questions" });
|
||||||
@ -152,6 +157,20 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Event.addScope('includeMultimedias', () => {
|
||||||
|
return {
|
||||||
|
include: [{
|
||||||
|
model: sequelize.models.Multimedia,
|
||||||
|
as: 'multimedias',
|
||||||
|
required: false,
|
||||||
|
include : [{
|
||||||
|
model: sequelize.models.MultimediaFile,
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Event.addScope('includeSpeakers', () => {
|
Event.addScope('includeSpeakers', () => {
|
||||||
return {
|
return {
|
||||||
include: [{
|
include: [{
|
||||||
@ -164,9 +183,11 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
include: [{
|
include: [{
|
||||||
model: sequelize.models.Speaker,
|
model: sequelize.models.Speaker,
|
||||||
as: 'speaker',
|
as: 'speaker',
|
||||||
|
required: false,
|
||||||
include : [{
|
include : [{
|
||||||
model: sequelize.models.Multimedia,
|
model: sequelize.models.Multimedia,
|
||||||
as: 'multimedias',
|
as: 'multimedias',
|
||||||
|
required: false,
|
||||||
include: [{
|
include: [{
|
||||||
model: sequelize.models.MultimediaFile,
|
model: sequelize.models.MultimediaFile,
|
||||||
}]
|
}]
|
||||||
|
|||||||
@ -37,11 +37,11 @@ routes.get('/events/next',
|
|||||||
PaginateMiddleware.middleware(),
|
PaginateMiddleware.middleware(),
|
||||||
SortMiddleware.middleware({ default: "init_available_date" }),
|
SortMiddleware.middleware({ default: "init_available_date" }),
|
||||||
eventController.find({
|
eventController.find({
|
||||||
scopes: ['defaultScope', 'next', 'includeVenue', 'includeSpeakers'],
|
scopes: ['defaultScope', 'next', 'includeVenue', 'includeMultimedias', 'includeSpeakers'],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
routes.get('/events/past',
|
routes.get('/events/pass',
|
||||||
//isLoggedUser,
|
//isLoggedUser,
|
||||||
FieldMiddleware.middleware({
|
FieldMiddleware.middleware({
|
||||||
invalidFields: generalInvalidFields
|
invalidFields: generalInvalidFields
|
||||||
@ -49,7 +49,7 @@ routes.get('/events/past',
|
|||||||
PaginateMiddleware.middleware(),
|
PaginateMiddleware.middleware(),
|
||||||
SortMiddleware.middleware({ default: "-init_date" }),
|
SortMiddleware.middleware({ default: "-init_date" }),
|
||||||
eventController.find({
|
eventController.find({
|
||||||
scopes: ['defaultScope', 'past', 'includeVenue', 'includeSpeakers'],
|
scopes: ['defaultScope', 'past', 'includeVenue', 'includeMultimedias', 'includeSpeakers'],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,7 @@ const models = require('../../core/models');
|
|||||||
|
|
||||||
const extraMethods = {
|
const extraMethods = {
|
||||||
afterFetchAll: (result, params, context) => {
|
afterFetchAll: (result, params, context) => {
|
||||||
return result;
|
|
||||||
/*
|
|
||||||
if (!result.count) {
|
if (!result.count) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -21,7 +20,13 @@ const extraMethods = {
|
|||||||
rows = rows.map(event => Object.assign({},
|
rows = rows.map(event => Object.assign({},
|
||||||
event,
|
event,
|
||||||
{ details: undefined },
|
{ details: undefined },
|
||||||
{ speakers: event.details.map(details => ({ ...details.speaker, order: details.order }) ) }
|
{ speakers: event.details.map((details) => {
|
||||||
|
const multimedias = details.speaker.multimedias.map((multimedias) => {
|
||||||
|
return {...multimedias, ...multimedias.MultimediaFile, MultimediaFile: undefined };
|
||||||
|
});
|
||||||
|
const data = { ...details.speaker, order: details.order, multimedias: multimedias };
|
||||||
|
return data;
|
||||||
|
} ) }
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +34,6 @@ const extraMethods = {
|
|||||||
count: rows.length,
|
count: rows.length,
|
||||||
rows: rows
|
rows: rows
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,9 +13,8 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
description: {
|
description: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
},
|
},
|
||||||
typeId: {
|
type: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.STRING,
|
||||||
foreignKey: true,
|
|
||||||
},
|
},
|
||||||
provider: {
|
provider: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
@ -37,9 +36,7 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
MultimediaFile.associate = function (models) {
|
MultimediaFile.associate = function (models) {
|
||||||
MultimediaFile.MultimediaType = MultimediaFile.belongsTo(models.MultimediaType, { foreignKey: 'typeId' });
|
|
||||||
MultimediaFile.UserCreate = MultimediaFile.belongsTo(models.User, { foreignKey: 'userId' });
|
MultimediaFile.UserCreate = MultimediaFile.belongsTo(models.User, { foreignKey: 'userId' });
|
||||||
|
|
||||||
MultimediaFile.Multimedias = MultimediaFile.hasMany(models.Multimedia, { foreignKey: 'multimediafileId' });
|
MultimediaFile.Multimedias = MultimediaFile.hasMany(models.Multimedia, { foreignKey: 'multimediafileId' });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const generateControllers = require('../../core/controllers');
|
|
||||||
const multimediaTypeService = require('./multimedia_types.service');
|
|
||||||
|
|
||||||
|
|
||||||
// Module Name
|
|
||||||
const MODULE_NAME = '[multimedia_types.controller]';
|
|
||||||
|
|
||||||
const controllerOptions = { MODULE_NAME };
|
|
||||||
const extraControllers = {};
|
|
||||||
|
|
||||||
module.exports = generateControllers(multimediaTypeService, extraControllers, controllerOptions);
|
|
||||||
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = function (sequelize, DataTypes) {
|
|
||||||
const MultimediaType = sequelize.define('MultimediaType', {
|
|
||||||
id: {
|
|
||||||
type: DataTypes.UUID,
|
|
||||||
defaultValue: DataTypes.UUIDV4,
|
|
||||||
primaryKey: true,
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
tableName: 'multimedia_types',
|
|
||||||
freezeTableName: true,
|
|
||||||
timestamps: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
MultimediaType.associate = function (models) {
|
|
||||||
MultimediaType.MultimediasFiles = MultimediaType.hasMany(models.MultimediaFile, { foreignKey: 'typeId' });
|
|
||||||
};
|
|
||||||
|
|
||||||
return MultimediaType;
|
|
||||||
};
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
const routes = require('express').Router();
|
|
||||||
|
|
||||||
const { isAdministratorUser, isLoggedUser } = require('../../middlewares/accessValidator');
|
|
||||||
const SchemaValidator = require('../../middlewares/schemaValidator');
|
|
||||||
|
|
||||||
/*const PaginateMiddleware = require('../../middlewares/paginate');
|
|
||||||
const FieldMiddleware = require('../../middlewares/fields');*/
|
|
||||||
//const SortMiddleware = require('../../middlewares/sort');
|
|
||||||
|
|
||||||
const MultimediaTypesValidation = require('./multimedia_types.validations');
|
|
||||||
const MultimediaTypesController = require('./multimedia_types.controller');
|
|
||||||
|
|
||||||
//routes.get('/venues', true, SortMiddleware.middleware({ default: "name" }), venueController.find);
|
|
||||||
//routes.get('/venues', isLoggedUser, SortMiddleware.middleware({ default: "name" }), venueController.find);
|
|
||||||
//routes.get('/venues/:id', isLoggedUser, venueController.findOne);
|
|
||||||
|
|
||||||
routes.post('/multimediaTypes/', SchemaValidator(MultimediaTypesValidation.MultimediaTypesInputType, true), MultimediaTypesController.create);
|
|
||||||
//routes.put('/venues/:id', isAdministratorUser, venueController.update);
|
|
||||||
//routes.delete('/venues/:id', isAdministratorUser, venueController.delete);
|
|
||||||
|
|
||||||
module.exports = routes;
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/* global MultimediaType */
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const _ = require('lodash');
|
|
||||||
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
|
|
||||||
const models = require('../../core/models');
|
|
||||||
|
|
||||||
const extraMethods = {};
|
|
||||||
|
|
||||||
module.exports = generateService(models.MultimediaType, extraMethods);
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
const Joi = require('joi');
|
|
||||||
|
|
||||||
const MultimediaTypesInputType = Joi.object().keys({
|
|
||||||
name: Joi.string().required(),
|
|
||||||
description: Joi.string().optional(),
|
|
||||||
});
|
|
||||||
/*
|
|
||||||
const MultimediaTypesOutputType = Joi.object().keys({
|
|
||||||
name: Joi.string().required(),
|
|
||||||
description: Joi.string().optional(),
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
MultimediaTypesInputType,
|
|
||||||
// MultimediaTypesOutputType
|
|
||||||
};
|
|
||||||
@ -51,6 +51,12 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
tableName: 'speakers',
|
tableName: 'speakers',
|
||||||
freezeTableName: true,
|
freezeTableName: true,
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
|
|
||||||
|
defaultScope: {
|
||||||
|
where: {
|
||||||
|
state: 'publish'
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Speaker.associate = function (models) {
|
Speaker.associate = function (models) {
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
Cargar
|
Cargar
|
||||||
script-carga-bd-users.sql
|
script-carga-bd-users.sql
|
||||||
script-carga-bd-event_types.sql
|
script-carga-bd-event_types.sql
|
||||||
script-carga-bd-multimedia_types.sql
|
|
||||||
script-carga-bd-values.sql
|
script-carga-bd-values.sql
|
||||||
script-carga-bd-venues.sql
|
script-carga-bd-venues.sql
|
||||||
script-carga-bd-envents_venues_aux.sql
|
script-carga-bd-envents_venues_aux.sql
|
||||||
@ -12,8 +11,8 @@ script-carga-bd-entidades.sql
|
|||||||
insert into lqdvi_v2.entities_entities_types (entityid, typeid, createdAt, updatedAt)
|
insert into lqdvi_v2.entities_entities_types (entityid, typeid, createdAt, updatedAt)
|
||||||
select id, '76b17163-a167-11e9-a57c-000c295f0f58', now(), now() from `entities`
|
select id, '76b17163-a167-11e9-a57c-000c295f0f58', now(), now() from `entities`
|
||||||
|
|
||||||
insert into lqdvi_v2.`multimedia_files` (id, name, description, typeid, provider, code, url, createdAt, userId, updatedAt)
|
insert into lqdvi_v2.`multimedia_files` (id, name, description, type, provider, code, url, createdAt, userId, updatedAt)
|
||||||
SELECT a.id, a.title, a.description, '166fb0aa-5182-4d22-addd-818337194cd7', a.provider, a.code, a.url, a.created, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now()
|
SELECT a.id, a.title, a.description, 'video', a.provider, a.code, a.url, a.created, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now()
|
||||||
FROM lqdvi.`video` as a;
|
FROM lqdvi.`video` as a;
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +28,7 @@ set e.venueID = (select a.venueID from envents_venues_aux a where a.eventID = e.
|
|||||||
|
|
||||||
insert into lqdvi_v2.speakers
|
insert into lqdvi_v2.speakers
|
||||||
(id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, state, typeId, userId, createdAt, updatedAt)
|
(id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, state, typeId, userId, createdAt, updatedAt)
|
||||||
SELECT id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, 'publicado', 1, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now()
|
SELECT id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, 'publish', 1, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now()
|
||||||
FROM lqdvi.speaker;
|
FROM lqdvi.speaker;
|
||||||
|
|
||||||
insert into lqdvi_v2.speakers_values (speakerid, valueId, createdAt, updatedAt)
|
insert into lqdvi_v2.speakers_values (speakerid, valueId, createdAt, updatedAt)
|
||||||
@ -48,20 +47,20 @@ FROM lqdvi.`conference`
|
|||||||
where resume in (select id from lqdvi_v2.multimedia_files);
|
where resume in (select id from lqdvi_v2.multimedia_files);
|
||||||
|
|
||||||
//insertamos las imagenes de los ponentes
|
//insertamos las imagenes de los ponentes
|
||||||
insert into lqdvi_v2.multimedia_files (id, name, description, typeId, provider, url, userId, createdAt, updatedAt)
|
insert into lqdvi_v2.multimedia_files (id, name, description, type, provider, url, userId, createdAt, updatedAt)
|
||||||
SELECT UUID() as ID, concat(name, ' - picture'), id as speakerId, '14c3810c-aca0-440a-b597-f72a7ceb59dc', 'cdn', picture, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
|
SELECT UUID() as ID, concat(name, ' - picture'), id as speakerId, 'picture', 'cdn', picture, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
|
||||||
where picture is not null;
|
where picture is not null;
|
||||||
|
|
||||||
insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
|
insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
|
||||||
SELECT UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'picture-speaker', now(), now() FROM lqdvi_v2.multimedia_files
|
SELECT UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'avatar', now(), now() FROM lqdvi_v2.multimedia_files
|
||||||
where name like '%picture%';
|
where name like '%picture%';
|
||||||
|
|
||||||
insert into lqdvi_v2.multimedia_files (id, name, description, typeId, provider, url, userId, createdAt, updatedAt)
|
insert into lqdvi_v2.multimedia_files (id, name, description, type, provider, url, userId, createdAt, updatedAt)
|
||||||
SELECT UUID() as ID, concat(name, ' - wallpaper'), id as speakerId, '14c3810c-aca0-440a-b597-f72a7ceb59dc', 'cdn', wallpaper, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
|
SELECT UUID() as ID, concat(name, ' - wallpaper'), id as speakerId, 'picture', 'cdn', wallpaper, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
|
||||||
where wallpaper is not null;
|
where wallpaper is not null;
|
||||||
|
|
||||||
insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
|
insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
|
||||||
SELECT UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'wallpaper-speaker', now(), now() FROM lqdvi_v2.multimedia_files
|
SELECT UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'wallpaper', now(), now() FROM lqdvi_v2.multimedia_files
|
||||||
where name like '%wallpaper%';
|
where name like '%wallpaper%';
|
||||||
|
|
||||||
insert into lqdvi_v2.`multimedias` (id, entityId, entityName, multimediafileId, type, createdAt, updatedAt)
|
insert into lqdvi_v2.`multimedias` (id, entityId, entityName, multimediafileId, type, createdAt, updatedAt)
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
-- MySQL dump 10.13 Distrib 5.7.26, for Linux (x86_64)
|
|
||||||
--
|
|
||||||
-- Host: localhost Database: lqdvi_v2
|
|
||||||
-- ------------------------------------------------------
|
|
||||||
-- Server version 5.7.26-0ubuntu0.16.04.1
|
|
||||||
|
|
||||||
/*!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 utf8 */;
|
|
||||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
||||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
|
||||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
|
||||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Dumping data for table `multimedia_types`
|
|
||||||
--
|
|
||||||
|
|
||||||
LOCK TABLES `multimedia_types` WRITE;
|
|
||||||
/*!40000 ALTER TABLE `multimedia_types` DISABLE KEYS */;
|
|
||||||
INSERT INTO `multimedia_types` VALUES ('14c3810c-aca0-440a-b597-f72a7ceb59dc','picture - Imagen','JPG / PNG','2019-07-04 16:42:29','2019-07-04 16:42:29'),('166fb0aa-5182-4d22-addd-818337194cd7','Video','Video de Vimeo o Youtube','2019-06-24 11:27:59','2019-06-24 11:27:59'),('574c8977-5578-4b5c-b093-6db791132daa','PodCast','PodCast de','2019-06-24 11:30:04','2019-06-24 11:30:04');
|
|
||||||
/*!40000 ALTER TABLE `multimedia_types` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
|
||||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
|
||||||
/*!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 */;
|
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
|
||||||
|
|
||||||
-- Dump completed on 2019-07-04 18:52:59
|
|
||||||
Loading…
Reference in New Issue
Block a user