u
This commit is contained in:
@@ -87,7 +87,20 @@
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* parentId:
|
||||
* categoryId:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
* sku:
|
||||
* type: string
|
||||
* track_stock:
|
||||
* type: boolean
|
||||
* Article:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* categoryId:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
@@ -98,7 +111,48 @@
|
||||
* ArticleDetail:
|
||||
* type: object
|
||||
* description: Full article payload (unit, brand, categoryIds, photos, eans, prices, track_stock, …)
|
||||
* additionalProperties: true
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* sku:
|
||||
* type: string
|
||||
* name:
|
||||
* type: string
|
||||
* slug:
|
||||
* type: string
|
||||
* track_stock:
|
||||
* type: boolean
|
||||
* unitamount:
|
||||
* type: number
|
||||
* nullable: true
|
||||
* weight:
|
||||
* type: number
|
||||
* nullable: true
|
||||
* unit:
|
||||
* type: object
|
||||
* brand:
|
||||
* type: object
|
||||
* nullable: true
|
||||
* categoryIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* photos:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* eans:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* prices:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* suppliers:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* ArticleHistoryEntry:
|
||||
* type: object
|
||||
* required: [id, date, text]
|
||||
@@ -824,6 +878,73 @@
|
||||
* desc:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* Posterminal:
|
||||
* type: object
|
||||
* required: [id, name]
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
* pairingpin:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* categoryIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* LabelTemplate:
|
||||
* type: object
|
||||
* required: [id, name, width, height, dpi, type, content]
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* name:
|
||||
* type: string
|
||||
* width:
|
||||
* type: number
|
||||
* height:
|
||||
* type: number
|
||||
* dpi:
|
||||
* type: integer
|
||||
* type:
|
||||
* type: string
|
||||
* content:
|
||||
* type: object
|
||||
* thumb:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* LabelTemplateCreateInput:
|
||||
* type: object
|
||||
* required: [name, width, height, dpi, type, content]
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* width:
|
||||
* type: number
|
||||
* height:
|
||||
* type: number
|
||||
* dpi:
|
||||
* type: integer
|
||||
* type:
|
||||
* type: string
|
||||
* content:
|
||||
* type: object
|
||||
* LabelTemplateUpdateInput:
|
||||
* type: object
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* width:
|
||||
* type: number
|
||||
* height:
|
||||
* type: number
|
||||
* dpi:
|
||||
* type: integer
|
||||
* type:
|
||||
* type: string
|
||||
* content:
|
||||
* type: object
|
||||
* Warehouse:
|
||||
* type: object
|
||||
* required: [id, name, sort]
|
||||
|
||||
@@ -111,7 +111,7 @@ export function register(app, basePath = '') {
|
||||
* /article:
|
||||
* post:
|
||||
* tags: [Article]
|
||||
* summary: Create article
|
||||
* summary: Create article in category
|
||||
* description: Creates an article under an authorized category (`parentId`).
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
@@ -123,18 +123,18 @@ export function register(app, basePath = '') {
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [parentId, name]
|
||||
* required: [categoryId, name]
|
||||
* properties:
|
||||
* parentId:
|
||||
* categoryId:
|
||||
* type: integer
|
||||
* description: Category id
|
||||
* description: Category ID under which to create the article
|
||||
* name:
|
||||
* type: string
|
||||
* track_stock:
|
||||
* type: boolean
|
||||
* description: Whether to track inventory stock (defaults to true)
|
||||
* example:
|
||||
* parentId: 10
|
||||
* categoryId: 10
|
||||
* name: New article
|
||||
* responses:
|
||||
* 201:
|
||||
@@ -178,7 +178,7 @@ export function register(app, basePath = '') {
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
app.post(`${basePath}/article`, async (req, res) => {
|
||||
const parent = parsePositiveInt(req.body?.parentId, 'parentId');
|
||||
const parent = parsePositiveInt(req.body?.categoryId ?? req.body?.parentId, 'categoryId');
|
||||
if (parent.error) {
|
||||
return res.status(400).json({ error: parent.error });
|
||||
}
|
||||
@@ -195,13 +195,17 @@ export function register(app, basePath = '') {
|
||||
const track_stock = rawTrack !== undefined ? Boolean(rawTrack) : true;
|
||||
|
||||
try {
|
||||
const article = await db.createUnderParent({
|
||||
const created = await db.createUnderParent({
|
||||
googleAuthId: req.user.id,
|
||||
parentId: parent.id,
|
||||
name,
|
||||
track_stock,
|
||||
});
|
||||
emitArticlesSignal(req);
|
||||
const article = {
|
||||
...created,
|
||||
categoryId: created.parentId,
|
||||
};
|
||||
res.status(201).json({ article });
|
||||
} catch (error) {
|
||||
const status = articleErrorStatus(error);
|
||||
|
||||
Reference in New Issue
Block a user