salix/back/methods/user-config/setUserConfig.js

29 lines
804 B
JavaScript
Raw Normal View History

2018-10-05 11:01:46 +00:00
module.exports = function(Self) {
Self.remoteMethodCtx('setUserConfig', {
description: 'Change worker of tickets state',
accepts: [{
arg: 'params',
type: 'object',
required: true,
description: 'warehouseFk, companyFk',
http: {source: 'body'}
}],
returns: {
arg: 'response',
type: 'object'
},
http: {
path: `/setUserConfig`,
verb: 'post'
}
});
Self.setUserConfig = async(ctx, params) => {
let token = ctx.req.accessToken;
let currentUserId = token && token.userId;
params.userFk = currentUserId;
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
}
};