Compare commits
26 Commits
4003aab9e0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16882046cf | ||
| fd17be5408 | |||
|
|
ecd298442b | ||
| 589fa2913c | |||
| 587d097d9b | |||
| a694af97c6 | |||
| 6523c5f520 | |||
| 0c09ee795e | |||
| 09396e334d | |||
| 605d68b4b0 | |||
| c707d4a065 | |||
| 0b28379145 | |||
| ca43de8756 | |||
| bb21ca33e4 | |||
| 48d6e64ada | |||
| e0731db836 | |||
| d2265390bd | |||
| a34c7c415c | |||
| 4975d5547d | |||
| fa6f0e0f49 | |||
| c9335a27e5 | |||
| f2b629eaad | |||
| 3b8b079123 | |||
| 1270c04a2c | |||
|
|
ca892daffa | ||
| 8e09813741 |
@@ -1,27 +1,41 @@
|
||||
name: Deploy NestJS API
|
||||
on: [push]
|
||||
name: Build (develop) / Promote (main)
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build-and-push-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login no Harbor
|
||||
- name: Build and Push
|
||||
run: |
|
||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 172.35.0.216 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin
|
||||
REGISTRY="git.simplifiquehc.com.br"
|
||||
IMAGE_NAME="$REGISTRY/simplifique/vendaweb-api"
|
||||
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||
|
||||
- name: Build e Push
|
||||
echo "${{ secrets.K8S }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" .
|
||||
docker push "$IMAGE_NAME:$SHA_TAG"
|
||||
docker push "$IMAGE_NAME:latest"
|
||||
|
||||
- name: Update Manifest and Push to Git
|
||||
run: |
|
||||
TAG=${{ gitea.sha }}
|
||||
docker build -t 172.35.0.216/library/vendaweb-api:$TAG .
|
||||
docker tag 172.35.0.216/library/vendaweb-api:$TAG 172.35.0.216/library/vendaweb-api:latest
|
||||
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||
IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api"
|
||||
|
||||
docker push 172.35.0.216/library/vendaweb-api:$TAG
|
||||
docker push 172.35.0.216/library/vendaweb-api:latest
|
||||
MANIFEST_FILE="k8s/overlays/prod/deployment-image-digest-patch.yaml"
|
||||
|
||||
- name: Notificar Portainer via Webhook
|
||||
run: |
|
||||
# O Webhook avisa o Portainer para puxar a nova imagem imediatamente
|
||||
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_VENDAWEBAPI }}"
|
||||
sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" "$MANIFEST_FILE"
|
||||
|
||||
git config user.name "Gitea Action"
|
||||
git config user.email "actions@simplifiquehc.com.br"
|
||||
|
||||
git add "$MANIFEST_FILE"
|
||||
git commit -m "chore: update image tag to $SHA_TAG [skip ci]"
|
||||
git push origin main
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
O Rollback via Git (Mais Seguro)
|
||||
|
||||
No Gitea, faça um git revert no commit que deu erro.
|
||||
|
||||
Dê o git push.
|
||||
|
||||
O Portainer detectará a mudança e atualizará o serviço para a versão estável de forma oficial.
|
||||
70
Dockerfile
70
Dockerfile
@@ -1,39 +1,55 @@
|
||||
# Estágio 1: Build
|
||||
FROM node:16-bullseye-slim AS builder
|
||||
ARG NODE_VERSION=16.20
|
||||
ARG DEBIAN_VARIANT=bullseye
|
||||
|
||||
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT} AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install --legacy-peer-deps
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM node:16-bullseye-slim
|
||||
# Instalar dependências do Oracle
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libaio1 \
|
||||
unzip \
|
||||
wget \
|
||||
&& mkdir -p /opt/oracle
|
||||
ARG INSTANTCLIENT_ZIP_URL=https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates wget unzip libaio1 libnsl2 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /opt/oracle \
|
||||
&& wget -q "${INSTANTCLIENT_ZIP_URL}" -O /opt/oracle/instantclient.zip \
|
||||
&& unzip -q /opt/oracle/instantclient.zip -d /opt/oracle \
|
||||
&& rm /opt/oracle/instantclient.zip \
|
||||
&& rm -f /opt/oracle/instantclient_*/ojdbc*.jar \
|
||||
/opt/oracle/instantclient_*/ucp*.jar \
|
||||
/opt/oracle/instantclient_*/xstreams.jar \
|
||||
/opt/oracle/instantclient_*/adrci \
|
||||
/opt/oracle/instantclient_*/genezi \
|
||||
/opt/oracle/instantclient_*/uidrvci \
|
||||
&& ln -s "$(ls -d /opt/oracle/instantclient_* | head -n 1)" /opt/oracle/instantclient
|
||||
|
||||
# Instalar Oracle Instant Client
|
||||
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
|
||||
|
||||
# Configurar o sistema para encontrar as bibliotecas do Oracle
|
||||
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||
RUN echo "/opt/oracle/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
|
||||
ENV PATH=/opt/oracle/instantclient:$PATH
|
||||
|
||||
COPY package*.json ./
|
||||
ENV NPM_CONFIG_LEGACY_PEER_DEPS=true
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
RUN npm run build \
|
||||
&& npm prune --omit=dev --legacy-peer-deps \
|
||||
&& npm cache clean --force
|
||||
|
||||
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT}-slim AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar apenas o necessário do estágio anterior
|
||||
COPY --from=builder /app/dist ./dist
|
||||
ENV NODE_ENV=production
|
||||
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||
ENV PATH=/opt/oracle/instantclient:$PATH
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libaio1 libnsl2 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /opt/oracle /opt/oracle
|
||||
COPY --from=builder /app/package*.json ./
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Variáveis de ambiente padrão para o driver oracledb
|
||||
ENV OCI_LIB_DIR=/opt/oracle/instantclient
|
||||
ENV OCI_INC_DIR=/opt/oracle/instantclient/sdk/include
|
||||
EXPOSE 8065
|
||||
|
||||
CMD ["npm", "run", "start:prod"]
|
||||
CMD ["node", "dist/main"]
|
||||
|
||||
76
KUBERNETES.md
Normal file
76
KUBERNETES.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Documentação do Kubernetes
|
||||
|
||||
Este documento descreve a infraestrutura e configuração do Kubernetes para o projeto **Vendaweb-api**, utilizando uma abordagem GitOps com ArgoCD e Kustomize.
|
||||
|
||||
## Estrutura de Diretórios e Arquivos
|
||||
|
||||
A configuração do Kubernetes está localizada no diretório `k8s/` e segue uma estrutura organizada para facilitar a manutenção e escalabilidade:
|
||||
|
||||
```
|
||||
k8s/
|
||||
├── argocd/ # Configurações do ArgoCD
|
||||
│ └── application-prod.yaml # Definição da Application para o ambiente de produção
|
||||
├── base/ # Recursos base do Kubernetes (Kustomize Base)
|
||||
│ ├── configmap.yaml # ConfigMap base
|
||||
│ ├── deployment.yaml # Deployment base da aplicação
|
||||
│ ├── kustomization.yaml # Arquivo principal do Kustomize Base
|
||||
│ ├── secret.yaml # Secret base
|
||||
│ └── service.yaml # Service base
|
||||
└── overlays/ # Sobrescritas para diferentes ambientes (Kustomize Overlays)
|
||||
└── prod/ # Ambiente de produção
|
||||
├── application-prod.yaml
|
||||
├── deployment-image-digest-patch.yaml
|
||||
├── kustomization.yaml
|
||||
└── service-patch.yaml
|
||||
```
|
||||
|
||||
## Recursos Base (`k8s/base`)
|
||||
|
||||
O diretório `base` contém as definições padrão dos recursos que são comuns a todos os ambientes.
|
||||
|
||||
### Deployment (`deployment.yaml`)
|
||||
|
||||
- **Nome**: `vendaweb-api`
|
||||
- **Replicas**: 3 (Base) / 15 (Produção via overlay)
|
||||
- **Imagem**: `git.simplifiquehc.com.br/simplifique/vendaweb-api:<sha>`
|
||||
- **Porta do Container**: 8067
|
||||
- **Resources**:
|
||||
- Requests: CPU 100m, Memory 256Mi
|
||||
- Limits: CPU 500m, Memory 512Mi
|
||||
- **Probes**: Liveness, Readiness e Startup probes configurados no endpoint `/v1/health`.
|
||||
- **Environment**: Configurações carregadas via ConfigMap e Secret.
|
||||
|
||||
### Service (`service.yaml`)
|
||||
|
||||
- **Tipo**: ClusterIP
|
||||
- **Porta**: 8065 (TCP)
|
||||
|
||||
## Ambientes (`k8s/overlays`)
|
||||
|
||||
### Produção (`k8s/overlays/prod`)
|
||||
|
||||
A sobreposição de produção personaliza a configuração base para o ambiente produtivo.
|
||||
|
||||
- **Namespace**: `vendaweb-prod`
|
||||
- **Patches**: Aplica modificações específicas (ex: tag da imagem, NodePort do service, replicas) via `kustomization.yaml`.
|
||||
|
||||
## Deploy com ArgoCD (`k8s/argocd`)
|
||||
|
||||
O deploy é gerenciado pelo ArgoCD, que sincroniza o estado do cluster com o repositório Git.
|
||||
|
||||
### Application (`application-prod.yaml`)
|
||||
|
||||
- **Nome**: `vendaweb-api-prod`
|
||||
- **Namespace do ArgoCD**: `argocd`
|
||||
- **Origem (Source)**:
|
||||
- Repositório: `https://git.simplifiquehc.com.br/simplifique/Vendaweb-api.git`
|
||||
- Revisão: `main`
|
||||
- Path: `k8s/overlays/prod` (Aponta para o overlay de produção)
|
||||
- **Destino (Destination)**:
|
||||
- Cluster: `https://kubernetes.default.svc`
|
||||
- Namespace: `vendaweb-prod`
|
||||
- **Sync Policy**: Automatizado com `selfHeal` ativado e criação automática de namespace.
|
||||
|
||||
---
|
||||
|
||||
**Observação**: Certifique-se de que as credenciais do Harbor (`imagePullSecrets`) estejam corretamente configuradas no namespace de destino para permitir o pull da imagem.
|
||||
60
WORKFLOWS.md
Normal file
60
WORKFLOWS.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Documentação dos Workflows (Gitea Actions)
|
||||
|
||||
Este documento descreve os fluxos de trabalho de integração contínua (CI) e entrega contínua (CD) configurados no Gitea Actions para o projeto **Vendaweb-api**.
|
||||
|
||||
## Visão Geral
|
||||
|
||||
Os workflows estão definidos no diretório `.gitea/workflows/`. O principal workflow configurado é o deploy da API.
|
||||
|
||||
## Workflow: Deploy NestJS API
|
||||
|
||||
**Arquivo**: `.gitea/workflows/deploy-api.yaml`
|
||||
|
||||
### Gatilhos (Triggers)
|
||||
|
||||
Este workflow é acionado automaticamente no evento:
|
||||
|
||||
- `push`: Na branch `main`.
|
||||
|
||||
### Jobs
|
||||
|
||||
#### `build-and-push-deploy`
|
||||
|
||||
Este job é responsável por construir a imagem Docker e enviá-la para o registry privado (Harbor).
|
||||
|
||||
- **Ambiente de Execução**: `ubuntu-latest` (Runner)
|
||||
|
||||
#### Passos (Steps):
|
||||
|
||||
1. **Checkout**
|
||||
- Utiliza `actions/checkout@v3` para clonar o código fonte do repositório.
|
||||
|
||||
2. **Login no Harbor**
|
||||
- Realiza autenticação no registry Docker privado.
|
||||
- **Registry**: `172.35.0.216`
|
||||
- **Segredos Utilizados**:
|
||||
- `HARBOR_USERNAME`: Nome de usuário do Harbor.
|
||||
- `HARBOR_PASSWORD`: Senha do usuário do Harbor.
|
||||
|
||||
3. **Build e Push**
|
||||
- Constrói a imagem Docker da aplicação.
|
||||
- Tags geradas:
|
||||
- `git.simplifiquehc.com.br/simplifique/vendaweb-api:$TAG` (onde `$TAG` é o SHA curto do commit)
|
||||
- `git.simplifiquehc.com.br/simplifique/vendaweb-api:latest`
|
||||
- Envia ambas as tags para o registry.
|
||||
|
||||
4. **Atualizar Manifest e Push no Git**
|
||||
- Atualiza `k8s/overlays/prod/deployment-image-digest-patch.yaml` para apontar para a tag `$TAG`.
|
||||
|
||||
## Variáveis e Segredos (Secrets)
|
||||
|
||||
Para que o workflow funcione corretamente, as seguintes secrets devem estar configuradas nas configurações do repositório no Gitea:
|
||||
|
||||
| Secret | Descrição |
|
||||
| ----------------- | ------------------------------------------------------------- |
|
||||
| `HARBOR_USERNAME` | Usuário com permissão de push no projeto `library` do Harbor. |
|
||||
| `HARBOR_PASSWORD` | Senha ou token de acesso do usuário do Harbor. |
|
||||
|
||||
## Integração com Kubernetes
|
||||
|
||||
Após o push da imagem com a tag `latest` (e o SHA específico), o ArgoCD (configurado conforme `KUBERNETES.md`) detectará as mudanças se houver alteração nos manifestos ou se estiver configurado para pollar a imagem `latest` (dependendo da política de `imagePullPolicy` e configuração do ArgoCD Image Updater, se houver).
|
||||
27
k8s/argocd/application-prod.yaml
Normal file
27
k8s/argocd/application-prod.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: vendaweb-api-prod
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://git.simplifiquehc.com.br/simplifique/Vendaweb-api.git
|
||||
targetRevision: main
|
||||
path: k8s/overlays/prod
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: vendaweb-prod
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
prune: true
|
||||
retry:
|
||||
limit: 2
|
||||
backoff:
|
||||
duration: 5s
|
||||
factor: 2
|
||||
maxDuration: 3m
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
- PruneLast=true
|
||||
10
k8s/base/configmap.yaml
Normal file
10
k8s/base/configmap.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: vendaweb-api-config
|
||||
data:
|
||||
REDIS_HOST: '172.35.0.250'
|
||||
REDIS_PORT: '6379'
|
||||
DB_HOST: '172.35.0.250'
|
||||
DB_PORT: '1521'
|
||||
DB_SERVICE_NAME: 'ORCL'
|
||||
71
k8s/base/deployment.yaml
Normal file
71
k8s/base/deployment.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 5
|
||||
minReadySeconds: 10
|
||||
progressDeadlineSeconds: 600
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vendaweb-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: gitea-auth
|
||||
terminationGracePeriodSeconds: 30
|
||||
containers:
|
||||
- name: api
|
||||
image: git.simplifiquehc.com.br/simplifique/vendaweb-api:589fa29
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8067
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: vendaweb-api-config
|
||||
- secretRef:
|
||||
name: vendaweb-api-secrets
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 6
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 24
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
7
k8s/base/kustomization.yaml
Normal file
7
k8s/base/kustomization.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- configmap.yaml
|
||||
8
k8s/base/secret.yaml
Normal file
8
k8s/base/secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: vendaweb-api-secrets
|
||||
type: Opaque
|
||||
stringData:
|
||||
DB_USERNAME: 'simplifique'
|
||||
DB_PASSWORD: 'simplifique'
|
||||
15
k8s/base/service.yaml
Normal file
15
k8s/base/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: vendaweb-api
|
||||
ports:
|
||||
- name: http
|
||||
port: 8067
|
||||
targetPort: 8067
|
||||
protocol: TCP
|
||||
10
k8s/overlays/prod/deployment-image-digest-patch.yaml
Normal file
10
k8s/overlays/prod/deployment-image-digest-patch.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: git.simplifiquehc.com.br/simplifique/vendaweb-api:fd17be5
|
||||
6
k8s/overlays/prod/deployment-prod-patch.yaml
Normal file
6
k8s/overlays/prod/deployment-prod-patch.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
spec:
|
||||
replicas: 15
|
||||
12
k8s/overlays/prod/kustomization.yaml
Normal file
12
k8s/overlays/prod/kustomization.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: vendaweb-prod
|
||||
|
||||
resources:
|
||||
- ../../base
|
||||
|
||||
patches:
|
||||
- path: service-patch.yaml
|
||||
- path: deployment-prod-patch.yaml
|
||||
- path: deployment-image-digest-patch.yaml
|
||||
11
k8s/overlays/prod/service-patch.yaml
Normal file
11
k8s/overlays/prod/service-patch.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- name: http
|
||||
port: 8067
|
||||
targetPort: 8067
|
||||
nodePort: 30001
|
||||
@@ -14,7 +14,7 @@ export class AppController {
|
||||
@Get('health')
|
||||
@ApiOperation({ summary: 'Health check' })
|
||||
healthCheck() {
|
||||
return { status: 'SIMPLIFIQUE HOME CENTER 2026' };
|
||||
return { status: 'SIMPLIFIQUE HOME CENTER 202' };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ async function bootstrap() {
|
||||
do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
|
||||
.setVersion("2023.1.2")
|
||||
.addTag("VendaWeb")
|
||||
.addTag("Autenticação")
|
||||
.addTag("Auth")
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
SwaggerModule.setup("docs", app, document);
|
||||
await app.listen(8065);
|
||||
await app.listen(8067);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -1448,7 +1448,7 @@ export class SalesService {
|
||||
const queryRunner = connectionDb.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||
@@ -1462,7 +1462,22 @@ export class SalesService {
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
||||
' ORDER BY VLFRETE';
|
||||
' ORDER BY VLFRETE';*/
|
||||
|
||||
const sql = `SELECT 0 as "id"
|
||||
,'1' as "store"
|
||||
,ESVCALCULOFRETE.CODCIDADE as "cityId"
|
||||
,PCCIDADE.NOMECIDADE as "cityName"
|
||||
,NULL as "carrierId"
|
||||
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
|
||||
,0 as "minSale"
|
||||
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
|
||||
,NULL as "deliveryTime"
|
||||
FROM ESVCALCULOFRETE, PCCIDADE
|
||||
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
|
||||
AND ESVCALCULOFRETE.CODCIDADE = :1
|
||||
AND ESVCALCULOFRETE.IDCART = :2
|
||||
ORDER BY VLFRETE`;
|
||||
|
||||
const deliveryTaxTable = await queryRunner.manager
|
||||
.query(sql, [cityId, cartId]);
|
||||
@@ -1514,7 +1529,22 @@ export class SalesService {
|
||||
const queryRunner = connectionDb.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
const sql = `SELECT 0 as "id"
|
||||
,'1' as "store"
|
||||
,ESVCALCULOFRETE.CODCIDADE as "cityId"
|
||||
,PCCIDADE.NOMECIDADE as "cityName"
|
||||
,NULL as "carrierId"
|
||||
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
|
||||
,0 as "minSale"
|
||||
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
|
||||
,NULL as "deliveryTime"
|
||||
FROM ESVCALCULOFRETE, PCCIDADE
|
||||
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
|
||||
AND ESVCALCULOFRETE.CODCIDADE = :1
|
||||
AND ESVCALCULOFRETE.IDCART = :2
|
||||
ORDER BY VLFRETE`;
|
||||
|
||||
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||
@@ -1528,7 +1558,7 @@ export class SalesService {
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
||||
' ORDER BY VLFRETE';
|
||||
' ORDER BY VLFRETE';*/
|
||||
|
||||
let deliveryTaxTable = await queryRunner.manager
|
||||
.query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]);
|
||||
|
||||
Reference in New Issue
Block a user