u
This commit is contained in:
@@ -65,6 +65,8 @@ async function http(path, { method = 'GET', body } = {}) {
|
||||
logApi('error-body', { method, path, status: res.status, message, data });
|
||||
const err = new Error(message || `Request failed (${res.status})`);
|
||||
err.status = res.status;
|
||||
err.path = path;
|
||||
err.method = method;
|
||||
err.data = data;
|
||||
throw err;
|
||||
}
|
||||
@@ -92,6 +94,30 @@ export const article = {
|
||||
const params = new URLSearchParams({ target });
|
||||
return http(`/api/article/get?${params}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /api/article/byCategory?categoryId&offset&maxCount
|
||||
* Articles assigned to a category (for tile view).
|
||||
*/
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
|
||||
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}` : ''}`);
|
||||
},
|
||||
};
|
||||
|
||||
export const company = {
|
||||
@@ -119,14 +145,8 @@ export const company = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Backend suggestion (not implemented yet):
|
||||
*
|
||||
* PUT /api/company/:companyId
|
||||
* Body: { name, iso639, taxrate, reducedtaxrate }
|
||||
* Response: { company: { id, name, iso639, taxrate, reducedtaxrate, ... } }
|
||||
* Auth: session cookie; user must be allowed to edit that company.
|
||||
*
|
||||
* Optional: add iso639 to GET /api/company list items (today only languageId).
|
||||
*/
|
||||
update(companyId, { name, iso639, taxrate, reducedtaxrate }) {
|
||||
return http(`/api/company/${companyId}`, {
|
||||
@@ -194,4 +214,4 @@ export const auth = {
|
||||
},
|
||||
};
|
||||
|
||||
export default { auth, article, company };
|
||||
export default { auth, article, category, company };
|
||||
|
||||
Reference in New Issue
Block a user