This commit is contained in:
seb
2026-07-31 17:51:57 +02:00
parent 797ea59bed
commit a6a9777f31
33 changed files with 1432 additions and 422 deletions

View File

@@ -90,33 +90,54 @@ export const article = {
return http(`/api/article/search?${params}`);
},
get({ target } = {}) {
const params = new URLSearchParams({ target });
return http(`/api/article/get?${params}`);
/** GET /api/article/:sku → { article: { id, sku, name, slug, net, taxRate, fatherArticleId, fatherSku, … } } */
getBySku(sku) {
return http(`/api/article/${encodeURIComponent(sku)}`);
},
/** POST /api/article → 201 { article } */
create({ parentId, name }) {
return http('/api/article', {
method: 'POST',
body: { parentId, name },
});
},
/**
* GET /api/article/byCategory?categoryId&offset&maxCount
* Articles assigned to a category (for tile view).
* PATCH /api/article/:sku
* Body: partial fields, e.g. { name }
* → 200 { article }
*/
byCategory({ categoryId, offset, maxCount } = {}) {
const params = new URLSearchParams({ categoryId: String(categoryId) });
if (offset) params.set('offset', String(offset));
if (maxCount != null) params.set('maxCount', String(maxCount));
return http(`/api/article/byCategory?${params}`);
update(sku, body) {
return http(`/api/article/${encodeURIComponent(sku)}`, {
method: 'PATCH',
body,
});
},
};
export const category = {
/**
* GET /api/category/tree?companyId=
* Flat map of categories keyed by id; rootCategoryId resolved server-side.
*/
getTree({ companyId } = {}) {
const params = new URLSearchParams();
if (companyId != null) params.set('companyId', String(companyId));
const qs = params.toString();
return http(`/api/category/tree${qs ? `?${qs}` : ''}`);
/** GET /api/category/tree → { languageId, tree, articles } (company from session) */
getTree() {
return http('/api/category/tree');
},
/** GET /api/category/:id/articles → { articles: [...] } */
getArticles(categoryId) {
return http(`/api/category/${categoryId}/articles`);
},
/** POST /api/category → 201 { category } */
create({ parentId, name }) {
return http('/api/category', {
method: 'POST',
body: { parentId, name },
});
},
/** DELETE /api/category/:id → 204 */
delete(categoryId) {
return http(`/api/category/${categoryId}`, { method: 'DELETE' });
},
};