u
This commit is contained in:
@@ -69,11 +69,11 @@ export default function del(provider) {
|
||||
await deleteArticleAndLists(id);
|
||||
};
|
||||
|
||||
const fatherRes = await runner.query(
|
||||
'SELECT fatherarticle_id FROM article WHERE id = @articleId',
|
||||
const parentRes = await runner.query(
|
||||
'SELECT parentarticle_id FROM article WHERE id = @articleId',
|
||||
{ articleId },
|
||||
);
|
||||
const fatherArticleId = fatherRes.rows[0]?.fatherarticle_id;
|
||||
const parentArticleId = parentRes.rows[0]?.parentarticle_id;
|
||||
|
||||
const childCount = await runner.query(queries.GET_CHILD_COUNT, { articleId });
|
||||
if (childCount.rows[0].count > 0) {
|
||||
@@ -85,18 +85,18 @@ export default function del(provider) {
|
||||
await deleteArticleAndLists(articleId);
|
||||
}
|
||||
|
||||
if (fatherArticleId != null) {
|
||||
if (parentArticleId != null) {
|
||||
const remainingChildrenRes = await runner.query(
|
||||
'SELECT id, fathersort FROM article WHERE fatherarticle_id = @fatherArticleId ORDER BY fathersort ASC, id ASC',
|
||||
{ fatherArticleId },
|
||||
'SELECT id, parentsort FROM article WHERE parentarticle_id = @parentArticleId ORDER BY parentsort ASC, id ASC',
|
||||
{ parentArticleId },
|
||||
);
|
||||
for (let i = 0; i < remainingChildrenRes.rows.length; i++) {
|
||||
const childRow = remainingChildrenRes.rows[i];
|
||||
if (Number(childRow.fathersort) !== i) {
|
||||
await runner.query(articleQueries.SET_FATHER_SORT, {
|
||||
if (Number(childRow.parentsort) !== i) {
|
||||
await runner.query(articleQueries.SET_PARENT_SORT, {
|
||||
articleId: childRow.id,
|
||||
fatherArticleId,
|
||||
fathersort: i,
|
||||
parentArticleId,
|
||||
parentsort: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user