Compare commits
36 Commits
feat/paine
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
15d8fecf42 | |
|
|
c5f284023a | |
|
|
df466ddaba | |
|
|
6360675ebf | |
|
|
cedcb43939 | |
|
|
b330910fbf | |
|
|
94f9208ee4 | |
|
|
4e926909b8 | |
|
|
70e88913f5 | |
|
|
217329adef | |
|
|
f55d0da72d | |
|
|
2b91449137 | |
|
|
95850ea39b | |
|
|
1760934db3 | |
|
|
7b2f13ab91 | |
|
|
f66fd4271f | |
|
|
c60eabd804 | |
|
|
9176d65606 | |
|
|
1fa2938128 | |
|
|
efc7d738a9 | |
|
|
bf246e2882 | |
|
|
fb724067c8 | |
|
|
e9c7d8d282 | |
|
|
a92fa77e37 | |
|
|
e6fd33a22e | |
|
|
c75f8ed9f4 | |
|
|
b034330e34 | |
|
|
61cdae600c | |
|
|
6fe94a4a7c | |
|
|
0084a162f7 | |
|
|
d5fa17151f | |
|
|
937b3f37ab | |
|
|
7022d491ce | |
|
|
c4e8996a22 | |
|
|
757d547755 | |
|
|
79fb04fdb5 |
|
|
@ -0,0 +1,30 @@
|
||||||
|
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,3 +33,5 @@ lerna-debug.log*
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
postgres-data/
|
||||||
|
.env
|
||||||
|
|
|
||||||
42
Dockerfile
42
Dockerfile
|
|
@ -1,32 +1,24 @@
|
||||||
FROM node:16
|
FROM node:16-bullseye-slim AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install --legacy-peer-deps
|
||||||
|
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 apt-get update && apt-get install -y \
|
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/client.zip && \
|
||||||
apt-transport-https \
|
unzip /opt/oracle/client.zip -d /opt/oracle && \
|
||||||
ca-certificates \
|
rm /opt/oracle/client.zip && \
|
||||||
libaio1 \
|
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/package*.json ./
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
COPY package*.json ./
|
EXPOSE 8068
|
||||||
|
|
||||||
|
|
||||||
RUN npm install --legacy-peer-deps
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
|
|
||||||
CMD ["npm", "run", "start:prod"]
|
CMD ["npm", "run", "start:prod"]
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
vendaweb:
|
vendaweb-api:
|
||||||
image: link70/vendaweb
|
image: 10.1.1.124:8082/library/vendaweb-api:latest
|
||||||
deploy:
|
|
||||||
replicas: 20
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: '0.5'
|
|
||||||
memory: 512M
|
|
||||||
ports:
|
ports:
|
||||||
- "8065:8065"
|
- "8068:8068"
|
||||||
restart: always
|
networks:
|
||||||
|
- simplifique-network
|
||||||
|
deploy:
|
||||||
|
replicas: 4
|
||||||
|
update_config:
|
||||||
|
order: start-first
|
||||||
|
parallelism: 1
|
||||||
|
|
||||||
|
networks:
|
||||||
|
simplifique-network:
|
||||||
|
external: true
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
import { ApiOperation, ApiTags } 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: 'ok' };
|
return { status: 'TESTE COM Felipe2 ' };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ export const typeOrmConfig: TypeOrmModuleOptions = {
|
||||||
// username: "LIVIA",
|
// username: "LIVIA",
|
||||||
// password: "LIVIA",
|
// password: "LIVIA",
|
||||||
host: "10.1.1.241",
|
host: "10.1.1.241",
|
||||||
username: "SEVEN",
|
username: "teste",
|
||||||
password: "USR54SEV",
|
password: "teste",
|
||||||
// username: "API",
|
// username: "API",
|
||||||
// password: "E05H5KIEQV3YKDJR",
|
// password: "E05H5KIEQV3YKDJR",
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
sid: "BDTESTE",
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
|
|
@ -22,10 +22,10 @@ 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: "teste",
|
||||||
password: "USR54SEV",
|
password: "teste",
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
sid: "BDTESTE",
|
||||||
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(8065);
|
await app.listen(8068, '0.0.0.0');}
|
||||||
}
|
console.log('API rodando na porta 8065 test 4');
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
@ -1503,6 +1503,7 @@ export class SalesService {
|
||||||
|
|
||||||
async calculateDeliveryTaxOrder(dataDeliveryTax: any) {
|
async calculateDeliveryTaxOrder(dataDeliveryTax: any) {
|
||||||
let cityId = await this.customerService.findCity(dataDeliveryTax.ibgeCode);
|
let cityId = await this.customerService.findCity(dataDeliveryTax.ibgeCode);
|
||||||
|
|
||||||
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