8032-devToTest_2440 #3009

Merged
alexm merged 262 commits from 8032-devToTest_2440 into test 2024-09-24 09:34:49 +00:00
1 changed files with 14 additions and 8 deletions
Showing only changes of commit 7870416860 - Show all commits

View File

@ -9,7 +9,13 @@ module.exports = Self => {
arg: 'androidId', arg: 'androidId',
type: 'String', type: 'String',
description: 'Android id' description: 'Android id'
}, { },
{
arg: 'deviceId',
type: 'String',
description: 'Device id'
},
{
arg: 'versionApp', arg: 'versionApp',
type: 'String', type: 'String',
description: 'Version app' description: 'Version app'
@ -30,9 +36,10 @@ module.exports = Self => {
} }
}); });
Self.handleUser = async(ctx, android_id, versionApp, nameApp, options) => { Self.handleUser = async(ctx, androidId, deviceId, versionApp, nameApp, options) => {
const models = Self.app.models; const models = Self.app.models;
const myOptions = {}; const myOptions = {};
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
@ -41,7 +48,7 @@ module.exports = Self => {
const [[{vIsAuthorized, vMessage}]] = const [[{vIsAuthorized, vMessage}]] =
await Self.rawSql('CALL vn.device_checkLogin(?, ?);', await Self.rawSql('CALL vn.device_checkLogin(?, ?);',
[user.id, android_id], myOptions); [user.id, androidId], myOptions);
if (!vIsAuthorized) if (!vIsAuthorized)
throw new UserError('Not authorized'); throw new UserError('Not authorized');
@ -55,18 +62,17 @@ module.exports = Self => {
if (!isUserInOperator) if (!isUserInOperator)
await models.Operator.create({'workerFk': user.id}); await models.Operator.create({'workerFk': user.id});
const serialNumber = (await models.DeviceProduction.findOne({ const whereCondition = deviceId ? {id: deviceId} : {android_id: androidId};
where: {android_id: android_id} const serialNumber =
}, myOptions))?.serialNumber ?? ''; (await models.DeviceProduction.findOne({where: whereCondition}, myOptions))?.serialNumber ?? '';
await models.DeviceLog.create({ await models.DeviceLog.create({
'android_id': android_id, 'android_id': androidId,
'userFk': user.id, 'userFk': user.id,
'nameApp': nameApp, 'nameApp': nameApp,
'versionApp': versionApp, 'versionApp': versionApp,
'serialNumber': serialNumber 'serialNumber': serialNumber
}, myOptions); }, myOptions);
// ctx.req.accessToken = {userId};
const getDataUser = await models.VnUser.getCurrentUserData(ctx); const getDataUser = await models.VnUser.getCurrentUserData(ctx);
const getDataOperator = await models.Operator.findOne({ const getDataOperator = await models.Operator.findOne({