03d01d4c4e
on:
pull_request:
branches:
- production
types:
- closed
jobs:
backend-build-and-deploy:
name: Build & Deploy ERP Core Backend
runs-on: linux
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
run: |
git clone \
--depth 1 \
--branch production \
https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
.
- name: Restore backend
run: dotnet restore Backend/ERPCore.sln
- name: Publish backend
run: |
rm -rf /tmp/erpcore-deploy
mkdir -p /tmp/erpcore-deploy
dotnet publish Backend/ERPCore/ERPCore.csproj \
-c Release \
-r linux-x64 \
--self-contained true \
-o /tmp/erpcore-deploy
- name: Stop backend service
run: systemctl stop erpcore.service
- name: Copy backend to deploy folder
run: |
mkdir -p /home/erp/core/publish
rm -rf /home/erp/core/publish/*
cp -r /tmp/erpcore-deploy/* /home/erp/core/publish/
- name: Fix backend ownership and permissions
run: |
chown -R erpuser:erpuser /home/erp/core/publish
find /home/erp/core/publish -type d -exec chmod 755 {} +
find /home/erp/core/publish -type f -exec chmod 644 {} +
chmod +x /home/erp/core/publish/ERPCore
- name: Restart backend service
run: systemctl restart erpcore.service
- name: Verify backend
run: |
systemctl is-active erpcore.service && echo "Backend service running" || echo "Backend service failed"
frontend-build-and-deploy:
name: Build & Deploy ERP Core Frontend
runs-on: linux
needs: backend-build-and-deploy
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
run: |
git clone \
--depth 1 \
--branch Production \
https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
.
- name: Build frontend Docker image
run: docker build -t erpcore-frontend:latest Frontend/erp-system
- name: Stop & remove existing frontend container
run: |
docker stop erpcore-frontend 2>/dev/null || true
docker rm erpcore-frontend 2>/dev/null || true
- name: Start frontend container
run: |
docker run -d \
--name erpcore-frontend \
-p 6702:6702 \
--add-host=host.docker.internal:host-gateway \
-e BACKEND_ORIGIN=http://host.docker.internal:6701 \
--restart unless-stopped \
--memory="512m" \
--cpus="1.0" \
--cap-drop ALL \
--security-opt no-new-privileges \
erpcore-frontend:latest
- name: Remove old frontend images
run: docker image prune -f
- name: Verify frontend
run: |
docker ps --filter name=erpcore-frontend --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \
| grep erpcore-frontend && echo "Frontend container running" || echo "Frontend container failed"
111 lines
3.6 KiB
TypeScript
111 lines
3.6 KiB
TypeScript
import { api } from '@/lib/api'
|
|
import type {
|
|
PaginatedResponse,
|
|
RideResponse,
|
|
LoadingSheetResponse,
|
|
DeliveryTaskResponse,
|
|
RideStatus,
|
|
CancelRequestType,
|
|
LoadingSheetStatus,
|
|
} from '@/types/api'
|
|
|
|
import type { PageParams } from './master'
|
|
|
|
// ─── Rides ────────────────────────────────────────────────────────────────────
|
|
|
|
export interface RideBody {
|
|
vehicleId: string
|
|
driverProfileId: string
|
|
meterstart: number
|
|
}
|
|
|
|
export interface RideListParams extends PageParams {
|
|
status?: RideStatus
|
|
driverProfileId?: string
|
|
vehicleId?: string
|
|
}
|
|
|
|
export interface CancelRideBody {
|
|
typeCode: CancelRequestType
|
|
reason: string
|
|
}
|
|
|
|
export const rides = {
|
|
list: (params?: RideListParams) =>
|
|
api.get<PaginatedResponse<RideResponse>>('/rides', { params }).then(r => r.data),
|
|
|
|
get: (id: string) =>
|
|
api.get<RideResponse>(`/rides/${id}`).then(r => r.data),
|
|
|
|
create: (body: RideBody) =>
|
|
api.post<RideResponse>('/rides', body).then(r => r.data),
|
|
|
|
assignDriver: (id: string, driverProfileId: string) =>
|
|
api.put<RideResponse>(`/rides/${id}/driver`, { driverProfileId }).then(r => r.data),
|
|
|
|
close: (id: string, meterend: number) =>
|
|
api.post<RideResponse>(`/rides/${id}/close`, { meterend }).then(r => r.data),
|
|
|
|
cancel: (id: string, body: CancelRideBody) =>
|
|
api.post<RideResponse>(`/rides/${id}/cancel`, body).then(r => r.data),
|
|
}
|
|
|
|
// ─── Loading Sheets ───────────────────────────────────────────────────────────
|
|
|
|
export interface LoadingSheetCreateBody {
|
|
fK_RideId: string
|
|
}
|
|
|
|
export interface LoadingSheetItemInput {
|
|
fK_ItemId: string
|
|
fK_WarehouseId: string
|
|
quantity: number
|
|
fK_ShopPOItemId?: string | null
|
|
}
|
|
|
|
export interface LoadingSheetListParams extends PageParams {
|
|
rideId?: string
|
|
status?: LoadingSheetStatus
|
|
}
|
|
|
|
export const loadingSheets = {
|
|
list: (params?: LoadingSheetListParams) =>
|
|
api.get<PaginatedResponse<LoadingSheetResponse>>('/loading-sheets', { params }).then(r => r.data),
|
|
|
|
get: (id: string) =>
|
|
api.get<LoadingSheetResponse>(`/loading-sheets/${id}`).then(r => r.data),
|
|
|
|
create: (body: LoadingSheetCreateBody) =>
|
|
api.post<LoadingSheetResponse>('/loading-sheets', body).then(r => r.data),
|
|
|
|
updateItems: (id: string, items: LoadingSheetItemInput[]) =>
|
|
api.put<LoadingSheetResponse>(`/loading-sheets/${id}/items`, { items }).then(r => r.data),
|
|
|
|
confirm: (id: string) =>
|
|
api.post<LoadingSheetResponse>(`/loading-sheets/${id}/confirm`).then(r => r.data),
|
|
}
|
|
|
|
// ─── Delivery Tasks ───────────────────────────────────────────────────────────
|
|
|
|
export interface DeliveryTaskItemQuantity {
|
|
itemId: string
|
|
quantityFulfilled: number
|
|
}
|
|
|
|
export const deliveryTasks = {
|
|
listByRide: (rideId: string) =>
|
|
api.get<DeliveryTaskResponse[]>(`/rides/${rideId}/tasks`).then(r => r.data),
|
|
|
|
get: (id: string) =>
|
|
api.get<DeliveryTaskResponse>(`/delivery-tasks/${id}`).then(r => r.data),
|
|
|
|
setQuantities: (id: string, items: DeliveryTaskItemQuantity[]) =>
|
|
api.put<DeliveryTaskResponse>(`/delivery-tasks/${id}/quantities`, { items }).then(r => r.data),
|
|
|
|
confirm: (id: string) =>
|
|
api.post<DeliveryTaskResponse>(`/delivery-tasks/${id}/confirm`).then(r => r.data),
|
|
|
|
fail: (id: string, note: string) =>
|
|
api.post<DeliveryTaskResponse>(`/delivery-tasks/${id}/fail`, { note }).then(r => r.data),
|
|
}
|