This commit is contained in:
seb
2026-07-31 00:20:20 +02:00
parent 6bdac7e543
commit af8ef0a788
23 changed files with 421 additions and 123 deletions

View File

@@ -0,0 +1,13 @@
import sql from 'mssql';
import { CREATE } from '../../sql/company.js';
export default function create(pool) {
return async ({ name }) => {
const result = await pool
.request()
.input('name', sql.NVarChar(255), name)
.query(CREATE);
return result.recordset[0].id;
};
}

View File

@@ -0,0 +1,11 @@
import sql from 'mssql';
import { DELETE } from '../../sql/company.js';
export default function del(pool) {
return async (companyId) => {
await pool
.request()
.input('companyId', sql.Int, companyId)
.query(DELETE);
};
}

View File

@@ -9,7 +9,7 @@ export default function getByCompanyUserId(pool) {
.query(GET_BY_COMPANY_USER_ID);
const row = result.recordset[0];
if (!row) return null;
if (!row) return;
return [row.id, row.default_language_id, row.root_category_id, row.name];
};

View File

@@ -0,0 +1,8 @@
import { LIST } from '../../sql/company.js';
export default function list(pool) {
return async () => {
const result = await pool.request().query(LIST);
return result.recordset;
};
}

View File

@@ -0,0 +1,12 @@
import sql from 'mssql';
import { SET_DEFAULT_LANG } from '../../sql/company.js';
export default function setDefaultLang(pool) {
return async (companyId, languageId) => {
await pool
.request()
.input('companyId', sql.Int, companyId)
.input('languageId', sql.Int, languageId)
.query(SET_DEFAULT_LANG);
};
}

View File

@@ -0,0 +1,12 @@
import sql from 'mssql';
import { SET_ROOT_CATEGORY } from '../../sql/company.js';
export default function setRootCategory(pool) {
return async (companyId, categoryId) => {
await pool
.request()
.input('companyId', sql.Int, companyId)
.input('categoryId', sql.Int, categoryId)
.query(SET_ROOT_CATEGORY);
};
}