This commit is contained in:
seb
2026-08-02 19:02:10 +02:00
parent b890843445
commit e96bfb0624
4 changed files with 8 additions and 6 deletions

View File

@@ -186,10 +186,10 @@ Company-scoped brands. Auth via `resolveCompanyAccess`.
| Method | Signature | Returns |
| --- | --- | --- |
| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name }` |
| `rename` | `({ googleAuthId, id, name })` | `{ id, name }` |
| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name, slug }` |
| `rename` | `({ googleAuthId, id, name })` | `{ id, name, slug }` |
| `delete` | `({ googleAuthId, id })` | `void` — blocked by FK if `categoryarticle` or child categories remain |
| `getTreeForCompany` | `(googleAuthId, companyId)` | `{ languageId, tree, articles }` |
| `getTreeForCompany` | `(googleAuthId, companyId)` | `{ languageId, tree, articles }` — tree rows carry `name` + `slug` |
| `getCategoryArticles` | `(googleAuthId, categoryId)` | `{ id, sku, name, slug, net, taxRate, optionsCount, articleListCount, childCount, fatherArticleId, fatherSku, fullHash, thumbW, thumbH, thumbHash }[]` |
### `createUnderParent` (transaction)
@@ -197,11 +197,11 @@ Company-scoped brands. Auth via `resolveCompanyAccess`.
1. `parentId` exists, else `Parent not found`
2. Walk ancestors to root; find `company` with `root_category_id` = root
3. `companyuser` for `(googleAuthId, companyId)`, else `Not authorized`
4. Insert `category` (next sibling `sort`) + `categorytext` (`name`, slugified `slug`, company default language)
4. Insert `category` (next sibling `sort`) + `categorytext` (`name`, slugified `slug`, company default language); returns `{ id, parentId, sort, name, slug }`
`getTreeForCompany` throws `Not authorized` if `googleAuthId` is not a `companyuser` of `companyId`, and `Company not found` if the company is missing, has no `root_category_id`, or no `default_language_id`.
`rename` updates the `categorytext` name (and re-slugifies `slug`) for the category in the company default language. Empty name → `Name required`. Auth via `resolveCategoryAccess` on the category (`Parent not found` / `Not authorized`). Missing text row → `Category not found`. Returns `{ id, name }`. For `PATCH /api/category/:id`.
`rename` updates the `categorytext` name (and re-slugifies `slug`) for the category in the company default language. Empty name → `Name required`. Auth via `resolveCategoryAccess` on the category (`Parent not found` / `Not authorized`). Missing text row → `Category not found`. Returns `{ id, name, slug }`. For `PATCH /api/category/:id`.
---

View File

@@ -15,6 +15,7 @@ SELECT
t.parent_id AS parentId,
t.sort,
ct.name,
ct.slug,
p.thumbw AS thumbW,
p.thumbh AS thumbH,
p.thumbhash AS thumbHash

View File

@@ -54,6 +54,7 @@ export default function createUnderParent(pool) {
parentId: resolvedParentId,
sort,
name,
slug,
};
} catch (err) {
try {

View File

@@ -36,6 +36,6 @@ export default function rename(pool) {
throw new Error('Category not found');
}
return { id, name: cleaned };
return { id, name: cleaned, slug };
};
}