fix: refs #4774 models and back
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2024-10-22 09:48:53 +02:00
parent 26e5146664
commit 3e0a7b3b6a
9 changed files with 188 additions and 0 deletions

View File

@ -213,5 +213,23 @@
},
"CompanyI18n": {
"dataSource": "vn"
},
"ItemTypeI18n": {
"dataSource": "vn"
},
"InkI18n": {
"dataSource": "vn"
},
"OriginI18n": {
"dataSource": "vn"
},
"StateI18n": {
"dataSource": "vn"
},
"TagI18n": {
"dataSource": "vn"
},
"itemCategoryI18n": {
"dataSource": "vn"
}
}

22
back/models/inkI18n.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "InkI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "inkI18n"
}
},
"properties": {
"inkFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "ItemCategoryI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "itemCategoryI18n"
}
},
"properties": {
"categoryFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "ItemTypeI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "itemTypeI18n"
}
},
"properties": {
"typeFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "OriginI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "originI18n"
}
},
"properties": {
"originFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,22 @@
{
"name": "StateI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "stateI18n"
}
},
"properties": {
"stateFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

22
back/models/tagI18n.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "TagI18n",
"base": "VnModel",
"options": {
"mysql": {
"table": "tagI18n"
}
},
"properties": {
"tagFk": {
"type": "number",
"id": 1
},
"lang": {
"type": "string",
"id": 2
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,37 @@
module.exports = Self => {
Self.remoteMethod('getI18nTables', {
description: 'Return tables with name end with i18n',
accessType: 'READ',
accepts: [],
returns: {
type: 'Array',
root: true
},
http: {
path: `/get-i18n-tables`,
verb: 'GET'
}
});
Self.getI18nTables = async() => {
const tables = await Self.rawSql(`
SELECT c.table_name tableName, c.column_name primaryKey
FROM information_schema.columns c
WHERE
c.table_name LIKE '%i18n'
AND c.COLUMN_KEY = 'PRI'
AND c.COLUMN_NAME <> 'lang'`);
const columns = await Self.rawSql(`
SELECT c.table_name tableName, c.column_name field
FROM information_schema.columns c
WHERE
c.table_name LIKE '%i18n'
AND c.COLUMN_KEY <> 'PRI'
`);
for (const column of columns)
tables.find(t => t.tableName == column.tableName).field = column.field;
return tables;
};
};

View File

@ -5,4 +5,5 @@ module.exports = function(Self) {
require('../methods/application/executeProc')(Self);
require('../methods/application/executeFunc')(Self);
require('../methods/application/getEnumValues')(Self);
require('../methods/application/getI18nTables')(Self);
};