Record articlehistory entry on article creation
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { CREATE } from '../../sql/article.js';
|
import { CREATE } from '../../sql/article.js';
|
||||||
import { ADD as ADD_CATEGORYARTICLE } from '../../sql/categoryarticle.js';
|
import { ADD as ADD_CATEGORYARTICLE } from '../../sql/categoryarticle.js';
|
||||||
import { CREATE as CREATE_ARTICLETEXT } from '../../sql/articletext.js';
|
import { CREATE as CREATE_ARTICLETEXT } from '../../sql/articletext.js';
|
||||||
|
import { INSERT as INSERT_HISTORY } from '../../sql/articlehistory.js';
|
||||||
import resolveCategoryAccess from '../category/resolveCategoryAccess.js';
|
import resolveCategoryAccess from '../category/resolveCategoryAccess.js';
|
||||||
import ensureDefaultUnit from '../unit/ensureDefault.js';
|
import ensureDefaultUnit from '../unit/ensureDefault.js';
|
||||||
import nextSku from '../numbers/nextSku.js';
|
import nextSku from '../numbers/nextSku.js';
|
||||||
@@ -27,7 +28,10 @@ export default function createUnderParent(pool) {
|
|||||||
* // => { id, parentId, name, sku }
|
* // => { id, parentId, name, sku }
|
||||||
*/
|
*/
|
||||||
return async ({ googleAuthId, parentId, name }) => {
|
return async ({ googleAuthId, parentId, name }) => {
|
||||||
const { companyId, languageId } = await access(googleAuthId, parentId);
|
const { companyId, languageId, companyuserId } = await access(
|
||||||
|
googleAuthId,
|
||||||
|
parentId
|
||||||
|
);
|
||||||
|
|
||||||
const tx = pool.transaction();
|
const tx = pool.transaction();
|
||||||
await tx.begin();
|
await tx.begin();
|
||||||
@@ -58,6 +62,12 @@ export default function createUnderParent(pool) {
|
|||||||
.input('slug', slug)
|
.input('slug', slug)
|
||||||
.query(CREATE_ARTICLETEXT);
|
.query(CREATE_ARTICLETEXT);
|
||||||
|
|
||||||
|
await request(pool, tx)
|
||||||
|
.input('articleId', id)
|
||||||
|
.input('companyuserId', companyuserId)
|
||||||
|
.input('text', `Artikel "${name}" angelegt`)
|
||||||
|
.query(INSERT_HISTORY);
|
||||||
|
|
||||||
await tx.commit();
|
await tx.commit();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export default function resolveCategoryAccess(pool) {
|
|||||||
rootCategoryId: row.rootCategoryId,
|
rootCategoryId: row.rootCategoryId,
|
||||||
languageId: row.languageId,
|
languageId: row.languageId,
|
||||||
posCustomerGroupId: row.posCustomerGroupId ?? null,
|
posCustomerGroupId: row.posCustomerGroupId ?? null,
|
||||||
|
companyuserId: row.companyuserId,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user