u
This commit is contained in:
13
src/store/company/create.js
Normal file
13
src/store/company/create.js
Normal 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;
|
||||
};
|
||||
}
|
||||
11
src/store/company/delete.js
Normal file
11
src/store/company/delete.js
Normal 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);
|
||||
};
|
||||
}
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
8
src/store/company/list.js
Normal file
8
src/store/company/list.js
Normal 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;
|
||||
};
|
||||
}
|
||||
12
src/store/company/setDefaultLang.js
Normal file
12
src/store/company/setDefaultLang.js
Normal 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);
|
||||
};
|
||||
}
|
||||
12
src/store/company/setRootCategory.js
Normal file
12
src/store/company/setRootCategory.js
Normal 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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user