u
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
import sql from 'mssql';
|
||||
import { CREATE } from '../../sql/company.js';
|
||||
import { CREATE as CREATE_CATEGORY } from '../../sql/category.js';
|
||||
|
||||
export default function create(pool) {
|
||||
return async ({ name }) => {
|
||||
const category = await pool
|
||||
.request()
|
||||
.input('parentId', sql.Int, null)
|
||||
.input('sort', sql.Int, 0)
|
||||
.query(CREATE_CATEGORY);
|
||||
|
||||
const rootCategoryId = category.recordset[0].id;
|
||||
|
||||
const result = await pool
|
||||
.request()
|
||||
.input('name', sql.NVarChar(255), name)
|
||||
.input('rootCategoryId', sql.Int, rootCategoryId)
|
||||
.query(CREATE);
|
||||
|
||||
return result.recordset[0].id;
|
||||
|
||||
Reference in New Issue
Block a user