Some extensions and fixes

This commit is contained in:
Torsten Schulz
2025-01-28 09:55:36 +01:00
parent 2f60741116
commit 90b4f51dcb
27 changed files with 910 additions and 53 deletions

View File

@@ -1,49 +1,57 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class FalukantCharacter extends Model {};
class FalukantCharacter extends Model {}
FalukantCharacter.init({
userId: {
type: DataTypes.INTEGER,
allowNull: true,
FalukantCharacter.init(
{
user_id: {
type: DataTypes.INTEGER,
allowNull: true,
},
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
region_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
firstName: {
type: DataTypes.INTEGER,
allowNull: false,
first_name: {
type: DataTypes.INTEGER,
allowNull: false,
},
lastName: {
type: DataTypes.INTEGER,
allowNull: false,
last_name: {
type: DataTypes.INTEGER,
allowNull: false,
},
birthdate: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
gender: {
type: DataTypes.STRING
type: DataTypes.STRING,
},
health: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100,
},
titleOfNobility: {
type: DataTypes.INTEGER,
allowNull: false,
type: DataTypes.INTEGER,
allowNull: false,
},
moodId: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 1,
}
}, {
},
{
sequelize,
modelName: 'FalukantCharacter',
tableName: 'character',
schema: 'falukant_data',
timestamps: true,
underscored: true,
});
}
);
export default FalukantCharacter;

View File

@@ -0,0 +1,27 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class FalukantCharacterTrait extends Model {}
FalukantCharacterTrait.init(
{
character_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
trait_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
},
{
sequelize,
modelName: 'FalukantCharacterTrait',
tableName: 'falukant_character_trait',
schema: 'falukant_data',
timestamps: false,
underscored: true,
}
);
export default FalukantCharacterTrait;

View File

@@ -0,0 +1,34 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class MarriageProposal extends Model {}
MarriageProposal.init(
{
requesterCharacterId: {
type: DataTypes.INTEGER,
allowNull: false,
onDelete: 'CASCADE',
},
proposedCharacterId: {
type: DataTypes.INTEGER,
allowNull: false,
onDelete: 'CASCADE',
},
cost: {
type: DataTypes.FLOAT,
allowNull: false,
defaultValue: 0,
},
},
{
sequelize,
modelName: 'MarriageProposal',
tableName: 'marriage_proposals',
schema: 'falukant_data',
timestamps: true,
underscored: true,
}
);
export default MarriageProposal;

View File

@@ -19,7 +19,7 @@ Production.init({
startTimestamp: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
}
}, {
sequelize,

View File

@@ -0,0 +1,34 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class TownProductWorth extends Model { }
TownProductWorth.init({
productId: {
type: DataTypes.INTEGER,
allowNull: false,
},
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
},
worthPercent: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
}
}, {
sequelize,
modelName: 'TownProductWorth',
tableName: 'town_product_worth',
schema: 'falukant_data',
timestamps: false,
underscored: true,
hooks: {
beforeCreate: (worthPercent) => {
worthPercent.worthPercent = Math.floor(Math.random() * 20) + 40;
}
}
});
export default TownProductWorth;

View File

@@ -0,0 +1,44 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class DayProduction extends Model { }
DayProduction.init({
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
},
productId: {
type: DataTypes.INTEGER,
allowNull: false,
},
quantity: {
type: DataTypes.INTEGER,
allowNull: false,
},
producerId: {
type: DataTypes.INTEGER,
allowNull: false,
},
productionTimestamp: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
}
}, {
sequelize,
modelName: 'DayProduction',
tableName: 'production',
schema: 'falukant_log',
timestamps: false,
underscored: true,
indexes: [
{
unique: true,
fields: ['producer_id', 'product_id', 'region_id']
}
]
});
export default DayProduction;

View File

@@ -0,0 +1,43 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class DaySell extends Model { }
DaySell.init({
regionId: {
type: DataTypes.INTEGER,
allowNull: false,
},
productId: {
type: DataTypes.INTEGER,
allowNull: false,
},
quantity: {
type: DataTypes.INTEGER,
allowNull: false,
},
sellerId: {
type: DataTypes.INTEGER,
allowNull: false,
},
sellTimestamp: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
}
}, {
sequelize,
modelName: 'DaySell',
tableName: 'sell',
schema: 'falukant_log',
timestamps: false,
underscored: true,
indexes: [
{
unique: true,
fields: ['seller_id', 'product_id', 'region_id']
}
]
});
export default DaySell;

View File

@@ -0,0 +1,29 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class Notification extends Model { }
Notification.init({
userId: {
type: DataTypes.INTEGER,
allowNull: false,
},
tr: {
type: DataTypes.STRING,
allowNull: false,
},
shown: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
}, {
sequelize,
modelName: 'Notification',
tableName: 'notification',
schema: 'falukant_log',
timestamps: true,
underscored: true,
});
export default Notification;

View File

@@ -0,0 +1,45 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
import PromotionalGift from '../type/promotional_gift.js';
import CharacterTrait from '../type/character_trait.js';
class PromotionalGiftCharacterTrait extends Model {}
PromotionalGiftCharacterTrait.init(
{
gift_id: {
type: DataTypes.INTEGER,
references: {
model: PromotionalGift,
key: 'id',
},
allowNull: false,
},
trait_id: {
type: DataTypes.INTEGER,
references: {
model: CharacterTrait,
key: 'id',
},
allowNull: false,
},
suitability: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
min: 1,
max: 5,
},
},
},
{
sequelize,
modelName: 'PromotionalGiftCharacterTrait',
tableName: 'promotional_gift_character_trait',
schema: 'falukant_predefine',
timestamps: false,
underscored: true,
}
);
export default PromotionalGiftCharacterTrait;

View File

@@ -0,0 +1,45 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
import PromotionalGift from '../type/promotional_gift.js';
import Mood from '../type/mood.js';
class PromotionalGiftMood extends Model {}
PromotionalGiftMood.init(
{
gift_id: {
type: DataTypes.INTEGER,
references: {
model: PromotionalGift,
key: 'id',
},
allowNull: false,
},
mood_id: {
type: DataTypes.INTEGER,
references: {
model: Mood,
key: 'id',
},
allowNull: false,
},
suitability: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
min: 1,
max: 5,
},
},
},
{
sequelize,
modelName: 'PromotionalGiftMood',
tableName: 'promotional_gift_mood',
schema: 'falukant_predefine',
timestamps: false,
underscored: true,
}
);
export default PromotionalGiftMood;

View File

@@ -0,0 +1,23 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class CharacterTrait extends Model {}
CharacterTrait.init(
{
tr: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
sequelize,
modelName: 'CharacterTrait',
tableName: 'character_trait',
schema: 'falukant_type',
timestamps: false,
underscored: true,
}
);
export default CharacterTrait;

View File

@@ -0,0 +1,23 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class Mood extends Model {}
Mood.init(
{
tr: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
sequelize,
modelName: 'Mood',
tableName: 'mood',
schema: 'falukant_type',
timestamps: false,
underscored: true,
}
);
export default Mood;

View File

@@ -0,0 +1,32 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class PromotionalGift extends Model {}
PromotionalGift.init(
{
name: {
type: DataTypes.STRING,
allowNull: false,
},
description: {
type: DataTypes.TEXT,
allowNull: true,
},
value: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0, // Wert des Geschenks
},
},
{
sequelize,
modelName: 'PromotionalGift',
tableName: 'promotional_gift',
schema: 'falukant_type',
timestamps: false,
underscored: true,
}
);
export default PromotionalGift;

View File

@@ -0,0 +1,23 @@
import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../../utils/sequelize.js';
class Relationship extends Model {}
Relationship.init(
{
tr: {
type: DataTypes.STRING,
allowNull: false,
}
},
{
sequelize,
modelName: 'Relationship',
tableName: 'relationship',
schema: 'falukant_type',
timestamps: false,
underscored: true,
}
);
export default Relationship;