diff --git a/.eslintrc.yml b/.eslintrc.yml index fc8c9fb1cf..022c3d6fa6 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -19,4 +19,4 @@ rules: no-eq-null: 0 no-console: 0 no-warning-comments: 0 - no-empty: 0 + no-empty: [error, allowEmptyCatch: true] diff --git a/client/item/src/history/item-history.html b/client/item/src/history/item-history.html index 1a5a654839..fe1c1faf75 100644 --- a/client/item/src/history/item-history.html +++ b/client/item/src/history/item-history.html @@ -1,5 +1,4 @@ - - + Item history @@ -22,12 +21,10 @@ {{::itemLog.description}} - No results - diff --git a/gulpfile.js b/gulpfile.js index 15941c78d0..28f1e37f6f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,16 +1,12 @@ require('require-yaml'); const gulp = require('gulp'); const gutil = require('gulp-util'); -const wrap = require('gulp-wrap'); -const concat = require('gulp-concat'); -const merge = require('merge-stream'); const print = require('gulp-print'); const runSequence = require('run-sequence'); const fs = require('fs-extra'); const webpack = require('webpack'); const WebpackDevServer = require('webpack-dev-server'); const exec = require('child_process').exec; -const path = require('path'); // Configuration @@ -81,9 +77,17 @@ gulp.task('e2e-run', () => { gulp.task('clean', () => { const del = require('del'); - return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true}); + const files = [ + `${buildDir}/*`, + `!${buildDir}/templates`, + `!${buildDir}/images`, + `docker-compose.yml` + ]; + return del(files, {force: true}); }); +gulp.task('i', ['install']); + gulp.task('install', () => { const install = require('gulp-install'); let jsonFile = []; @@ -101,9 +105,6 @@ gulp.task('install', () => { })); }); -// Gulp install alias -gulp.task('i', ['install']); - // Deployment gulp.task('build', ['clean'], () => { @@ -111,9 +112,8 @@ gulp.task('build', ['clean'], () => { }); gulp.task('docker-compose', async () => { - let compose = await fs.readFile('./docker-compose.tpl.yml', 'utf8'); - const yaml = require('js-yaml'); + let compose = await fs.readFile('./docker-compose.tpl.yml', 'utf8'); let composeYml = yaml.safeLoad(compose); let services = await getServices(); @@ -191,9 +191,8 @@ gulp.task('nginx-stop', ['nginx-conf'], async () => { gulp.task('nginx-conf', async () => { const mustache = require('mustache'); - if (!fs.existsSync(nginxTemp)) { - fs.mkdirSync(nginxTemp); - } + if (!await fs.exists(nginxTemp)) + await fs.mkdir(nginxTemp); let params = { services: await getServices(), @@ -220,11 +219,8 @@ gulp.task('nginx-clean', () => { return del([`${nginxTemp}/*`], {force: true}); }); -let services; - async function getServices() { - if (services) return services; - + let services; let startPort = defaultPort + 1; services = []; @@ -290,11 +286,13 @@ gulp.task('webpack-dev-server', function() { // Locale -let localeFiles = `${srcDir}/**/locale/*.json`; +let localeFiles = `${srcDir}/**/locale/*.yml`; gulp.task('locales', function() { const extend = require('gulp-extend'); const yaml = require('gulp-yaml'); + const merge = require('merge-stream'); + let streams = []; for (let mod in modules) @@ -314,6 +312,9 @@ gulp.task('locales', function() { let routeFiles = `${srcDir}/**/routes.json`; gulp.task('routes', function() { + const concat = require('gulp-concat'); + const wrap = require('gulp-wrap'); + return gulp.src(routeFiles) .pipe(concat('routes.js', {newLine: ','})) .pipe(wrap('var routes = [<%=contents%>\n];')) diff --git a/package-lock.json b/package-lock.json index e10725348e..dec836866c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,7 +113,7 @@ "angular": { "version": "1.6.8", "resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz", - "integrity": "sha1-W+N4pYvpGlSJ54tZxFGM2f0nP/s=" + "integrity": "sha512-9WErZIOw1Cu1V5Yxdvxz/6YpND8ntdP71fdPpufPFJvZodZXqCjQBYrHqEoMZreO5i84O3D/Jw/vepoFt68Azw==" }, "angular-cookies": { "version": "1.6.4", @@ -1119,7 +1119,7 @@ "bluebird": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", "dev": true }, "bn.js": { @@ -9909,7 +9909,7 @@ "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", - "integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=", + "integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==", "dev": true, "requires": { "colors": "1.1.2" @@ -10051,7 +10051,7 @@ "karma": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz", - "integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=", + "integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==", "dev": true, "requires": { "bluebird": "3.5.1", @@ -10103,7 +10103,7 @@ "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=", + "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", "dev": true, "requires": { "fs-access": "1.0.1", @@ -10113,7 +10113,7 @@ "karma-firefox-launcher": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz", - "integrity": "sha1-LEcDBFLwRTHrfRPU/HZpYwu5Mzk=", + "integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==", "dev": true }, "karma-jasmine": { @@ -10134,7 +10134,7 @@ "karma-webpack": { "version": "2.0.9", "resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz", - "integrity": "sha1-YciAkffdkQY1E0wDKyZqRlr/tX8=", + "integrity": "sha512-F1j3IG/XhiMzcunAXbWXH95uizjzr3WdTzmVWlta8xqxcCtAu9FByCb4sccIMxaVFAefpgnUW9KlCo0oLvIX6A==", "dev": true, "requires": { "async": "0.9.2", @@ -14654,7 +14654,7 @@ "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", - "integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=", + "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", "dev": true, "requires": { "lru-cache": "4.1.1", diff --git a/services/auth/Dockerfile b/services/auth/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/auth/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/client/Dockerfile b/services/client/Dockerfile new file mode 100644 index 0000000000..b1197d1718 --- /dev/null +++ b/services/client/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] + diff --git a/services/db/00-trucateAll.sql b/services/db/00-trucateAll.sql new file mode 100644 index 0000000000..f7d98056cc --- /dev/null +++ b/services/db/00-trucateAll.sql @@ -0,0 +1,38 @@ +DROP PROCEDURE IF EXISTS mysql.truncateAll; +DELIMITER $$ +CREATE PROCEDURE mysql.truncateAll() +BEGIN + DECLARE vSchema VARCHAR(255); + DECLARE vTable VARCHAR(255); + DECLARE vDone BOOL; + + DECLARE cTables CURSOR FOR + SELECT `TABLE_SCHEMA`, `TABLE_NAME` + FROM `information_schema`.`TABLES` + WHERE `TABLE_TYPE` = 'BASE TABLE' + AND `TABLE_ROWS` > 0 + AND `TABLE_SCHEMA` NOT IN ('information_schema', 'mysql', 'performance_schema'); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SET FOREIGN_KEY_CHECKS = FALSE; + OPEN cTables; + + l: LOOP + SET vDone = FALSE; + FETCH cTables INTO vSchema, vTable; + + IF vDone THEN + LEAVE l; + END IF; + + SET @stmt = CONCAT('TRUNCATE TABLE `', vSchema, '`.`', vTable, '`'); + PREPARE stmt FROM @stmt; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + END LOOP; + + CLOSE cTables; + SET FOREIGN_KEY_CHECKS = TRUE; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/services/db/02-fixtures.sql b/services/db/02-fixtures.sql index 9cf4deeeca..3b51c91fc0 100644 --- a/services/db/02-fixtures.sql +++ b/services/db/02-fixtures.sql @@ -390,16 +390,16 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `defaultAgencyFk`, `longitude`, `latitude`, `isEqualizated`) VALUES - (1, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0), - (2, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0), - (3, 'Clark Kenn', 'The phone box', 'Silla', 46460, 1, NULL, NULL, 1, 1, 3, 2, NULL, NULL, 0), - (4, 'Tony Stark', 'Stark tower', 'Silla', 46460, 1, NULL, NULL, 1, 1, 4, 2, NULL, NULL, 0), - (5, 'Max Eisenhardt', 'The plastic cell', 'Silla', 46460, 1, NULL, NULL, 1, 1, 5, 2, NULL, NULL, 0), - (6, 'David Charles Haller', 'Many places', 'Silla', 46460, 1, NULL, NULL, 1, 1, 6, 2, NULL, NULL, 0), - (7, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0), - (8, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0), - (9, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0), - (10,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0); + (101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0), + (102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0), + (103, 'Clark Kenn', 'The phone box', 'Silla', 46460, 1, NULL, NULL, 1, 1, 3, 2, NULL, NULL, 0), + (104, 'Tony Stark', 'Stark tower', 'Silla', 46460, 1, NULL, NULL, 1, 1, 4, 2, NULL, NULL, 0), + (105, 'Max Eisenhardt', 'The plastic cell', 'Silla', 46460, 1, NULL, NULL, 1, 1, 5, 2, NULL, NULL, 0), + (106, 'David Charles Haller', 'Many places', 'Silla', 46460, 1, NULL, NULL, 1, 1, 6, 2, NULL, NULL, 0), + (107, 'Hank Pym', 'Your pocket', 'Silla', 46460, 1, NULL, NULL, 1, 1, 7, 2, NULL, NULL, 0), + (108, 'Charles Xavier', 'Cerebro', 'Silla', 46460, 1, NULL, NULL, 1, 1, 8, 2, NULL, NULL, 0), + (109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0), + (110,'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0); INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `created`) VALUES @@ -475,16 +475,16 @@ INSERT INTO `vn2008`.`empresa`(`id`, `abbreviation`, `registro`, `gerente_id`, ` INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `clientFk`,`nickname`, `addressFk`) VALUES - (1, 1, 1, NULL, CURDATE(), 1, 'Batman', 1), - (2, 1, 1, NULL, CURDATE(), 1, 'Spider-Man', 2), - (3, 2, 2, NULL, CURDATE(), 2, 'Super-Man', 3), - (4, 2, 2, NULL, CURDATE(), 2, 'Iron-Man', 4), - (5, 3, 3, NULL, CURDATE(), 3, 'Magneto', 5), - (6, 3, 3, NULL, CURDATE(), 3, 'Legion', 6), - (7, 4, 4, NULL, CURDATE(), 4, 'Ant-Man', 7), - (8, 4, 4, NULL, CURDATE(), 4, 'Professor X', 8), - (9, 5, 5, NULL, CURDATE(), 5, 'Hulk', 9), - (10, 6, 5, NULL, CURDATE(), 5, 'Jessica Jones', 10); + (1, 1, 1, NULL, CURDATE(), 1, 'Batman', 101), + (2, 1, 1, NULL, CURDATE(), 1, 'Spider-Man', 102), + (3, 2, 2, NULL, CURDATE(), 2, 'Super-Man', 103), + (4, 2, 2, NULL, CURDATE(), 2, 'Iron-Man', 104), + (5, 3, 3, NULL, CURDATE(), 3, 'Magneto', 105), + (6, 3, 3, NULL, CURDATE(), 3, 'Legion', 106), + (7, 4, 4, NULL, CURDATE(), 4, 'Ant-Man', 107), + (8, 4, 4, NULL, CURDATE(), 4, 'Professor X', 108), + (9, 5, 5, NULL, CURDATE(), 5, 'Hulk', 109), + (10, 6, 5, NULL, CURDATE(), 5, 'Jessica Jones', 110); INSERT INTO `vn`.`ticketTracking`(`id`, `ticketFk`, `stateFk`, `workerFk`, `created`) VALUES diff --git a/services/db/changes/1.0.0/01-agencyMode.sql b/services/db/changes/1.0.0/01-agencyMode.sql new file mode 100644 index 0000000000..5190821c5e --- /dev/null +++ b/services/db/changes/1.0.0/01-agencyMode.sql @@ -0,0 +1,25 @@ +CREATE OR REPLACE + ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`agencyMode` AS + SELECT + `a`.`Id_Agencia` AS `id`, + `a`.`Agencia` AS `name`, + `a`.`description` AS `description`, + `a`.`Vista` AS `deliveryMethodFk`, + `a`.`Vista` AS `__deliveryMethod`, + `a`.`Vista` AS `__view`, + `a`.`m3` AS `m3`, + `a`.`cod71` AS `cod71`, + `a`.`web` AS `web`, + `a`.`agency_id` AS `agencyFk`, + `a`.`agency_id` AS `__agency`, + `a`.`agency_service_id` AS `agencyServiceFk`, + `a`.`agency_service_id` AS `__agencyService`, + `a`.`inflacion` AS `inflation`, + `a`.`inflacion` AS `__inflacion`, + `a`.`is_volumetric` AS `isVolumetric`, + `a`.`send_mail` AS `reportMail` + FROM + `vn2008`.`Agencias` `a` \ No newline at end of file diff --git a/services/db/changes/1.0.0/02-agencyHour.sql b/services/db/changes/1.0.0/02-agencyHour.sql new file mode 100644 index 0000000000..1c3a743f61 --- /dev/null +++ b/services/db/changes/1.0.0/02-agencyHour.sql @@ -0,0 +1,18 @@ +CREATE OR REPLACE + ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`agencyHour` AS + SELECT + `h`.`agency_hour_id` AS `id`, + `h`.`agency_id` AS `agencyFk`, + `h`.`agency_id` AS `__agency`, + `h`.`week_day` AS `weekDay`, + `h`.`warehouse_id` AS `warehouseFk`, + `h`.`warehouse_id` AS `__warehouse`, + `h`.`province_id` AS `provinceFk`, + `h`.`province_id` AS `__province`, + `h`.`subtract_day` AS `substractDay`, + `h`.`max_hour` AS `maxHour` + FROM + `vn2008`.`agency_hour` `h` \ No newline at end of file diff --git a/services/db/changes/1.0.0/03-address.sql b/services/db/changes/1.0.0/03-address.sql new file mode 100644 index 0000000000..bdd27136c9 --- /dev/null +++ b/services/db/changes/1.0.0/03-address.sql @@ -0,0 +1,24 @@ +CREATE OR REPLACE + ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`address` AS + SELECT + `t`.`id_consigna` AS `id`, + `t`.`Id_cliente` AS `clientFk`, + `t`.`domicilio` AS `street`, + `t`.`poblacion` AS `city`, + `t`.`codPostal` AS `postalCode`, + `t`.`province_id` AS `provinceFk`, + `t`.`telefono` AS `phone`, + `t`.`movil` AS `mobile`, + `t`.`consignatario` AS `nickname`, + `t`.`predeterminada` AS `isDefaultAddress`, + `t`.`longitude` AS `longitude`, + `t`.`latitude` AS `latitude`, + `t`.`warehouse_id` AS `warehouseFk`, + `t`.`Id_Agencia` AS `agencyFk`, + `t`.`isEqualizated` AS `isEqualizated`, + `t`.`active` AS `isActive` + FROM + `vn2008`.`Consignatarios` `t` \ No newline at end of file diff --git a/services/db/changes/1.0.0/04-userRole.sql b/services/db/changes/1.0.0/04-userRole.sql new file mode 100644 index 0000000000..b896589bc3 --- /dev/null +++ b/services/db/changes/1.0.0/04-userRole.sql @@ -0,0 +1,36 @@ +USE `account`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `account`.`__userRole` AS + SELECT + `r`.`inheritsFrom` AS `id` + FROM + (`account`.`roleRole` `r` + JOIN `account`.`user` `u` ON ((`u`.`role` = `r`.`role`))) + WHERE + (`u`.`id` = USERGETID()); + +DROP VIEW `account`.`userRole`; + +CREATE TABLE `account`.`userRole` ( + `userFk` INT(10) UNSIGNED NOT NULL, + `roleFk` INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (`userFk`, `roleFk`)); + +ALTER TABLE `account`.`userRole` + ADD INDEX `user` (`userFk` ASC), + ADD INDEX `role` (`roleFk` ASC); + +ALTER TABLE `account`.`userRole` + ADD CONSTRAINT `user` + FOREIGN KEY (`userFk`) + REFERENCES `account`.`user` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD CONSTRAINT `role` + FOREIGN KEY (`roleFk`) + REFERENCES `account`.`role` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; diff --git a/services/db/changes/1.0.0/05-userHasRoleId.sql b/services/db/changes/1.0.0/05-userHasRoleId.sql new file mode 100644 index 0000000000..9d96ff775d --- /dev/null +++ b/services/db/changes/1.0.0/05-userHasRoleId.sql @@ -0,0 +1,31 @@ +DROP function IF EXISTS `userHasRoleId`; +DELIMITER $$ +CREATE DEFINER=`root`@`%` FUNCTION `account`.`userHasRoleId`(vRoleId INT) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** + * Comprueba si el usuario actual tiene asociado un rol. + * + * @param vRoleId Identificador del rol a comprobar + * @return %TRUE si tiene el rol, %FALSE en caso contrario + */ + DECLARE vHasRole BOOL DEFAULT FALSE; + + SELECT COUNT(*) > 0 INTO vHasRole + FROM user u + JOIN roleRole r ON r.role = u.role + WHERE u.id = userGetId() + AND r.inheritsFrom = vRoleId; + + IF NOT vHasRole + THEN + SELECT COUNT(*) > 0 INTO vHasRole + FROM userRole + WHERE userFk = userGetId() + AND roleFk = vRoleId; + END IF; + + RETURN vHasRole; +END$$ +DELIMITER ; + diff --git a/services/item/Dockerfile b/services/item/Dockerfile new file mode 100644 index 0000000000..b1197d1718 --- /dev/null +++ b/services/item/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] + diff --git a/services/item/common/methods/item/getLog.js b/services/item/common/methods/item/getLog.js index 50d563c08b..3b214e5c88 100644 --- a/services/item/common/methods/item/getLog.js +++ b/services/item/common/methods/item/getLog.js @@ -1,27 +1,13 @@ module.exports = Self => { - Self.remoteMethod('itemLog', { - description: 'Returns the item changes log', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }], - returns: { - arg: 'data', - type: ['Object'], - root: true - }, - http: { - path: `/:id/itemLog`, - verb: 'get' - } - }); + Self.installMethod('getLog', filterParams); - Self.itemLog = itemFk => { - let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`; - return Self.rawSql(query, [itemFk]); - }; + function filterParams(params) { + return { + where: { + itemFk: params.itemFk + }, + skip: (params.page - 1) * params.size, + limit: params.size + }; + } }; diff --git a/services/item/common/models/itemLog.js b/services/item/common/models/itemLog.js new file mode 100644 index 0000000000..248cc6abd3 --- /dev/null +++ b/services/item/common/models/itemLog.js @@ -0,0 +1,3 @@ +module.exports = function(Self) { + require('../methods/item/getLog.js')(Self); +}; diff --git a/services/item/common/models/itemLog.json b/services/item/common/models/itemLog.json new file mode 100644 index 0000000000..63777113f5 --- /dev/null +++ b/services/item/common/models/itemLog.json @@ -0,0 +1,35 @@ +{ + "name": "ItemLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemLog", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "creationDate": { + "type": "Date" + }, + "description": { + "type": "String" + } + }, + "relations": { + "originFk": { + "type": "belongsTo", + "model": "Origin", + "foreignKey": "originFk" + }, + "userFk": { + "type": "belongsTo", + "model": "User", + "foreignKey": "userFk" + } + } + } diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index f001fcba12..09eed17357 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -34,5 +34,8 @@ }, "Tag": { "dataSource": "vn" + }, + "ItemLog": { + "dataSource": "vn" } } diff --git a/services/mailer/Dockerfile b/services/mailer/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/mailer/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/print/Dockerfile b/services/print/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/print/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/production/Dockerfile b/services/production/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/production/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/route/Dockerfile b/services/route/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/route/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services/salix/Dockerfile b/services/salix/Dockerfile new file mode 100644 index 0000000000..3264a1c0a1 --- /dev/null +++ b/services/salix/Dockerfile @@ -0,0 +1,11 @@ +FROM node:8.9.4 + +COPY . /app +COPY ../loopback /loopback + +WORKDIR /app + +RUN npm install +RUN npm -g install pm2 + +CMD ["pm2-docker", "./server/server.js"] diff --git a/services_tests.js b/services_tests.js index 0ce8698436..068f8c8f26 100644 --- a/services_tests.js +++ b/services_tests.js @@ -36,4 +36,3 @@ jasmine.addReporter(new SpecReporter({ })); jasmine.execute(); -