fix: refs #6553 workerBusiness, workerDescriptor
gitea/salix/pipeline/pr-test This commit looks good
Details
gitea/salix/pipeline/pr-test This commit looks good
Details
This commit is contained in:
parent
4e9bcf530b
commit
ebfba823b0
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Worker','getWorkerBusiness','READ','ALLOW','ROLE','hr');
|
|
@ -0,0 +1,258 @@
|
|||
const {filter} = require('jszip');
|
||||
const {ContextExclusionPlugin} = require('webpack');
|
||||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getWorkerBusiness', {
|
||||
description: 'Returns an array of business from an specified worker',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The worker id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
|
||||
},
|
||||
{
|
||||
arg: 'started',
|
||||
type: 'date',
|
||||
description: 'started',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'ended',
|
||||
type: 'date',
|
||||
description: 'ended',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'companyCodeFk',
|
||||
type: 'string',
|
||||
description: 'companyCodeFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'reasonEndFk',
|
||||
type: 'number',
|
||||
description: 'reasonEndFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'reasondEnd',
|
||||
type: 'string',
|
||||
description: 'reasondEnd',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'departmentFk',
|
||||
type: 'number',
|
||||
description: 'departmentFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'department',
|
||||
type: 'string',
|
||||
description: 'department',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessProfessionalCategoryFk',
|
||||
type: 'number',
|
||||
description: 'workerBusinessProfessionalCategoryFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessProfessionalCategory',
|
||||
type: 'string',
|
||||
description: 'workerBusinessProfessionalCategory',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'calendarTypeFk',
|
||||
type: 'number',
|
||||
description: 'calendarTypeFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'calendarType',
|
||||
type: 'string',
|
||||
description: 'calendarType',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workcenterFk',
|
||||
type: 'number',
|
||||
description: 'workcenterFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workCenter',
|
||||
type: 'string',
|
||||
description: 'workCenter',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessCategoryFk',
|
||||
type: 'number',
|
||||
description: 'WorkerBusinessCategoryFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessCategory',
|
||||
type: 'string',
|
||||
description: 'workerBusinessCategory',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'occupationCodeFk',
|
||||
type: 'number',
|
||||
description: 'occupationCodeFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'occupationCode',
|
||||
type: 'string',
|
||||
description: 'occupationCode',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'rate',
|
||||
type: 'number',
|
||||
description: 'rate',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessTypeFk',
|
||||
type: 'number',
|
||||
description: 'workerBusinessTypeFk',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'workerBusinessType',
|
||||
type: 'string',
|
||||
description: 'workerBusinessType',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'amount',
|
||||
type: 'number',
|
||||
description: 'amount',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'basicSalary',
|
||||
type: 'number',
|
||||
description: 'amount',
|
||||
http: {source: 'query'}
|
||||
},
|
||||
{
|
||||
arg: 'notes',
|
||||
type: 'string',
|
||||
description: 'notes',
|
||||
http: {source: 'query'}
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: '/:id/getWorkerBusiness',
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getWorkerBusiness = async(ctx, id, filter, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
let conn = Self.dataSource.connector;
|
||||
let where = buildFilter(ctx.args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'started':
|
||||
case 'ended':
|
||||
case 'companyCodeFk':
|
||||
case 'reasonEndFk':
|
||||
case 'reasondEnd':
|
||||
case 'departmentFk':
|
||||
case 'department':
|
||||
case 'workerBusinessProfessionalCategoryFk':
|
||||
case 'workerBusinessProfessionalCategory':
|
||||
case 'calendarTypeFk':
|
||||
case 'calendarType':
|
||||
case 'workcenterFk':
|
||||
case 'workCenter':
|
||||
case 'workerBusinessCategoryFk':
|
||||
case 'workerBusinessCategory':
|
||||
case 'occupationCodeFk':
|
||||
case 'occupationCode':
|
||||
case 'rate':
|
||||
case 'workerBusinessTypeFk':
|
||||
case 'workerBusinessType':
|
||||
case 'amount':
|
||||
case 'basicSalary':
|
||||
case 'notes':
|
||||
}
|
||||
});
|
||||
where = {...where, ...{workerFk: id}};
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
let stmts = [];
|
||||
let stmt;
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT * FROM(
|
||||
SELECT b.id,
|
||||
b.workerFk,
|
||||
b.started,
|
||||
b.ended,
|
||||
b.companyCodeFk,
|
||||
b.reasonEndFk,
|
||||
bre.reason,
|
||||
b.departmentFk,
|
||||
d.name departmentName,
|
||||
b.occupationCodeFk,
|
||||
oc.name occupationName,
|
||||
b.workerBusinessProfessionalCategoryFk,
|
||||
pf.description professionalDescription,
|
||||
b.calendarTypeFk,
|
||||
ct.description calendarTypeDescription,
|
||||
b.workcenterFk,
|
||||
wc.name workCenterName,
|
||||
b.workerBusinessCategoryFk,
|
||||
py.description payrollDescription,
|
||||
b.workerBusinessTypeFk,
|
||||
wt.name workerBusinessTypeName,
|
||||
b.amount,
|
||||
b.basicSalary,
|
||||
b.notes
|
||||
FROM business b
|
||||
LEFT JOIN businessReasonEnd bre ON bre.id = b.reasonEndFk
|
||||
LEFT JOIN occupationCode oc ON oc.code = b.occupationCodeFk
|
||||
LEFT JOIN department d ON d.id = b.departmentFk
|
||||
LEFT JOIN professionalCategory pf ON pf.id = b.workerBusinessProfessionalCategoryFk
|
||||
JOIN calendarType ct ON ct.id = b.calendarTypeFk
|
||||
LEFT JOIN workCenter wc ON wc.id = b.workcenterFk
|
||||
LEFT JOIN payrollCategories py ON py.id = b.workerBusinessCategoryFk
|
||||
LEFT JOIN workerBusinessType wt ON wt.id = b.workerBusinessTypeFk
|
||||
) sub
|
||||
`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
stmts.push(stmt);
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let result = await conn.executeStmt(sql, myOptions);
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -21,6 +21,7 @@ module.exports = Self => {
|
|||
require('../methods/worker/setPassword')(Self);
|
||||
require('../methods/worker/getAvailablePda')(Self);
|
||||
require('../methods/worker/myTeam')(Self);
|
||||
require('../methods/worker/getWorkerBusiness')(Self);
|
||||
|
||||
Self.canModifyAbsenceInPast = async(ctx, time) => {
|
||||
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
|
||||
|
|
Loading…
Reference in New Issue