add: parser upload product
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { forwardRef, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||
import {
|
||||
forwardRef,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Connection, Not, Repository } from 'typeorm';
|
||||
import { Connection, EntityNotFoundError, Not, Repository } from 'typeorm';
|
||||
import { CoaService } from '../../transaction/coa.service';
|
||||
import { CreatePartnerDto } from '../dto/create-partner.dto';
|
||||
import { Partner } from '../entities/partner.entity';
|
||||
@@ -9,6 +15,7 @@ import { UsersService } from '../users.service';
|
||||
import { CreateUserDto } from '../dto/create-user.dto';
|
||||
import { UpdatePartnerDto } from '../dto/update-partner.dto';
|
||||
import { UpdateUserDto } from '../dto/update-user.dto';
|
||||
import { when } from 'joi';
|
||||
|
||||
@Injectable()
|
||||
export class PartnerService {
|
||||
@@ -41,10 +48,12 @@ export class PartnerService {
|
||||
}
|
||||
|
||||
const partnerData = new Partner();
|
||||
|
||||
partnerData.id = uuid.v4();
|
||||
partnerData.name = createPartnerDto.name;
|
||||
partnerData.npwp = createPartnerDto.npwp;
|
||||
partnerData.address = createPartnerDto.address;
|
||||
partnerData.code = createPartnerDto.code;
|
||||
partnerData.status = true;
|
||||
|
||||
await this.connection.transaction(async (manager) => {
|
||||
@@ -52,6 +61,7 @@ export class PartnerService {
|
||||
});
|
||||
|
||||
const dataUser = new CreateUserDto();
|
||||
|
||||
dataUser.username = `admin_${partnerData.name}`;
|
||||
dataUser.name = partnerData.name;
|
||||
dataUser.phone_number = partnerData.phone_number;
|
||||
@@ -129,6 +139,14 @@ export class PartnerService {
|
||||
return partnerData;
|
||||
};
|
||||
|
||||
async findOne(code: string) {
|
||||
return await this.partnerRepository.findOne({
|
||||
where: {
|
||||
code: code,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
findAllPartner(page, pageSize?) {
|
||||
return this.partnerRepository.findAndCount({
|
||||
skip: page * (pageSize || 10),
|
||||
|
||||
Reference in New Issue
Block a user