Compare commits

..

No commits in common. "main" and "feat/painel-cliente" have entirely different histories.

10 changed files with 149 additions and 140 deletions

View File

@ -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 }}"

2
.gitignore vendored
View File

@ -33,5 +33,3 @@ lerna-debug.log*
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
postgres-data/
.env

View File

@ -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"]

View File

@ -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

View File

@ -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')
@ -11,10 +11,10 @@ export class AppController {
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' };
} }
} }

View File

@ -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}'],

View File

@ -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();

View File

@ -132,15 +132,17 @@ 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,
);
} }
} }
} }

View File

@ -367,37 +367,66 @@ export class CustomerService {
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,
numberState: customer.numberState,
email: customer.email,
zipCode: customer.zipCode,
address: customer.address,
addressNumber: customer.addressNumber,
complement: customer.complement,
neighborhood: customer.neighborhood, neighborhood: customer.neighborhood,
city: customer.city, state: customer.state, city: customer.city,
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone, state: customer.state,
category: customer.category, subCategory: customer.subCategory, allowMessage: customer.allowMessage,
place: customer.place, ramo: customer.ramo, meiocomunicacao: customer.communicate, cellPhone: customer.cellPhone,
latitude: customer.latitude, longitude: customer.longitude, ibgeCode: customer.ibgeCode, category: customer.category,
subCategory: customer.subCategory,
place: customer.place,
ramo: customer.ramo,
meiocomunicacao: customer.communicate,
latitude: customer.latitude,
longitude: customer.longitude,
ibgeCode: customer.ibgeCode,
addressType: customer.addressType, addressType: customer.addressType,
}; };
} else { } else {
const idCustomer = await this.generateIdCustomer(); const idCustomer = await this.generateIdCustomer();
if (idCustomer == -1) if (idCustomer == -1)
return new HttpException("Erro ao gerar númeração de cliente.", HttpStatus.INTERNAL_SERVER_ERROR); return new HttpException(
'Erro ao gerar númeração de cliente.',
HttpStatus.INTERNAL_SERVER_ERROR,
);
newCustomer.codcli = idCustomer; newCustomer.codcli = idCustomer;
await this.insertCustomer(newCustomer); await this.insertCustomer(newCustomer);
return { return {
customerId: idCustomer, customerId: idCustomer,
company: customer.company, name: customer.name, company: customer.company,
cpfCnpj: customer.cpfCnpj, gender: customer.gender, numberState: customer.numberState, name: customer.name,
email: customer.email, zipCode: customer.zipCode, address: customer.address, cpfCnpj: customer.cpfCnpj,
addressNumber: customer.addressNumber, complement: customer.complement, gender: customer.gender,
numberState: customer.numberState,
email: customer.email,
zipCode: customer.zipCode,
address: customer.address,
addressNumber: customer.addressNumber,
complement: customer.complement,
neighborhood: customer.neighborhood, neighborhood: customer.neighborhood,
city: customer.city, state: customer.state, city: customer.city,
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone, state: customer.state,
category: customer.category, subCategory: customer.subCategory, allowMessage: customer.allowMessage,
place: customer.place, meiocomunicacao: customer.communicate, cellPhone: customer.cellPhone,
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude, category: customer.category,
ibgeCode: customer.ibgeCode, addressType: customer.addressType, 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) { } catch (error) {

View File

@ -1506,6 +1506,12 @@ export class SalesService {
async calculateDeliveryTaxOrder(dataDeliveryTax: any) { async calculateDeliveryTaxOrder(dataDeliveryTax: any) {
console.log("json dataDeliveryTax", dataDeliveryTax); console.log("json dataDeliveryTax", dataDeliveryTax);
/*const dataDeliveryTax = {
cartId: cartId,
cityId: cityId,
ibgeCode: ibgeCode,
priorityDelivery: priorityDelivery,
};*/
let cityId = 0; let cityId = 0;
if (dataDeliveryTax.ibgeCode) { if (dataDeliveryTax.ibgeCode) {