Re_Backend/src/models/WorkflowTemplate.ts

100 lines
2.5 KiB
TypeScript

import { Model, DataTypes } from 'sequelize';
import { sequelize } from '@config/database';
import { User } from './User';
export class WorkflowTemplate extends Model {
public id!: string;
public name!: string;
public description!: string;
public category!: string;
public priority!: 'low' | 'medium' | 'high';
public estimatedTime!: string;
public approvers!: any[];
public suggestedSLA!: number;
public isActive!: boolean;
public createdBy!: string;
public fields!: any;
public readonly createdAt!: Date;
public readonly updatedAt!: Date;
}
WorkflowTemplate.init(
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false
},
name: {
type: DataTypes.STRING,
allowNull: false
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
category: {
type: DataTypes.STRING,
defaultValue: 'General'
},
priority: {
type: DataTypes.ENUM('low', 'medium', 'high'),
defaultValue: 'medium'
},
estimatedTime: {
type: DataTypes.STRING,
defaultValue: 'Variable',
field: 'estimated_time'
},
approvers: {
type: DataTypes.JSONB,
defaultValue: []
},
suggestedSLA: {
type: DataTypes.INTEGER,
defaultValue: 24,
comment: 'In hours',
field: 'suggested_sla'
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true,
field: 'is_active'
},
createdBy: {
type: DataTypes.UUID,
allowNull: true,
field: 'created_by',
references: {
model: 'users',
key: 'user_id'
}
},
fields: {
type: DataTypes.JSONB,
defaultValue: {}
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
field: 'created_at'
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
field: 'updated_at'
}
},
{
sequelize,
tableName: 'workflow_templates',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at'
}
);