- Implemented new endpoints in AdminController for managing Falukant regions, including fetching, updating, and deleting region distances. - Enhanced the FalukantService with methods for retrieving region distances and handling upsert operations. - Updated the router to expose new routes for region management and transport creation. - Introduced a transport management interface in the frontend, allowing users to create and manage transports between branches. - Added localization for new transport-related terms and improved the vehicle management interface to include transport options. - Enhanced the database initialization logic to support new region and transport models.
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import { Model, DataTypes } from 'sequelize';
|
||
import { sequelize } from '../../../utils/sequelize.js';
|
||
import RegionData from './region.js';
|
||
|
||
class RegionDistance extends Model {}
|
||
|
||
RegionDistance.init(
|
||
{
|
||
sourceRegionId: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: false,
|
||
references: {
|
||
model: RegionData,
|
||
key: 'id',
|
||
schema: 'falukant_data',
|
||
},
|
||
},
|
||
targetRegionId: {
|
||
type: DataTypes.INTEGER,
|
||
allowNull: false,
|
||
references: {
|
||
model: RegionData,
|
||
key: 'id',
|
||
schema: 'falukant_data',
|
||
},
|
||
},
|
||
transportMode: {
|
||
// e.g. 'land', 'water', 'air' – should match VehicleType.transportMode
|
||
type: DataTypes.STRING,
|
||
allowNull: false,
|
||
},
|
||
distance: {
|
||
// distance between regions (e.g. in abstract units, used for travel time etc.)
|
||
type: DataTypes.DOUBLE,
|
||
allowNull: false,
|
||
},
|
||
},
|
||
{
|
||
sequelize,
|
||
modelName: 'RegionDistance',
|
||
tableName: 'region_distance',
|
||
schema: 'falukant_data',
|
||
timestamps: false,
|
||
underscored: true,
|
||
}
|
||
);
|
||
|
||
export default RegionDistance;
|
||
|
||
|
||
|