Files
Dwinzo-Backend-V0.0/src/api-server/Routes/zoneRoutes.ts

544 lines
17 KiB
TypeScript

import * as express from "express";
import { ZoneService } from "../controller/lines/zoneService.ts";
const router = express.Router();
/**
* @swagger
* components:
* schemas:
* Zone:
* type: object
* required:
* - zoneName
* - zoneUUID
* - sceneID
* - createdBy
* - layer
* - viewPortCenter
* - viewPortposition
* properties:
* zoneName:
* type: string
* description: Name of the zone
* zoneUUID:
* type: string
* description: Unique identifier for the zone
* sceneID:
* type: string
* description: ID of the scene associated with the zone
* createdBy:
* type: string
* description: User ID who created the zone
* layer:
* type: integer
* description: Layer number in the scene
* zonePoints:
* type: array
* description: List of points defining the zone
* items:
* type: array
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* viewPortCenter:
* type: array
* description: Center position of the viewport
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* viewPortposition:
* type: array
* description: Position of the viewport
* items:
* type: object
* properties:
* x:
* type: number
* panelOrder:
* type: array
* description: Order of panels
* items:
* type: string
* enum: ["left", "right", "up", "down"]
* lockedPanel:
* type: array
* description: Locked panels in the zone
* items:
* type: string
* enum: ["left", "right", "up", "down"]
* isArchive:
* type: boolean
* description: Flag to mark if the zone is archived
* createdAt:
* type: string
* format: date-time
* description: Timestamp when the zone was created
* updatedAt:
* type: string
* format: date-time
* description: Timestamp when the zone was last updated
* example:
* zoneName: "Zone 2"
* zoneUUID: "0114-58-064-9"
* sceneID: "125789632548"
* createdBy: "012357894268"
* layer: 1
* zonePoints: [[{"x":5,"y":5}], [{"x":5,"y":5}], [{"x":5,"y":5}]]
* viewPortCenter: [{"x":5, "y":5}]
* viewPortposition: [{"x":5}]
* panelOrder: ["left", "right"]
* lockedPanel: ["up"]
* isArchive: false
* createdAt: "2025-01-01T00:00:00Z"
* updatedAt: "2025-01-01T00:00:00Z"
*/
/**
* @swagger
* tags:
* name: Zones
* description: API for managing zones
*/
/**
* @swagger
* /zone/save:
* post:
* summary: Create or update a zone
* tags: [Zones]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - organization
* - zonesdata
* properties:
* organization:
* type: string
* description: Organization name
* example: "NEWORG"
* zonesdata:
* type: object
* required:
* - zonename
* - zoneId
* - sceneID
* - userid
* - layer
* - points
* - viewportPosition
* properties:
* zonename:
* type: string
* description: Name of the zone
* example: "Zone 2"
* zoneId:
* type: string
* description: Unique identifier for the zone
* example: "0114-58-064-9"
* sceneID:
* type: string
* description: ID of the scene associated with the zone
* example: "125789632548"
* userid:
* type: string
* description: User ID who created the zone
* example: "012357894268"
* layer:
* type: integer
* description: Layer number in the scene
* example: 1
* points:
* type: array
* description: List of points defining the zone
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* example: [{"x":5,"y":5}, {"x":10,"y":10}]
* viewportPosition:
* type: array
* description: Position of the viewport
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* example: [{"x":5, "y":5}]
* viewPortCenter:
* type: array
* description: Center of the viewport
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* example: [{"x":10, "y":10}]
* responses:
* 200:
* description: Zone created or updated successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone created successfully"
* zoneData:
* type: object
* properties:
* zoneName:
* type: string
* points:
* type: array
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* viewPortposition:
* type: array
* items:
* type: object
* viewPortCenter:
* type: array
* items:
* type: object
* 404:
* description: Zone not updated
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone not updated"
* 500:
* description: Server error
* content:
* application/json:
* schema:
* type: object
* properties:
* error:
* type: string
* example: "Internal server error"
*/
router.post("/zone/save", ZoneService.addandUpdateZone);
/**
* @swagger
* /zones/{sceneID}:
* get:
* summary: Get all zones for a scene
* tags: [Zones]
* parameters:
* - in: path
* name: sceneID
* required: true
* schema:
* type: string
* description: ID of the scene
* - in: query
* name: organization
* required: true
* schema:
* type: string
* description: Organization name
* responses:
* 200:
* description: List of zones retrieved successfully
* content:
* application/json:
* schema:
* type: array
* items:
* type: object
* properties:
* zoneName:
* type: string
* description: Name of the zone
* sceneID:
* type: string
* description: Scene ID associated with the zone
* zoneUUID:
* type: string
* description: Unique identifier for the zone
* 404:
* description: No zones found for the given scene ID
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone not found for the UUID"
* 500:
* description: Server error
* content:
* application/json:
* schema:
* type: object
* properties:
* error:
* type: string
* example: "Internal Server Error"
* examples:
* Successful Response:
* value:
* - zoneName: "Zone A"
* sceneID: "scene123"
* zoneUUID: "UUID-12345"
* - zoneName: "Zone B"
* sceneID: "scene123"
* zoneUUID: "UUID-67890"
* Not Found Response:
* value:
* message: "Zone not found for the UUID"
*/
router.get("/zones/:sceneID", ZoneService.allZones);
router.get("/pageZodeData", ZoneService.vizAllDatas);
/**
* @swagger
* /ZoneVisualization/{zoneId}:
* get:
* summary: Get Zone Panel Data
* tags: [Zones]
* description: Fetches zone panel details including widgets, panel order, locked panels, and points.
* parameters:
* - in: path
* name: zoneId
* required: true
* description: The unique identifier of the zone.
* schema:
* type: string
* - in: query
* name: organization
* required: true
* description: The organization name to filter data.
* schema:
* type: string
* responses:
* 200:
* description: Zone panel data retrieved successfully.
* content:
* application/json:
* schema:
* type: object
* properties:
* zoneName:
* type: string
* activeSides:
* type: array
* items:
* type: string
* panelOrder:
* type: array
* items:
* type: string
* lockedPanels:
* type: array
* items:
* type: string
* points:
* type: array
* items:
* type: object
* properties:
* x:
* type: number
* y:
* type: number
* widgets:
* type: array
* items:
* type: object
* properties:
* id:
* type: string
* type:
* type: string
* title:
* type: string
* panel:
* type: string
* data:
* type: array
* items:
* type: object
* example:
* zoneName: "Zone 2"
* activeSides: []
* panelOrder: []
* lockedPanels: []
* points:
* - x: 5
* y: 5
* - x: 10
* y: 10
* widgets: []
* 404:
* description: Zone not found
* content:
* application/json:
* example:
* message: "Zone not found for the UUID"
* 500:
* description: Internal Server Error
* content:
* application/json:
* example:
* error: "Internal Server Error"
*/
router.get("/ZoneVisualization/:zoneId", ZoneService.singleZonePanelDatas);
/**
* @swagger
* /A_zone/{zoneId}:
* get:
* summary: Get a specific zone's data
* tags: [Zones]
* parameters:
* - in: path
* name: zoneId
* required: true
* schema:
* type: string
* description: Unique identifier of the zone
* - in: query
* name: organization
* required: true
* schema:
* type: string
* description: Organization name
* responses:
* 200:
* description: Zone data retrieved successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* zoneUUID:
* type: string
* description: Unique identifier of the zone
* zoneName:
* type: string
* description: Name of the zone
* isArchive:
* type: boolean
* description: Indicates if the zone is archived
* 404:
* description: Zone not found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone not found"
* 500:
* description: Server error
* content:
* application/json:
* schema:
* type: object
* properties:
* error:
* type: string
* example: "Internal Server Error"
* examples:
* Successful Response:
* value:
* zoneUUID: "abc123"
* zoneName: "Zone A"
* isArchive: false
* otherProperties: {}
* Not Found Response:
* value:
* message: "Zone not found"
*/
router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
/**
* @swagger
* /zone/{zoneId}:
* patch:
* summary: Soft delete a zone
* tags: [Zones]
* parameters:
* - in: path
* name: zoneId
* required: true
* schema:
* type: string
* description: Unique identifier of the zone
* - in: query
* name: organization
* required: true
* schema:
* type: string
* description: Organization name
* responses:
* 200:
* description: Zone successfully deleted
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone deleted successfully"
* 404:
* description: Zone not found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: "Zone not found for the UUID"
* 500:
* description: Server error
* content:
* application/json:
* schema:
* type: object
* properties:
* error:
* type: string
* example: "Internal Server Error"
*/
router.patch("/zone/:zoneId", ZoneService.deleteAZone);
router.get("/findZones/:organization", ZoneService.getZones);
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
export default router;