u
This commit is contained in:
@@ -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' });
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user