This commit is contained in:
seb
2026-07-31 18:15:15 +02:00
parent c2e128cb55
commit 6b1701d4dc
6 changed files with 194 additions and 38 deletions

View File

@@ -142,14 +142,33 @@ Backend mapping:
| Method | Signature | Returns |
| --- | --- | --- |
| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, name, sku }` |
| `getBySku` | `(googleAuthId, sku)` | `{ id, sku, name, slug, net, taxRate, optionsCount, articleListCount, childCount, fatherArticleId, fatherSku, thumbW, thumbH, thumbHash }` |
| `getBySku` | `(googleAuthId, sku)` | detail object (see below) |
| `updateBySku` | `(googleAuthId, sku, { name })` | same shape as `getBySku` |
`getBySku` / `updateBySku` return:
```js
{
id, sku, name, slug,
unitamount, weight,
unit: { si },
brand: { name, thumbW, thumbH, thumbHash } | null,
categoryIds: number[],
photos: { sort, thumbW, thumbH, thumbHash }[],
eans: string[],
prices: { minmultiplier, net, taxRate, customergroupId }[],
optionsCount, articleListCount, childCount,
fatherArticleId, fatherSku,
}
```
`getCategoryArticles` / `getTreeForCompany().articles[]` keep the flat list shape (`net`, `taxRate`, single `thumbW`/`thumbH`/`thumbHash`).
`parentId` is the category id. Creates `article` + `articletext` (company default language) + `categoryarticle` in one transaction. Allocates `sku` via `getnextnumberwithprefixandpadding` (`type` `sku`; creates `numbers` row with empty prefix if missing). Default unit `pc` is ensured if missing (`unitamount` 1, `weight` 0). Auth via `resolveCategoryAccess(googleAuthId, parentId)` — `Parent not found` / `Not authorized`.
Same article shape as `getCategoryArticles` / `getTreeForCompany().articles[]`. Auth via the article's `categoryarticle` category + `resolveCategoryAccess`. Errors: `Article not found`, `Not authorized`.
Auth via the article's `categoryarticle` category + `resolveCategoryAccess`. Errors: `Article not found`, `Not authorized`.
`updateBySku` updates `articletext` (company default language) in a transaction (`name` + slugified `slug`), then returns the same select as `getBySku`. Errors: `Article not found`, `Not authorized`, `Name required`.
`updateBySku` updates `articletext` (company default language) in a transaction (`name` + slugified `slug`), then returns the same object as `getBySku`. Errors: `Article not found`, `Not authorized`, `Name required`.
---