feat/painel-cliente #2
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"cweijan.dbclient-jdbc"
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,17 +2,17 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
|
||||||
export const typeOrmConfig: TypeOrmModuleOptions = {
|
export const typeOrmConfig: TypeOrmModuleOptions = {
|
||||||
type: "oracle",
|
type: 'oracle',
|
||||||
// host: "192.168.100.40",
|
// host: "192.168.100.40",
|
||||||
// username: "LIVIA",
|
// username: "LIVIA",
|
||||||
// password: "LIVIA",
|
// password: "LIVIA",
|
||||||
host: "10.1.1.241",
|
host: '10.1.1.241',
|
||||||
username: "SEVEN",
|
username: 'SEVEN',
|
||||||
password: "USR54SEV",
|
password: 'USR54SEV',
|
||||||
// username: "API",
|
// username: "API",
|
||||||
// password: "E05H5KIEQV3YKDJR",
|
// password: "E05H5KIEQV3YKDJR",
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
serviceName: 'WINT',
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
|
|
@ -20,14 +20,13 @@ export const typeOrmConfig: TypeOrmModuleOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const connectionOptions: ConnectionOptions = {
|
export const connectionOptions: ConnectionOptions = {
|
||||||
type: "oracle",
|
type: 'oracle',
|
||||||
host: "10.1.1.241",
|
host: '10.1.1.241',
|
||||||
username: "SEVEN",
|
username: 'SEVEN',
|
||||||
password: "USR54SEV",
|
password: 'USR54SEV',
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
serviceName: 'WINT',
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,109 +1,148 @@
|
||||||
import { Body, Controller, Get, HttpException, HttpStatus, Param, Post, Query } from '@nestjs/common';
|
import {
|
||||||
import { CustomerService } from './customer.service';
|
Body,
|
||||||
import { ResultModel } from '../../domain/models/result.model';
|
Controller,
|
||||||
|
Get,
|
||||||
|
HttpException,
|
||||||
|
HttpStatus,
|
||||||
|
Param,
|
||||||
|
Post,
|
||||||
|
Query,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { error } from 'console';
|
import { error } from 'console';
|
||||||
import { Customer } from 'src/domain/models/customer.model';
|
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')
|
@ApiTags('Customer')
|
||||||
@Controller('api/v1/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')
|
@Get('categories/fechAll')
|
||||||
async getCustomerByName(@Param('name') name: string){
|
async getCategories() {
|
||||||
try{
|
try {
|
||||||
const customers = await this.customerService.findCustomerByName(name);
|
const categories = await this.customerService.getCategory();
|
||||||
return new ResultModel(true, null, customers, null);
|
return categories;
|
||||||
} catch(err){
|
} catch (err) {
|
||||||
throw new HttpException(new ResultModel(false, 'Não foi possível consultar o cadastro de clientes.', {}, error),
|
throw new HttpException(
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
new ResultModel(false, err.message, {}, error),
|
||||||
}
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Get('categories/fechAll')
|
@Get('subcategories/fechAll')
|
||||||
async getCategories(){
|
async getSubCategories() {
|
||||||
try{
|
try {
|
||||||
const categories = await this.customerService.getCategory();
|
const subCategories = await this.customerService.getSubCategory();
|
||||||
return categories;
|
return subCategories;
|
||||||
} catch(err){
|
} catch (err) {
|
||||||
throw new HttpException(new ResultModel(false, err.message, {}, error),
|
throw new HttpException(
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
new ResultModel(false, err.message, {}, error),
|
||||||
}
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Get('subcategories/fechAll')
|
@Get()
|
||||||
async getSubCategories(){
|
async getCustomer(@Query() query) {
|
||||||
try{
|
try {
|
||||||
const subCategories = await this.customerService.getSubCategory();
|
const field = query['field'];
|
||||||
return subCategories;
|
const textSearch = query['textsearch'];
|
||||||
} catch(err){
|
const customers = await this.customerService.findCustomerByQuery(
|
||||||
throw new HttpException(new ResultModel(false, err.message, {}, error),
|
field,
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
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')
|
||||||
@Get()
|
async getCustomerById(@Param('id') id: number) {
|
||||||
async getCustomer(@Query() query){
|
try {
|
||||||
try{
|
const customers = await this.customerService.findCustomerById(id);
|
||||||
const field = query['field'];
|
return new ResultModel(true, null, customers, null);
|
||||||
const textSearch = query['textsearch'];
|
} catch (err) {
|
||||||
const customers = await this.customerService.findCustomerByQuery(field, textSearch);
|
throw new HttpException(
|
||||||
return new ResultModel(true, null, customers, null);
|
new ResultModel(
|
||||||
} catch(err){
|
false,
|
||||||
// 'Não foi possível consultar o cadastro de clientes.'
|
'Não foi possível consultar o cadastro de clientes.',
|
||||||
throw new HttpException(new ResultModel(false, err.message, {}, error),
|
{},
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
error,
|
||||||
}
|
),
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get('cpf/:cpf')
|
||||||
async getCustomerById(@Param('id') id: number){
|
async getCustomerByCpf(@Param('cpf') cpf: string) {
|
||||||
try{
|
try {
|
||||||
const customers = await this.customerService.findCustomerById(id);
|
console.log('pesquisando por cpf');
|
||||||
return new ResultModel(true, null, customers, null);
|
const customer = await this.customerService.findCustomerByCpf(cpf);
|
||||||
} catch(err){
|
if (!customer)
|
||||||
throw new HttpException(new ResultModel(false, 'Não foi possível consultar o cadastro de clientes.', {}, error),
|
return new ResultModel(false, 'Cliente não cadastrado', null, null);
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
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')
|
@Get('create/proxnumcli')
|
||||||
async getCustomerByCpf(@Param('cpf') cpf: string){
|
async IdCustomer() {
|
||||||
try{
|
try {
|
||||||
console.log("pesquisando por cpf");
|
console.log('proxnumcli');
|
||||||
const customer = await this.customerService.findCustomerByCpf(cpf);
|
const id = await this.customerService.generateIdCustomer();
|
||||||
if (!customer) return new ResultModel(false, 'Cliente não cadastrado', null, null);
|
return new ResultModel(true, null, id, null);
|
||||||
return new ResultModel(true, null, customer, null);
|
} catch (err) {
|
||||||
} catch(err){
|
throw 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('create')
|
||||||
@Post('create')
|
async createCustomer(@Body() customer: Customer) {
|
||||||
async createCustomer(@Body() customer: Customer){
|
try {
|
||||||
try{
|
console.log(customer);
|
||||||
console.log(customer);
|
const result = await this.customerService.createCustomer(customer);
|
||||||
const result = await this.customerService.createCustomer(customer);
|
return new ResultModel(true, null, result, null);
|
||||||
return new ResultModel(true, null, result, null);
|
//return new ResultModel(true, null, id, null);
|
||||||
//return new ResultModel(true, null, id, null);
|
} catch (err) {
|
||||||
} catch(err){
|
throw new HttpException(
|
||||||
throw new HttpException(new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
|
new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,7 +13,9 @@
|
||||||
"paths": {
|
"paths": {
|
||||||
"src/*": ["./src/*"]
|
"src/*": ["./src/*"]
|
||||||
},
|
},
|
||||||
"incremental": true
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": false
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue