u
This commit is contained in:
10
README.md
10
README.md
@@ -186,10 +186,10 @@ Company-scoped brands. Auth via `resolveCompanyAccess`.
|
|||||||
|
|
||||||
| Method | Signature | Returns |
|
| Method | Signature | Returns |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name }` |
|
| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name, slug }` |
|
||||||
| `rename` | `({ googleAuthId, id, name })` | `{ id, name }` |
|
| `rename` | `({ googleAuthId, id, name })` | `{ id, name, slug }` |
|
||||||
| `delete` | `({ googleAuthId, id })` | `void` — blocked by FK if `categoryarticle` or child categories remain |
|
| `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 }[]` |
|
| `getCategoryArticles` | `(googleAuthId, categoryId)` | `{ id, sku, name, slug, net, taxRate, optionsCount, articleListCount, childCount, fatherArticleId, fatherSku, fullHash, thumbW, thumbH, thumbHash }[]` |
|
||||||
|
|
||||||
### `createUnderParent` (transaction)
|
### `createUnderParent` (transaction)
|
||||||
@@ -197,11 +197,11 @@ Company-scoped brands. Auth via `resolveCompanyAccess`.
|
|||||||
1. `parentId` exists, else `Parent not found`
|
1. `parentId` exists, else `Parent not found`
|
||||||
2. Walk ancestors to root; find `company` with `root_category_id` = root
|
2. Walk ancestors to root; find `company` with `root_category_id` = root
|
||||||
3. `companyuser` for `(googleAuthId, companyId)`, else `Not authorized`
|
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`.
|
`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`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ SELECT
|
|||||||
t.parent_id AS parentId,
|
t.parent_id AS parentId,
|
||||||
t.sort,
|
t.sort,
|
||||||
ct.name,
|
ct.name,
|
||||||
|
ct.slug,
|
||||||
p.thumbw AS thumbW,
|
p.thumbw AS thumbW,
|
||||||
p.thumbh AS thumbH,
|
p.thumbh AS thumbH,
|
||||||
p.thumbhash AS thumbHash
|
p.thumbhash AS thumbHash
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export default function createUnderParent(pool) {
|
|||||||
parentId: resolvedParentId,
|
parentId: resolvedParentId,
|
||||||
sort,
|
sort,
|
||||||
name,
|
name,
|
||||||
|
slug,
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ export default function rename(pool) {
|
|||||||
throw new Error('Category not found');
|
throw new Error('Category not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { id, name: cleaned };
|
return { id, name: cleaned, slug };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user