feat(mdb): start section
gitea/salix/pipeline/head This commit is unstable Details

This commit is contained in:
Alex Moreno 2022-05-25 14:59:28 +02:00
parent f66e5fac9e
commit 79c42d04f9
12 changed files with 235 additions and 0 deletions

View File

@ -0,0 +1,14 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES('MdbVersion', '*', '*', 'ALLOW', 'ROLE', 'developer');
CREATE TABLE `vn`.`mdbBranch` (
`name` VARCHAR(255),
PRIMARY KEY(`name`)
);
CREATE TABLE `vn`.`mdbVersion` (
`app` VARCHAR(255) NOT NULL,
`branchFk` VARCHAR(255) NOT NULL,
`version` INT,
CONSTRAINT `mdbVersion_branchFk` FOREIGN KEY (`branchFk`) REFERENCES `vn`.`mdbBranch` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);

View File

@ -2577,3 +2577,12 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
(1106, 2, CURDATE(), NULL),
(1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY));
INSERT INTO `vn`.`mdbBranch` (`name`)
VALUES
('test'),
('master');
INSERT INTO `vn`.`mdbVersion` (`app`, `branchFk`, `version`)
VALUES
('tpv', 'test', '1'),
('lab', 'master', '2');

View File

@ -32,6 +32,7 @@ services:
- /mnt/appdata/pdfs:/var/lib/salix/pdfs
- /mnt/appdata/dms:/var/lib/salix/dms
- /mnt/appdata/image:/var/lib/salix/image
- /mnt/appdata/vn-access:/var/lib/salix/vn-access
deploy:
replicas: ${BACK_REPLICAS:?}
placement:

View File

@ -98,5 +98,25 @@
"image/jpg",
"video/mp4"
]
},
"mdbStorage": {
"name": "mdbStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/mdb",
"maxFileSize": "262144000",
"allowedContentTypes": [
"application/x-7z-compressed",
"application/x-zip-compressed",
"application/x-rar-compressed",
"application/octet-stream",
"application/pdf",
"application/zip",
"application/rar",
"multipart/x-zip",
"image/png",
"image/jpeg",
"image/jpg"
]
}
}

View File

@ -0,0 +1,76 @@
const models = require('vn-loopback/server/server').models;
describe('tag filterValue()', () => {
const colorTagId = 1;
it('should return a list of color values', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {limit: 5};
const result = await models.Tag.filterValue(colorTagId, filter, options);
expect(result.length).toEqual(5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the values matching color "Blue"', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {where: {value: 'Blue'}, limit: 5};
const result = await models.Tag.filterValue(colorTagId, filter, options);
expect(result.length).toEqual(2);
expect(result[0].value).toEqual('Blue');
expect(result[1].value).toEqual('Blue/Silver');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the values matching color "Blue/Silver"', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {where: {value: 'Blue/Silver'}, limit: 5};
const result = await models.Tag.filterValue(colorTagId, filter, options);
expect(result.length).toEqual(1);
expect(result[0].value).toEqual('Blue/Silver');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return the values matching color "Silver"', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const filter = {where: {value: 'Silver'}, limit: 5};
const result = await models.Tag.filterValue(colorTagId, filter, options);
expect(result.length).toEqual(2);
expect(result[0].value).toEqual('Silver');
expect(result[1].value).toEqual('Blue/Silver');
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -0,0 +1,50 @@
module.exports = Self => {
Self.remoteMethodCtx('upload', {
description: 'Returns a list of tag values',
accepts: [
{
arg: 'appName',
type: 'string',
required: true,
description: 'The app name'
},
{
arg: 'newVersion',
type: 'number',
required: true,
description: `The new version number`
},
{
arg: 'branch',
type: 'string',
required: true,
description: `The branch name`
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/upload`,
verb: 'POST'
}
});
Self.upload = async(ctx, appName, newVersion, branch, options) => {
const models = Self.app.models;
const myOptions = {};
const moduleFile = ctx.req;
if (!moduleFile) return;
if (typeof options == 'object')
Object.assign(myOptions, options);
const newMdb = await models.mdbVersion.create({
app: appName,
version: newVersion,
branchFk: branch
}, myOptions);
};
};

View File

@ -0,0 +1,11 @@
{
"MdbBranch": {
"dataSource": "vn"
},
"MdbVersion": {
"dataSource": "vn"
},
"MdbContainer": {
"dataSource": "mdbStorage"
}
}

View File

@ -0,0 +1,10 @@
{
"name": "MdbContainer",
"base": "Container",
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "developer",
"permission": "ALLOW"
}]
}

View File

@ -0,0 +1,16 @@
{
"name": "MdbBranch",
"base": "VnModel",
"options": {
"mysql": {
"table": "mdbBranch"
}
},
"properties": {
"name": {
"id": true,
"type": "string",
"description": "Identifier"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/mdbVersion/upload')(Self);
};

View File

@ -0,0 +1,25 @@
{
"name": "MdbVersion",
"base": "VnModel",
"options": {
"mysql": {
"table": "mdbVersion"
}
},
"properties": {
"app": {
"type": "string",
"description": "The app name"
},
"version": {
"type": "number"
}
},
"relations": {
"branch": {
"type": "belongsTo",
"model": "MdbBranch",
"foreignKey": "name"
}
}
}