#6276 createNewWarehouse methods migrated from silex to salix #1850

Merged
jorgep merged 158 commits from 6276-createNewWarehouse into dev 2024-03-06 11:32:11 +00:00
3 changed files with 24 additions and 1 deletions
Showing only changes of commit d0975f0acd - Show all commits

View File

View File

@ -0,0 +1,21 @@
module.exports = Self => {
Self.remoteMethodCtx('add', {
description: 'Add a new operator',
accessType: 'WRITE',
http: {
path: `/add`,
verb: 'POST'
}
});
Self.add = async ctx => {
const userId = ctx.req.accessToken.userId;
// He visto findOrCreate pero no funciona
const user = await Self.findById(userId);
if (!user) {
await Self.create({
workerFk: userId
});
}
};
};

View File

@ -1,4 +1,6 @@
module.exports = function(Self) {
module.exports = Self => {
require('../methods/operator/add')(Self);
Self.observe('after save', async function(ctx) {
const instance = ctx.data || ctx.instance;
const models = Self.app.models;