Füge neue Modelle für Produktion, Inventar und kaufbare Bestände hinzu; aktualisiere bestehende Modelle und Routen
This commit is contained in:
@@ -42,6 +42,9 @@ import TitleOfNobility from './falukant/type/title_of_nobility.js';
|
||||
import TitleRequirement from './falukant/type/title_requirement.js';
|
||||
import Branch from './falukant/data/branch.js';
|
||||
import BranchType from './falukant/type/branch.js';
|
||||
import Production from './falukant/data/production.js';
|
||||
import Inventory from './falukant/data/inventory.js';
|
||||
import BuyableStock from './falukant/data/buayble_stock.js';
|
||||
|
||||
|
||||
export default function setupAssociations() {
|
||||
@@ -205,21 +208,15 @@ export default function setupAssociations() {
|
||||
|
||||
FalukantCharacter.belongsTo(TitleOfNobility, { foreignKey: 'titleOfNobility', as: 'nobleTitle' });
|
||||
TitleOfNobility.hasMany(FalukantCharacter, { foreignKey: 'titleOfNobility', as: 'charactersWithNobleTitle' });
|
||||
|
||||
|
||||
FalukantCharacter.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(FalukantCharacter, { foreignKey: 'regionId', as: 'charactersInRegion' });
|
||||
|
||||
FalukantStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(FalukantStock, { foreignKey: 'stockTypeId', as: 'stocks' });
|
||||
|
||||
FalukantStock.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasMany(FalukantStock, { foreignKey: 'userId', as: 'stocks' });
|
||||
|
||||
FalukantStock.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(FalukantStock, { foreignKey: 'regionId', as: 'stocksInRegion' });
|
||||
|
||||
Knowledge.belongsTo(ProductType, { foreignKey: 'productTypeId', as: 'productType' });
|
||||
ProductType.hasMany(Knowledge, { foreignKey: 'productTypeId', as: 'knowledges' });
|
||||
Knowledge.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Knowledge, { foreignKey: 'productId', as: 'knowledges' });
|
||||
|
||||
Knowledge.belongsTo(FalukantCharacter, { foreignKey: 'characterId', as: 'character' });
|
||||
FalukantCharacter.hasMany(Knowledge, { foreignKey: 'characterId', as: 'knowledges' });
|
||||
@@ -235,4 +232,23 @@ export default function setupAssociations() {
|
||||
|
||||
Branch.belongsTo(BranchType, { foreignKey: 'branchTypeId', as: 'branchType' });
|
||||
BranchType.hasMany(Branch, { foreignKey: 'branchTypeId', as: 'branches' });
|
||||
|
||||
Production.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
Branch.hasMany(Production, { foreignKey: 'branchId', as: 'productions' });
|
||||
|
||||
Production.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Production, { foreignKey: 'productId', as: 'productions' });
|
||||
|
||||
Inventory.belongsTo(FalukantStock, { foreignKey: 'stockId', as: 'stock' });
|
||||
FalukantStock.hasMany(Inventory, { foreignKey: 'stockId', as: 'inventories' });
|
||||
|
||||
Inventory.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
||||
ProductType.hasMany(Inventory, { foreignKey: 'productId', as: 'inventories' });
|
||||
|
||||
BuyableStock.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
||||
RegionData.hasMany(BuyableStock, { foreignKey: 'regionId', as: 'buyableStocks' });
|
||||
|
||||
Branch.hasMany(FalukantStock, { foreignKey: 'branchId', as: 'stocks' });
|
||||
FalukantStock.belongsTo(Branch, { foreignKey: 'branchId', as: 'branch' });
|
||||
|
||||
}
|
||||
|
||||
28
backend/models/falukant/data/buayble_stock.js
Normal file
28
backend/models/falukant/data/buayble_stock.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class BuyableStock extends Model { }
|
||||
|
||||
BuyableStock.init({
|
||||
regionId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
stockTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'BuyableStock',
|
||||
tableName: 'buyable_stock',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default BuyableStock;
|
||||
37
backend/models/falukant/data/inventory.js
Normal file
37
backend/models/falukant/data/inventory.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Inventory extends Model { }
|
||||
|
||||
Inventory.init({
|
||||
stockId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
quality: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
producedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Inventory',
|
||||
tableName: 'inventory',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Inventory;
|
||||
33
backend/models/falukant/data/production.js
Normal file
33
backend/models/falukant/data/production.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Production extends Model { }
|
||||
|
||||
Production.init({
|
||||
branchId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
startTimestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Production',
|
||||
tableName: 'production',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Production;
|
||||
@@ -4,13 +4,10 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class FalukantStock extends Model { }
|
||||
|
||||
FalukantStock.init({
|
||||
userId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
regionId: {
|
||||
branchId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
},
|
||||
stockTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
@@ -37,6 +37,11 @@ FalukantUser.init({
|
||||
allowNull: false,
|
||||
defaultValue: 0.00,
|
||||
},
|
||||
certificate: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
},
|
||||
mainBranchRegionId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
|
||||
@@ -46,6 +46,9 @@ import TitleRequirement from './falukant/type/title_requirement.js';
|
||||
import TitleOfNobility from './falukant/type/title_of_nobility.js';
|
||||
import BranchType from './falukant/type/branch.js';
|
||||
import Branch from './falukant/data/branch.js';
|
||||
import Production from './falukant/data/production.js';
|
||||
import Inventory from './falukant/data/inventory.js';
|
||||
import BuyableStock from './falukant/data/buayble_stock.js';
|
||||
|
||||
const models = {
|
||||
SettingsType,
|
||||
@@ -54,10 +57,10 @@ const models = {
|
||||
UserRightType,
|
||||
User,
|
||||
UserParam,
|
||||
Login,
|
||||
Login,
|
||||
UserRight,
|
||||
InterestType,
|
||||
InterestTranslationType,
|
||||
InterestTranslationType,
|
||||
Interest,
|
||||
ContactMessage,
|
||||
UserParamVisibilityType,
|
||||
@@ -96,6 +99,9 @@ const models = {
|
||||
TitleRequirement,
|
||||
BranchType,
|
||||
Branch,
|
||||
Production,
|
||||
Inventory,
|
||||
BuyableStock,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
Reference in New Issue
Block a user