diff --git a/client/item/src/history/item-history.html b/client/item/src/history/item-history.html index 1a5a65483..fe1c1faf7 100644 --- a/client/item/src/history/item-history.html +++ b/client/item/src/history/item-history.html @@ -1,5 +1,4 @@ - - + Item history @@ -22,12 +21,10 @@ {{::itemLog.description}} - No results - diff --git a/services/item/common/methods/item/getLog.js b/services/item/common/methods/item/getLog.js index 50d563c08..3b214e5c8 100644 --- a/services/item/common/methods/item/getLog.js +++ b/services/item/common/methods/item/getLog.js @@ -1,27 +1,13 @@ module.exports = Self => { - Self.remoteMethod('itemLog', { - description: 'Returns the item changes log', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The item id', - http: {source: 'path'} - }], - returns: { - arg: 'data', - type: ['Object'], - root: true - }, - http: { - path: `/:id/itemLog`, - verb: 'get' - } - }); + Self.installMethod('getLog', filterParams); - Self.itemLog = itemFk => { - let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`; - return Self.rawSql(query, [itemFk]); - }; + function filterParams(params) { + return { + where: { + itemFk: params.itemFk + }, + skip: (params.page - 1) * params.size, + limit: params.size + }; + } }; diff --git a/services/item/common/models/itemLog.js b/services/item/common/models/itemLog.js new file mode 100644 index 000000000..248cc6abd --- /dev/null +++ b/services/item/common/models/itemLog.js @@ -0,0 +1,3 @@ +module.exports = function(Self) { + require('../methods/item/getLog.js')(Self); +}; diff --git a/services/item/common/models/itemLog.json b/services/item/common/models/itemLog.json new file mode 100644 index 000000000..63777113f --- /dev/null +++ b/services/item/common/models/itemLog.json @@ -0,0 +1,35 @@ +{ + "name": "ItemLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemLog", + "database": "vn" + } + }, + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "creationDate": { + "type": "Date" + }, + "description": { + "type": "String" + } + }, + "relations": { + "originFk": { + "type": "belongsTo", + "model": "Origin", + "foreignKey": "originFk" + }, + "userFk": { + "type": "belongsTo", + "model": "User", + "foreignKey": "userFk" + } + } + } diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index f001fcba1..09eed1735 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -34,5 +34,8 @@ }, "Tag": { "dataSource": "vn" + }, + "ItemLog": { + "dataSource": "vn" } } diff --git a/services_tests.js b/services_tests.js index 0ce869843..068f8c8f2 100644 --- a/services_tests.js +++ b/services_tests.js @@ -36,4 +36,3 @@ jasmine.addReporter(new SpecReporter({ })); jasmine.execute(); -