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