refs #6276 getVersion
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Penadés 2023-11-29 13:22:44 +01:00
parent 133fe1065a
commit 877c679273
6 changed files with 114 additions and 1 deletions

View File

@ -0,0 +1,45 @@
module.exports = Self => {
Self.remoteMethodCtx('getVersion', {
description: 'gets app version data',
accessType: 'READ',
accepts: [{
arg: 'app',
type: 'string',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/getVersion`,
verb: 'GET'
}
});
Self.getVersion = async(ctx, app) => {
const {models} = Self.app;
const userId = ctx.req.accessToken.userId;
const workerFk = await models.WorkerAppTester.findOne({
where: {
workerFk: userId
}
});
let fields = ['id', 'appName'];
if (workerFk)
fields = [...fields, ...['isVersionBetaCritical', 'versionBeta', 'urlBeta']];
else
fields = [...fields, ...['isVersionCritical', 'version', 'urlProduction']];
const filter = {
where: {
appName: app
},
fields,
};
return await Self.findOne(filter);
};
};

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/mobile-app-version-control/getVersion')(Self);
};

View File

@ -0,0 +1,39 @@
{
"name": "MobileAppVersionControl",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.mobileAppVersionControl"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"appName": {
"type": "string"
},
"version": {
"type": "string"
},
"isVersionCritical": {
"type": "boolean"
},
"urlProduction": {
"type": "string"
},
"urlBeta": {
"type": "string"
},
"versionBeta": {
"type": "string"
},
"isVersionBetaCritical": {
"type": "boolean"
}
}
}

View File

@ -2,4 +2,5 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
VALUES
('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
('ExpeditionPallet', 'getPallet', 'READ', 'ALLOW', 'ROLE', 'employee'),
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','employee');
('MachineWorker','updateInTime','WRITE','ALLOW','ROLE','employee'),
('MobileAppVersionControl','getVersion','READ','ALLOW','ROLE','employee');

View File

@ -53,6 +53,9 @@
"Time": {
"dataSource": "vn"
},
"WorkerAppTester": {
"dataSource": "vn"
},
"WorkCenter": {
"dataSource": "vn"
},

View File

@ -0,0 +1,22 @@
{
"name": "WorkerAppTester",
"base": "VnModel",
"options": {
"mysql": {
"table": "vn.workerAppTester"
}
},
"properties": {
"workerFk": {
"id": true,
"type": "number"
}
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
}
}
}