From 872ce1a0baef96b304cfaa39a1e2e7c65ff33628 Mon Sep 17 00:00:00 2001 From: munkhsaikhan Date: Wed, 7 Oct 2020 13:35:33 +0800 Subject: [PATCH 1/2] product and service has a image uploader --- src/data/schema/product.ts | 6 ++++-- src/db/models/definitions/deals.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/data/schema/product.ts b/src/data/schema/product.ts index da6e35988..b497ca91c 100644 --- a/src/data/schema/product.ts +++ b/src/data/schema/product.ts @@ -6,7 +6,7 @@ export const types = ` parentId: String code: String! order: String! - + isRoot: Boolean productCount: Int } @@ -24,6 +24,7 @@ export const types = ` createdAt: Date getTags: [Tag] tagIds: [String] + attachment: Attachment category: ProductCategory } @@ -37,7 +38,8 @@ const productParams = ` sku: String, unitPrice: Float, code: String, - customFieldsData: JSON + customFieldsData: JSON, + attachment: AttachmentInput `; const productCategoryParams = ` diff --git a/src/db/models/definitions/deals.ts b/src/db/models/definitions/deals.ts index b86942e8d..ec16adab0 100644 --- a/src/db/models/definitions/deals.ts +++ b/src/db/models/definitions/deals.ts @@ -1,5 +1,5 @@ import { Document, Schema } from 'mongoose'; -import { commonItemFieldsSchema, IItemCommonFields } from './boards'; +import { attachmentSchema, commonItemFieldsSchema, IItemCommonFields } from './boards'; import { customFieldSchema, ICustomField } from './common'; import { PRODUCT_TYPES } from './constants'; import { field, schemaWrapper } from './utils'; @@ -16,6 +16,7 @@ export interface IProduct { customFieldsData?: ICustomField[]; productId?: string; tagIds?: string[]; + attachment?: any; } export interface IProductDocument extends IProduct, Document { @@ -91,6 +92,7 @@ export const productSchema = schemaWrapper( default: new Date(), label: 'Created at', }), + attachment: field({ type: attachmentSchema, label: 'Attachments' }), }), ); From be93d38dd0707a7fc6298e11107b481f74b43700 Mon Sep 17 00:00:00 2001 From: munkhsaikhan Date: Wed, 7 Oct 2020 13:43:28 +0800 Subject: [PATCH 2/2] products image test schema --- src/__tests__/productMutations.test.ts | 14 ++++++++++++++ src/__tests__/productQueries.test.ts | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/__tests__/productMutations.test.ts b/src/__tests__/productMutations.test.ts index 0f50cdac8..33af90e95 100644 --- a/src/__tests__/productMutations.test.ts +++ b/src/__tests__/productMutations.test.ts @@ -16,6 +16,7 @@ describe('Test products mutations', () => { $categoryId: String, $sku: String $code: String + $attachment: AttachmentInput `; const commonParams = ` @@ -25,6 +26,7 @@ describe('Test products mutations', () => { categoryId: $categoryId sku: $sku code: $code + attachment: $attachment `; const commonCategoryParamDefs = ` @@ -77,6 +79,12 @@ describe('Test products mutations', () => { description sku code + attachment { + url + name + type + size + } } } `; @@ -112,6 +120,12 @@ describe('Test products mutations', () => { description sku code + attachment { + url + name + type + size + } } } `; diff --git a/src/__tests__/productQueries.test.ts b/src/__tests__/productQueries.test.ts index 378fddc64..a90e35d5e 100644 --- a/src/__tests__/productQueries.test.ts +++ b/src/__tests__/productQueries.test.ts @@ -29,6 +29,12 @@ describe('productQueries', () => { description sku createdAt + attachment { + name + url + type + size + } } } `;