Unverified Commit 92ef23c9 authored by Ruslan Konviser's avatar Ruslan Konviser Committed by GitHub
Browse files

Merge pull request #1219 from ever-co/feat/#80-start-update-promotion

Feat/#80 start update promotion
parents 004359e7 e96487bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
	"name": "ever-platform",
	"description": "Ever Platform",
	"license": "AGPL-3.0",
	"version": "0.3.0",
	"version": "0.3.1",
	"homepage": "https://ever.co",
	"repository": {
		"type": "git",
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
	"name": "@ever-platform/common",
	"description": "Ever Platform Shared Core",
	"license": "AGPL-3.0",
	"version": "0.3.11",
	"version": "0.3.14",
	"homepage": "https://ever.co",
	"repository": {
		"type": "git",
+20 −1
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ import {
	IPromotionTitle,
	IPromotionDescription,
} from '../interfaces/IPromotion';
import Warehouse from './Warehouse';
import IWarehouse from '../interfaces/IWarehouse';

/**
 *
@@ -22,7 +24,7 @@ class Promotion extends DBObject<IPromotion, IPromotionCreateObject>
	 * @type {IPromotionTitle[]}
	 * @memberof Promotion
	 */
	@Schema({ type: Array, required: false })
	@Schema({ type: Array, required: true })
	title: IPromotionTitle[];

	/**
@@ -40,6 +42,23 @@ class Promotion extends DBObject<IPromotion, IPromotionCreateObject>
	@Column()
	active: boolean;

	/**
	 * @type {number}
	 * @memberof Promotion
	 */
	@Types.Number()
	@Column()
	promoPrice: number;

	/**
	 * Warehouse promotion is associated with
	 *
	 * @type {IWarehouse}
	 * @memberof Promotion
	 */
	@Types.Ref(Warehouse)
	warehouse: Warehouse;

	/**
	 * @type {Date}
	 * @memberof Promotion
+29 −0
Original line number Diff line number Diff line
import { ILocaleMember } from './ILocale';
import Product from '../entities/Product';
import { DBRawObject, PyroObjectId, DBCreateObject } from '@pyro/db';
import IWarehouse from './IWarehouse';

export interface IPromotionCreateObject extends DBCreateObject {
	/**
@@ -52,11 +53,39 @@ export interface IPromotionCreateObject extends DBCreateObject {
	 */
	product: Product;

	/**
	 * @type {string}
	 * @memberof IPromotionCreateObject
	 */
	productId?: string;

	/**
	 * @type {number}
	 * @memberof IPromotionCreateObject
	 */
	purchasesCount: number;

	/**
	 *
	 * @type {number}
	 * @memberof IPromotionCreateObject
	 */
	promoPrice: number;

	/**
	 *
	 * Id of warehouse this Promotion is associated with
	 *
	 * @type {IWarehouse}
	 * @memberof IPromotionCreateObject
	 */
	warehouse: IWarehouse;

	/**
	 * @type {string}
	 * @memberof IPromotionCreateObject
	 */
	warehouseId?: string;
}

export interface IPromotion extends IPromotionCreateObject, DBRawObject {
+13 −3
Original line number Diff line number Diff line
import { Resolver, Query, Mutation } from '@nestjs/graphql';
import { IPromotionCreateObject } from '@ever-platform/common/src/interfaces/IPromotion';
import { PromotionService } from '../../../services/products/PromotionService';
import Promotion from '@ever-platform/common/src/entities/Promotion';

@Resolver('Promotion')
export class PromotionResolver {
	constructor(private readonly _promotionService: PromotionService) {}

	@Query('promotions')
	async getPromotions() {
		return this._promotionService.getAllPromotions();
	async getPromotions(_context, { findInput }) {
		return this._promotionService.getAllPromotions(findInput);
	}

	@Mutation()
	@Mutation('createPromotion')
	async createPromotion(
		_,
		{ createInput }: { createInput: IPromotionCreateObject }
@@ -36,4 +37,13 @@ export class PromotionResolver {

		return this._promotionService.removeMultipleByIds(promotionsIds);
	}

	@Mutation('updatePromotion')
	async updatePromotion(
		_,
		{ id, updateInput }: { id; updateInput }
	): Promise<Promotion> {
		await this._promotionService.throwIfNotExists(id);
		return this._promotionService.update(id, updateInput);
	}
}
Loading