Compare commits
No commits in common. "main" and "feat/painel-cliente" have entirely different histories.
main
...
feat/paine
|
|
@ -1,30 +0,0 @@
|
||||||
name: Deploy NestJS API
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push-deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Login no Harbor
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 10.1.1.124:8082 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin
|
|
||||||
|
|
||||||
- name: Build e Push
|
|
||||||
run: |
|
|
||||||
# Usando o short SHA para uma tag mais limpa
|
|
||||||
TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
|
||||||
IMAGE_NAME="10.1.1.124:8082/library/vendaweb-api"
|
|
||||||
|
|
||||||
docker build -t $IMAGE_NAME:$TAG .
|
|
||||||
docker tag $IMAGE_NAME:$TAG $IMAGE_NAME:latest
|
|
||||||
|
|
||||||
docker push $IMAGE_NAME:$TAG
|
|
||||||
docker push $IMAGE_NAME:latest
|
|
||||||
|
|
||||||
- name: Notificar Portainer via Webhook
|
|
||||||
run: |
|
|
||||||
# O segredo PORTAINER_WEBHOOK_VENDAWEBAPI deve conter a URL completa gerada na Stack
|
|
||||||
curl -f -X POST "${{ secrets.PORTAINER_WEBHOOK_VENDAWEBAPI }}"
|
|
||||||
|
|
@ -33,5 +33,3 @@ lerna-debug.log*
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
||||||
postgres-data/
|
|
||||||
.env
|
|
||||||
|
|
|
||||||
44
Dockerfile
44
Dockerfile
|
|
@ -1,24 +1,32 @@
|
||||||
FROM node:16-bullseye-slim AS builder
|
FROM node:16
|
||||||
|
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
apt-transport-https \
|
||||||
|
ca-certificates \
|
||||||
|
libaio1 \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
libc6 \
|
||||||
|
libncurses5 && \
|
||||||
|
mkdir -p /opt/oracle && \
|
||||||
|
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/instantclient-basic-linuxx64.zip && \
|
||||||
|
unzip /opt/oracle/instantclient-basic-linuxx64.zip -d /opt/oracle && \
|
||||||
|
rm /opt/oracle/instantclient-basic-linuxx64.zip && \
|
||||||
|
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient && \
|
||||||
|
echo "/opt/oracle/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && \
|
||||||
|
ldconfig
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install --legacy-peer-deps
|
|
||||||
|
|
||||||
|
RUN npm install --legacy-peer-deps
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
FROM node:16-bullseye-slim
|
|
||||||
RUN apt-get update && apt-get install -y libaio1 unzip wget && mkdir -p /opt/oracle
|
|
||||||
|
|
||||||
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/client.zip && \
|
|
||||||
unzip /opt/oracle/client.zip -d /opt/oracle && \
|
|
||||||
rm /opt/oracle/client.zip && \
|
|
||||||
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient
|
|
||||||
|
|
||||||
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
COPY --from=builder /app/package*.json ./
|
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
|
||||||
|
|
||||||
EXPOSE 8068
|
|
||||||
CMD ["npm", "run", "start:prod"]
|
CMD ["npm", "run", "start:prod"]
|
||||||
|
|
@ -1,18 +1,14 @@
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
vendaweb-api:
|
vendaweb:
|
||||||
image: 10.1.1.124:8082/library/vendaweb-api:latest
|
image: link70/vendaweb
|
||||||
ports:
|
|
||||||
- "8068:8068"
|
|
||||||
networks:
|
|
||||||
- simplifique-network
|
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 4
|
replicas: 20
|
||||||
update_config:
|
resources:
|
||||||
order: start-first
|
limits:
|
||||||
parallelism: 1
|
cpus: '0.5'
|
||||||
|
memory: 512M
|
||||||
networks:
|
ports:
|
||||||
simplifique-network:
|
- "8065:8065"
|
||||||
external: true
|
restart: always
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||||
import { APP_VERSION } from './version';
|
import { APP_VERSION } from './version';
|
||||||
|
|
||||||
@ApiTags('Main')
|
@ApiTags('Main')
|
||||||
|
|
@ -8,13 +8,13 @@ export class AppController {
|
||||||
@Get('version')
|
@Get('version')
|
||||||
@ApiOperation({ summary: 'Get App Version' })
|
@ApiOperation({ summary: 'Get App Version' })
|
||||||
getVersion() {
|
getVersion() {
|
||||||
return { version: APP_VERSION };
|
return { version: APP_VERSION };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('health')
|
@Get('health')
|
||||||
@ApiOperation({ summary: 'Health check' })
|
@ApiOperation({ summary: 'Health check' })
|
||||||
healthCheck() {
|
healthCheck() {
|
||||||
return { status: 'TESTE COM Felipe2 ' };
|
return { status: 'ok' };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,12 +20,12 @@ 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}'],
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,6 @@ async function bootstrap() {
|
||||||
.build();
|
.build();
|
||||||
const document = SwaggerModule.createDocument(app, options);
|
const document = SwaggerModule.createDocument(app, options);
|
||||||
SwaggerModule.setup("docs", app, document);
|
SwaggerModule.setup("docs", app, document);
|
||||||
await app.listen(8068, '0.0.0.0');}
|
await app.listen(8065);
|
||||||
console.log('API rodando na porta 8065 test 4');
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
|
|
@ -131,16 +131,18 @@ export class CustomerController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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(new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
|
throw new HttpException(
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
new ResultModel(false, 'Erro ao cadastrar cliente.', {}, err),
|
||||||
}
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -360,50 +360,79 @@ export class CustomerService {
|
||||||
newCustomer.longitude = customer.longitude;
|
newCustomer.longitude = customer.longitude;
|
||||||
newCustomer.tipoendereco = customer.addressType;
|
newCustomer.tipoendereco = customer.addressType;
|
||||||
|
|
||||||
const oldCustomer = await this.findCustomerByCpf(newCustomer.cgcent);
|
const oldCustomer = await this.findCustomerByCpf(newCustomer.cgcent);
|
||||||
if (oldCustomer) {
|
if (oldCustomer) {
|
||||||
console.log('Cliente localizado: ' + oldCustomer.customerId);
|
console.log('Cliente localizado: ' + oldCustomer.customerId);
|
||||||
newCustomer.codcli = oldCustomer.customerId;
|
newCustomer.codcli = oldCustomer.customerId;
|
||||||
await this.updateCustomer(newCustomer);
|
await this.updateCustomer(newCustomer);
|
||||||
return {
|
return {
|
||||||
customerId: oldCustomer.customerId,
|
customerId: oldCustomer.customerId,
|
||||||
company: customer.company, name: customer.name, sexo: customer.gender,
|
company: customer.company,
|
||||||
cpfCnpj: customer.cpfCnpj, numberState: customer.numberState,
|
name: customer.name,
|
||||||
email: customer.email, zipCode: customer.zipCode, address: customer.address,
|
sexo: customer.gender,
|
||||||
addressNumber: customer.addressNumber, complement: customer.complement,
|
cpfCnpj: customer.cpfCnpj,
|
||||||
neighborhood: customer.neighborhood,
|
numberState: customer.numberState,
|
||||||
city: customer.city, state: customer.state,
|
email: customer.email,
|
||||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
zipCode: customer.zipCode,
|
||||||
category: customer.category, subCategory: customer.subCategory,
|
address: customer.address,
|
||||||
place: customer.place, ramo: customer.ramo, meiocomunicacao: customer.communicate,
|
addressNumber: customer.addressNumber,
|
||||||
latitude: customer.latitude, longitude: customer.longitude, ibgeCode: customer.ibgeCode,
|
complement: customer.complement,
|
||||||
addressType: customer.addressType,
|
neighborhood: customer.neighborhood,
|
||||||
};
|
city: customer.city,
|
||||||
} else {
|
state: customer.state,
|
||||||
const idCustomer = await this.generateIdCustomer();
|
allowMessage: customer.allowMessage,
|
||||||
if (idCustomer == -1)
|
cellPhone: customer.cellPhone,
|
||||||
return new HttpException("Erro ao gerar númeração de cliente.", HttpStatus.INTERNAL_SERVER_ERROR);
|
category: customer.category,
|
||||||
newCustomer.codcli = idCustomer;
|
subCategory: customer.subCategory,
|
||||||
await this.insertCustomer(newCustomer);
|
place: customer.place,
|
||||||
return {
|
ramo: customer.ramo,
|
||||||
customerId: idCustomer,
|
meiocomunicacao: customer.communicate,
|
||||||
company: customer.company, name: customer.name,
|
latitude: customer.latitude,
|
||||||
cpfCnpj: customer.cpfCnpj, gender: customer.gender, numberState: customer.numberState,
|
longitude: customer.longitude,
|
||||||
email: customer.email, zipCode: customer.zipCode, address: customer.address,
|
ibgeCode: customer.ibgeCode,
|
||||||
addressNumber: customer.addressNumber, complement: customer.complement,
|
addressType: customer.addressType,
|
||||||
neighborhood: customer.neighborhood,
|
};
|
||||||
city: customer.city, state: customer.state,
|
} else {
|
||||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
const idCustomer = await this.generateIdCustomer();
|
||||||
category: customer.category, subCategory: customer.subCategory,
|
if (idCustomer == -1)
|
||||||
place: customer.place, meiocomunicacao: customer.communicate,
|
return new HttpException(
|
||||||
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude,
|
'Erro ao gerar númeração de cliente.',
|
||||||
ibgeCode: customer.ibgeCode, addressType: customer.addressType,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
};
|
);
|
||||||
}
|
newCustomer.codcli = idCustomer;
|
||||||
} catch (error) {
|
await this.insertCustomer(newCustomer);
|
||||||
throw error;
|
return {
|
||||||
}
|
customerId: idCustomer,
|
||||||
|
company: customer.company,
|
||||||
|
name: customer.name,
|
||||||
|
cpfCnpj: customer.cpfCnpj,
|
||||||
|
gender: customer.gender,
|
||||||
|
numberState: customer.numberState,
|
||||||
|
email: customer.email,
|
||||||
|
zipCode: customer.zipCode,
|
||||||
|
address: customer.address,
|
||||||
|
addressNumber: customer.addressNumber,
|
||||||
|
complement: customer.complement,
|
||||||
|
neighborhood: customer.neighborhood,
|
||||||
|
city: customer.city,
|
||||||
|
state: customer.state,
|
||||||
|
allowMessage: customer.allowMessage,
|
||||||
|
cellPhone: customer.cellPhone,
|
||||||
|
category: customer.category,
|
||||||
|
subCategory: customer.subCategory,
|
||||||
|
place: customer.place,
|
||||||
|
meiocomunicacao: customer.communicate,
|
||||||
|
ramo: customer.ramo,
|
||||||
|
latitude: customer.latitude,
|
||||||
|
longitude: customer.longitude,
|
||||||
|
ibgeCode: customer.ibgeCode,
|
||||||
|
addressType: customer.addressType,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async updateCustomer(client: Pcclient) {
|
async updateCustomer(client: Pcclient) {
|
||||||
const connection = new Connection(connectionOptions);
|
const connection = new Connection(connectionOptions);
|
||||||
|
|
|
||||||
|
|
@ -1505,10 +1505,6 @@ export class SalesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async calculateDeliveryTaxOrder(dataDeliveryTax: any) {
|
async calculateDeliveryTaxOrder(dataDeliveryTax: any) {
|
||||||
<<<<<<< HEAD
|
|
||||||
let cityId = await this.customerService.findCity(dataDeliveryTax.ibgeCode);
|
|
||||||
|
|
||||||
=======
|
|
||||||
console.log("json dataDeliveryTax", dataDeliveryTax);
|
console.log("json dataDeliveryTax", dataDeliveryTax);
|
||||||
/*const dataDeliveryTax = {
|
/*const dataDeliveryTax = {
|
||||||
cartId: cartId,
|
cartId: cartId,
|
||||||
|
|
@ -1523,7 +1519,6 @@ export class SalesService {
|
||||||
} else {
|
} else {
|
||||||
cityId = dataDeliveryTax.cityId;
|
cityId = dataDeliveryTax.cityId;
|
||||||
}
|
}
|
||||||
>>>>>>> feat/painel-cliente
|
|
||||||
await this.updatePriorityDelivery(dataDeliveryTax.cartId, dataDeliveryTax.priorityDelivery);
|
await this.updatePriorityDelivery(dataDeliveryTax.cartId, dataDeliveryTax.priorityDelivery);
|
||||||
|
|
||||||
if (cityId == 0) {
|
if (cityId == 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue