This commit is contained in:
seb
2026-10-10 18:17:14 +02:00
parent 004e0de869
commit a20668cd61
31 changed files with 572 additions and 76 deletions

View File

@@ -9,6 +9,7 @@ export const brand = {
* GET /api/brand → { brands: Brand[], total, offset, limit }
* @param {{ offset?: number, limit?: number, includeSmallThumbs?: boolean }} [params]
*/
// #region GET /api/brand — list
list(params) {
const offset = Number(params?.offset ?? 0);
const limit = Number(params?.limit ?? 0);
@@ -20,6 +21,7 @@ export const brand = {
const qs = query.toString();
return http(qs ? `/api/brand?${qs}` : '/api/brand');
},
// #endregion
/**
* POST /api/brand
@@ -27,32 +29,39 @@ export const brand = {
* Empty name ⇒ 400 Invalid brand.
* → 201 { brand: Brand } · 409 Brand already exists
*/
// #region POST /api/brand — create
create(body) {
return http('/api/brand', { method: 'POST', body });
},
// #endregion
/**
* PATCH /api/brand/:id
* Body: { name, gsprpinfo? } — rename / update info.
* → 200 { id, name, gsprpinfo, touchedArticleCount } · 404 Brand not found
*/
// #region PATCH /api/brand/:id — rename
rename(id, body) {
return http(`/api/brand/${encodeURIComponent(id)}`, { method: 'PATCH', body });
},
// #endregion
/**
* DELETE /api/brand/:id
* → 204 No Content · 404 Brand not found
*/
// #region DELETE /api/brand/:id — delete
delete(id) {
return http(`/api/brand/${encodeURIComponent(id)}`, { method: 'DELETE' });
},
// #endregion
/**
* POST /api/brand/:id/image
* Accepts full-size image body (Content-Type: image/webp).
* → 201 { brand: { id, fullHash, thumbW, thumbH, thumbHash, pics } }
*/
// #region POST /api/brand/:id/image — addImage
addImage(brandId, file) {
return httpBinary(`/api/brand/${brandId}/image`, {
method: 'POST',
@@ -60,12 +69,15 @@ export const brand = {
body: file,
});
},
// #endregion
/**
* DELETE /api/brand/:id/image
* → 200 { brand: { id, thumbW: null, thumbH: null, thumbHash: null, pics: [] } }
*/
// #region DELETE /api/brand/:id/image — deleteImage
deleteImage(brandId) {
return http(`/api/brand/${brandId}/image`, { method: 'DELETE' });
},
// #endregion
};