#1188 item.index filtering doesnt work for some params
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
80ebf671e8
commit
7f10a509e0
|
@ -23,6 +23,11 @@ module.exports = Self => {
|
|||
type: 'String',
|
||||
description: `If it's and integer searchs by id, otherwise it searchs by name`,
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'id',
|
||||
type: 'Integer',
|
||||
description: 'Item id',
|
||||
http: {source: 'query'}
|
||||
}, {
|
||||
arg: 'categoryFk',
|
||||
type: 'Integer',
|
||||
|
@ -71,7 +76,7 @@ module.exports = Self => {
|
|||
case 'categoryFk':
|
||||
return {'ic.id': value};
|
||||
case 'typeFk':
|
||||
return {'t.id': value};
|
||||
return {'i.typeFk': value};
|
||||
case 'isActive':
|
||||
return {'i.isActive': value};
|
||||
}
|
||||
|
@ -96,10 +101,10 @@ module.exports = Self => {
|
|||
ic.name AS category, i.density, tc.description AS taxClass,
|
||||
b.grouping, b.packing
|
||||
FROM item i
|
||||
JOIN itemType t ON t.id = i.typeFk
|
||||
LEFT JOIN itemType t ON t.id = i.typeFk
|
||||
LEFT JOIN itemCategory ic ON ic.id = t.categoryFk
|
||||
JOIN worker w ON w.id = t.workerFk
|
||||
JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN worker w ON w.id = t.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.userFk
|
||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||
LEFT JOIN producer pr ON pr.id = i.producerFk
|
||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||
|
@ -118,17 +123,26 @@ module.exports = Self => {
|
|||
|
||||
if (ctx.args.tags) {
|
||||
let i = 1;
|
||||
for (let tag of ctx.args.tags) {
|
||||
if (tag.value == null) continue;
|
||||
let tAlias = `it${i++}`;
|
||||
stmt.merge({
|
||||
sql: `JOIN itemTag ${tAlias} ON ${tAlias}.itemFk = i.id
|
||||
AND ${tAlias}.tagFk = ?
|
||||
AND ${tAlias}.value = ?`,
|
||||
params: [tag.tagFk, tag.value]
|
||||
});
|
||||
for (const tag of ctx.args.tags) {
|
||||
const tAlias = `it${i++}`;
|
||||
|
||||
if (tag.tagFk) {
|
||||
stmt.merge({
|
||||
sql: `JOIN vn.itemTag ${tAlias} ON ${tAlias}.itemFk = i.id
|
||||
AND ${tAlias}.tagFk = ?
|
||||
AND ${tAlias}.value LIKE ?`,
|
||||
params: [tag.tagFk, `%${tag.value}%`],
|
||||
});
|
||||
} else {
|
||||
stmt.merge({
|
||||
sql: `JOIN vn.itemTag ${tAlias} ON ${tAlias}.itemFk = i.id
|
||||
AND ${tAlias}.value LIKE ?`,
|
||||
params: [`%${tag.value}%`],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
let itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue