Some extensions and fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
27
backend/models/falukant/data/falukant_character_trait.js
Normal file
27
backend/models/falukant/data/falukant_character_trait.js
Normal 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;
|
||||
34
backend/models/falukant/data/marriage_proposal.js
Normal file
34
backend/models/falukant/data/marriage_proposal.js
Normal 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;
|
||||
@@ -19,7 +19,7 @@ Production.init({
|
||||
startTimestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
|
||||
34
backend/models/falukant/data/town_product_worth.js
Normal file
34
backend/models/falukant/data/town_product_worth.js
Normal 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;
|
||||
44
backend/models/falukant/log/dayproduction.js
Normal file
44
backend/models/falukant/log/dayproduction.js
Normal 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;
|
||||
43
backend/models/falukant/log/daysell.js
Normal file
43
backend/models/falukant/log/daysell.js
Normal 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;
|
||||
29
backend/models/falukant/log/notification
Normal file
29
backend/models/falukant/log/notification
Normal 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;
|
||||
@@ -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;
|
||||
45
backend/models/falukant/predefine/promotional_gift_mood.js
Normal file
45
backend/models/falukant/predefine/promotional_gift_mood.js
Normal 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;
|
||||
23
backend/models/falukant/type/character_trait.js
Normal file
23
backend/models/falukant/type/character_trait.js
Normal 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;
|
||||
23
backend/models/falukant/type/mood.js
Normal file
23
backend/models/falukant/type/mood.js
Normal 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;
|
||||
32
backend/models/falukant/type/promotional_gift.js
Normal file
32
backend/models/falukant/type/promotional_gift.js
Normal 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;
|
||||
23
backend/models/falukant/type/relationship.js
Normal file
23
backend/models/falukant/type/relationship.js
Normal 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;
|
||||
Reference in New Issue
Block a user