catalogues count
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common';
|
||||
import { BusinessService } from './business.service';
|
||||
import { SetupBusinessDto } from './dto/create-business.dto';
|
||||
import { SetupBusinessDto } from './dto/setup-business.dto';
|
||||
import { SuperAdminAuthGuard } from '../auth/guards/superAdminAuth.guard';
|
||||
import { FindBusinessesDto } from './dto/find-businesses.dto';
|
||||
// import { UpdateBusinessDto } from './dto/update-business.dto';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { SetupBusinessDto } from './dto/create-business.dto';
|
||||
import { SetupBusinessDto } from './dto/setup-business.dto';
|
||||
import { UpdateBusinessDto } from './dto/update-business.dto';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { Business } from './entities/business.entity';
|
||||
@@ -16,13 +16,14 @@ export class BusinessService {
|
||||
) { }
|
||||
|
||||
async setupAccount(dto: SetupBusinessDto) {
|
||||
const { danakSubscriptionId, name, phone, slug, firstName, lastName } = dto
|
||||
const { danakSubscriptionId, name, phone, slug, firstName, lastName, maxCataloguesCount } = dto
|
||||
|
||||
const business = await this.em.transactional(async (em) => {
|
||||
const business = em.create(Business, {
|
||||
danakSubscriptionId,
|
||||
name,
|
||||
slug
|
||||
slug,
|
||||
maxCataloguesCount
|
||||
})
|
||||
|
||||
const admin = em.create(Admin, {
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
import { IsNotEmpty, IsOptional, IsString, } from 'class-validator';
|
||||
import { IsInt, IsNotEmpty, IsOptional, IsString, } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class SetupBusinessDto {
|
||||
@@ -29,4 +29,8 @@ export class SetupBusinessDto {
|
||||
@IsString()
|
||||
lastName?: string;
|
||||
|
||||
@IsInt()
|
||||
@ApiProperty()
|
||||
maxCataloguesCount: number;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { SetupBusinessDto } from './create-business.dto';
|
||||
import { SetupBusinessDto } from './setup-business.dto';
|
||||
|
||||
export class UpdateBusinessDto extends PartialType(SetupBusinessDto) { }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Cascade, Collection, Entity, EntityRepositoryType,
|
||||
OneToMany, OneToOne, Opt, Property, Unique } from "@mikro-orm/core";
|
||||
import {
|
||||
Cascade, Collection, Entity, EntityRepositoryType,
|
||||
OneToMany, OneToOne, Opt, Property, Unique
|
||||
} from "@mikro-orm/core";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { Catalogue } from "src/modules/catalogue/entities/catalogue.entity";
|
||||
import { BusinessRepository } from "../repositories/business.repository";
|
||||
@@ -32,6 +34,8 @@ export class Business extends BaseEntity {
|
||||
@Property({ type: "varchar", length: 255, nullable: true })
|
||||
logoUrl?: string;
|
||||
|
||||
@Property({ type: "numeric", nullable: false, default: 0 })
|
||||
maxCataloguesCount: number;
|
||||
|
||||
//=========================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user