feat/painel-cliente #2

Closed
felipe-batista wants to merge 4 commits from feat/painel-cliente into dev
6 changed files with 7919 additions and 10025 deletions
Showing only changes of commit 7bd0d85386 - Show all commits

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"cweijan.dbclient-jdbc"
]
}

16399
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,17 +2,17 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { ConnectionOptions } from 'typeorm';
export const typeOrmConfig: TypeOrmModuleOptions = {
type: "oracle",
// host: "192.168.100.40",
// username: "LIVIA",
// password: "LIVIA",
host: "10.1.1.241",
username: "SEVEN",
password: "USR54SEV",
// username: "API",
// password: "E05H5KIEQV3YKDJR",
type: 'oracle',
// host: "192.168.100.40",
// username: "LIVIA",
// password: "LIVIA",
host: '10.1.1.241',
username: 'SEVEN',
password: 'USR54SEV',
// username: "API",
// password: "E05H5KIEQV3YKDJR",
port: 1521,
sid: "WINT",
serviceName: 'WINT',
synchronize: false,
logging: false,
entities: [__dirname + '/../**/*.entity.{js,ts}'],
@ -20,14 +20,13 @@ export const typeOrmConfig: TypeOrmModuleOptions = {
};
export const connectionOptions: ConnectionOptions = {
type: "oracle",
host: "10.1.1.241",
username: "SEVEN",
password: "USR54SEV",
type: 'oracle',
host: '10.1.1.241',
username: 'SEVEN',
password: 'USR54SEV',
port: 1521,
sid: "WINT",
serviceName: 'WINT',
synchronize: false,
logging: false,
entities: [__dirname + '/../**/*.entity.{js,ts}'],
}
};

View File

@ -1,109 +1,148 @@
import { Body, Controller, Get, HttpException, HttpStatus, Param, Post, Query } from '@nestjs/common';
import { CustomerService } from './customer.service';
import { ResultModel } from '../../domain/models/result.model';
import {
Body,
Controller,
Get,
HttpException,
HttpStatus,
Param,
Post,
Query,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { error } from 'console';
import { Customer } from 'src/domain/models/customer.model';
import { ApiTags } from '@nestjs/swagger';
import { ResultModel } from '../../domain/models/result.model';
import { CustomerService } from './customer.service';
@ApiTags('Customer')
@Controller('api/v1/customer')
export class CustomerController {
export class CustomerController {
constructor(private readonly customerService: CustomerService) {}
constructor(private readonly customerService: CustomerService){}
@Get(':name')
async getCustomerByName(@Param('name') name: string) {
try {
const customers = await this.customerService.findCustomerByName(name);
return new ResultModel(true, null, customers, null);
} catch (err) {
throw new HttpException(
new ResultModel(
false,
'Não foi possível consultar o cadastro de clientes.',
{},
error,
),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@Get(':name')
async getCustomerByName(@Param('name') name: string){
try{
const customers = await this.customerService.findCustomerByName(name);
return new ResultModel(true, null, customers, null);
} catch(err){
throw new HttpException(new ResultModel(false, 'Não foi possível consultar o cadastro de clientes.', {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Get('categories/fechAll')
async getCategories() {
try {
const categories = await this.customerService.getCategory();
return categories;
} catch (err) {
throw new HttpException(
new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@Get('categories/fechAll')
async getCategories(){
try{
const categories = await this.customerService.getCategory();
return categories;
} catch(err){
throw new HttpException(new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Get('subcategories/fechAll')
async getSubCategories() {
try {
const subCategories = await this.customerService.getSubCategory();
return subCategories;
} catch (err) {
throw new HttpException(
new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@Get('subcategories/fechAll')
async getSubCategories(){
try{
const subCategories = await this.customerService.getSubCategory();
return subCategories;
} catch(err){
throw new HttpException(new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Get()
async getCustomer(@Query() query) {
try {
const field = query['field'];
const textSearch = query['textsearch'];
const customers = await this.customerService.findCustomerByQuery(
field,
textSearch,
);
return new ResultModel(true, null, customers, null);
} catch (err) {
// 'Não foi possível consultar o cadastro de clientes.'
throw new HttpException(
new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@Get()
async getCustomer(@Query() query){
try{
const field = query['field'];
const textSearch = query['textsearch'];
const customers = await this.customerService.findCustomerByQuery(field, textSearch);
return new ResultModel(true, null, customers, null);
} catch(err){
// 'Não foi possível consultar o cadastro de clientes.'
throw new HttpException(new ResultModel(false, err.message, {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Get(':id')
async getCustomerById(@Param('id') id: number) {
try {
const customers = await this.customerService.findCustomerById(id);
return new ResultModel(true, null, customers, null);
} catch (err) {
throw new HttpException(
new ResultModel(
false,
'Não foi possível consultar o cadastro de clientes.',
{},
error,
),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
@Get(':id')
async getCustomerById(@Param('id') id: number){
try{
const customers = await this.customerService.findCustomerById(id);
return new ResultModel(true, null, customers, null);
} catch(err){
throw new HttpException(new ResultModel(false, 'Não foi possível consultar o cadastro de clientes.', {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Get('cpf/:cpf')
async getCustomerByCpf(@Param('cpf') cpf: string) {
try {
console.log('pesquisando por cpf');
const customer = await this.customerService.findCustomerByCpf(cpf);
if (!customer)
return new ResultModel(false, 'Cliente não cadastrado', null, null);
return new ResultModel(true, null, customer, null);
} catch (err) {
throw new HttpException(
new ResultModel(
false,
'Não foi possível consultar o cadastro de clientes.',
{},
error,
),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
@Get('cpf/:cpf')
async getCustomerByCpf(@Param('cpf') cpf: string){
try{
console.log("pesquisando por cpf");
const customer = await this.customerService.findCustomerByCpf(cpf);
if (!customer) return new ResultModel(false, 'Cliente não cadastrado', null, null);
return new ResultModel(true, null, customer, null);
} catch(err){
throw new HttpException(new ResultModel(false, 'Não foi possível consultar o cadastro de clientes.', {}, error),
HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@Get('create/proxnumcli')
async IdCustomer(){
try{
console.log('proxnumcli');
const id = await this.customerService.generateIdCustomer();
return new ResultModel(true, null, id, null);
} catch(err){
throw err;
}
}
@Get('create/proxnumcli')
async IdCustomer() {
try {
console.log('proxnumcli');
const id = await this.customerService.generateIdCustomer();
return new ResultModel(true, null, id, null);
} catch (err) {
throw err;
}
}
@Post('create')
async createCustomer(@Body() customer: Customer){
try{
console.log(customer);
const result = await this.customerService.createCustomer(customer);
return new ResultModel(true, null, result, null);
//return new ResultModel(true, null, id, null);
} catch(err){
throw new HttpException(new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
HttpStatus.INTERNAL_SERVER_ERROR);
}
@Post('create')
async createCustomer(@Body() customer: Customer) {
try {
console.log(customer);
const result = await this.customerService.createCustomer(customer);
return new ResultModel(true, null, result, null);
//return new ResultModel(true, null, id, null);
} catch (err) {
throw new HttpException(
new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,9 @@
"paths": {
"src/*": ["./src/*"]
},
"incremental": true
"incremental": true,
"skipLibCheck": true,
"strict": false
},
"exclude": ["node_modules", "dist"]
}