Spiel erweitert
This commit is contained in:
@@ -65,6 +65,26 @@ import PromotionalGiftLog from './falukant/log/promotional_gift.js';
|
||||
import HouseType from './falukant/type/house.js';
|
||||
import BuyableHouse from './falukant/data/buyable_house.js';
|
||||
import UserHouse from './falukant/data/user_house.js';
|
||||
import PartyType from './falukant/type/party.js';
|
||||
import Party from './falukant/data/party.js';
|
||||
import MusicType from './falukant/type/music.js';
|
||||
import BanquetteType from './falukant/type/banquette.js';
|
||||
import PartyInvitedNobility from './falukant/data/partyInvitedNobility.js';
|
||||
import ChildRelation from './falukant/data/child_relation.js';
|
||||
import Learning from './falukant/data/learning.js';
|
||||
import LearnRecipient from './falukant/type/learn_recipient.js';
|
||||
import Credit from './falukant/data/credit.js';
|
||||
import DebtorsPrism from './falukant/data/debtors_prism.js';
|
||||
import HealthActivity from './falukant/log/health_activity.js';
|
||||
import Election from './falukant/data/election.js';
|
||||
import ElectionResult from './falukant/data/election_result.js';
|
||||
import Candidate from './falukant/data/candidate.js';
|
||||
import Vote from './falukant/data/vote.js';
|
||||
import PoliticalOfficeType from './falukant/type/political_office_type.js';
|
||||
import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js';
|
||||
|
||||
export default function setupAssociations() {
|
||||
// UserParam related associations
|
||||
@@ -275,7 +295,7 @@ export default function setupAssociations() {
|
||||
|
||||
BuyableStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(BuyableStock, { foreignKey: 'stockTypeId', as: 'buyableStocks' });
|
||||
|
||||
|
||||
Director.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Director, { foreignKey: 'employerUserId', as: 'directors' });
|
||||
|
||||
@@ -315,31 +335,31 @@ export default function setupAssociations() {
|
||||
Notification.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasMany(Notification, { foreignKey: 'userId', as: 'notifications' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, {foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'requesterCharacterId', as: 'initiatedProposals' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, {foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, {foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, {through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, {through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
|
||||
Mood.hasMany(FalukantCharacter, {foreignKey: 'mood_id', as: 'moods'});
|
||||
FalukantCharacter.belongsTo(Mood, {foreignKey: 'mood_id', as: 'mood'});
|
||||
|
||||
PromotionalGift.belongsToMany(CharacterTrait, {through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits',});
|
||||
CharacterTrait.belongsToMany(PromotionalGift, {through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts',});
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
|
||||
PromotionalGift.belongsToMany(Mood, {through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods',});
|
||||
Mood.belongsToMany(PromotionalGift, {through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts',});
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, { through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, { through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
|
||||
Mood.hasMany(FalukantCharacter, { foreignKey: 'mood_id', as: 'moods' });
|
||||
FalukantCharacter.belongsTo(Mood, { foreignKey: 'mood_id', as: 'mood' });
|
||||
|
||||
PromotionalGift.belongsToMany(CharacterTrait, { through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(PromotionalGift, { through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts', });
|
||||
|
||||
PromotionalGift.belongsToMany(Mood, { through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods', });
|
||||
Mood.belongsToMany(PromotionalGift, { through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts', });
|
||||
|
||||
Relationship.belongsTo(RelationshipType, { foreignKey: 'relationshipTypeId', as: 'relationshipType' });
|
||||
RelationshipType.hasMany(Relationship, { foreignKey: 'relationshipTypeId', as: 'relationships' });
|
||||
|
||||
Relationship.belongsTo(FalukantCharacter, {foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, {foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, {foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, {foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
|
||||
PromotionalGiftLog.belongsTo(PromotionalGift, { foreignKey: 'giftId', as: 'gift' });
|
||||
PromotionalGift.hasMany(PromotionalGiftLog, { foreignKey: 'giftId', as: 'logs' });
|
||||
@@ -367,4 +387,262 @@ export default function setupAssociations() {
|
||||
|
||||
TitleOfNobility.hasMany(HouseType, { foreignKey: 'minimumNobleTitle', as: 'houseTypes' });
|
||||
HouseType.belongsTo(TitleOfNobility, { foreignKey: 'minimumNobleTitle', as: 'titleOfNobility' });
|
||||
|
||||
PartyType.hasMany(Party, { foreignKey: 'partyTypeId', as: 'parties' });
|
||||
Party.belongsTo(PartyType, { foreignKey: 'partyTypeId', as: 'partyType' });
|
||||
|
||||
MusicType.hasMany(Party, { foreignKey: 'musicTypeId', as: 'parties' });
|
||||
Party.belongsTo(MusicType, { foreignKey: 'musicTypeId', as: 'musicType' });
|
||||
|
||||
BanquetteType.hasMany(Party, { foreignKey: 'banquetteTypeId', as: 'parties' });
|
||||
Party.belongsTo(BanquetteType, { foreignKey: 'banquetteTypeId', as: 'banquetteType' });
|
||||
|
||||
FalukantUser.hasMany(Party, { foreignKey: 'falukantUserId', as: 'parties' });
|
||||
Party.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'partyUser' });
|
||||
|
||||
Party.belongsToMany(TitleOfNobility, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'party_id',
|
||||
otherKey: 'title_of_nobility_id',
|
||||
as: 'invitedNobilities',
|
||||
});
|
||||
TitleOfNobility.belongsToMany(Party, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'title_of_nobility_id',
|
||||
otherKey: 'party_id',
|
||||
as: 'partiesInvitedTo',
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'father'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'childrenFather'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'mother'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'childrenMother'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'child'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'parentRelations'
|
||||
});
|
||||
|
||||
Learning.belongsTo(LearnRecipient, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'recipient'
|
||||
}
|
||||
);
|
||||
|
||||
LearnRecipient.hasMany(Learning, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantUser, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learner'
|
||||
}
|
||||
);
|
||||
|
||||
FalukantUser.hasMany(Learning, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(ProductType, {
|
||||
foreignKey: 'productId',
|
||||
as: 'productType'
|
||||
});
|
||||
|
||||
ProductType.hasMany(Learning, {
|
||||
foreignKey: 'productId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningCharacter'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(Learning, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningsCharacter'
|
||||
});
|
||||
|
||||
FalukantUser.hasMany(Credit, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'credits'
|
||||
});
|
||||
Credit.belongsTo(FalukantUser, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'user'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(DebtorsPrism, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'debtorsPrisms'
|
||||
});
|
||||
DebtorsPrism.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
|
||||
HealthActivity.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(HealthActivity, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'healthActivities'
|
||||
});
|
||||
|
||||
// — Political Offices —
|
||||
|
||||
// predefine requirements for office
|
||||
PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficeRequirement, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'requirements'
|
||||
});
|
||||
|
||||
// predefine benefits for office
|
||||
PoliticalOfficeBenefit.belongsTo(
|
||||
PoliticalOfficeBenefitType,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinition' }
|
||||
);
|
||||
PoliticalOfficeBenefitType.hasMany(
|
||||
PoliticalOfficeBenefit,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinitions' }
|
||||
);
|
||||
|
||||
// tie benefits back to office type
|
||||
PoliticalOfficeBenefit.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficeBenefit, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'benefits'
|
||||
});
|
||||
|
||||
// actual office holdings
|
||||
PoliticalOffice.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'type'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
PoliticalOffice.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'holder'
|
||||
});
|
||||
FalukantCharacter.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'heldOffices'
|
||||
});
|
||||
|
||||
// elections
|
||||
Election.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(Election, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'elections'
|
||||
});
|
||||
|
||||
// candidates in an election
|
||||
Candidate.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(Candidate, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'candidates'
|
||||
});
|
||||
|
||||
Candidate.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(Candidate, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'candidacies'
|
||||
});
|
||||
|
||||
// votes cast
|
||||
Vote.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(Vote, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
Vote.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
});
|
||||
Candidate.hasMany(Vote, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
Vote.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'voter'
|
||||
});
|
||||
FalukantCharacter.hasMany(Vote, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'votesCast'
|
||||
});
|
||||
|
||||
// election results
|
||||
ElectionResult.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(ElectionResult, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'results'
|
||||
});
|
||||
|
||||
ElectionResult.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
});
|
||||
Candidate.hasMany(ElectionResult, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'results'
|
||||
});
|
||||
|
||||
PoliticalOffice.belongsTo(RegionData, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'region'
|
||||
});
|
||||
RegionData.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
30
backend/models/falukant/data/candidate.js
Normal file
30
backend/models/falukant/data/candidate.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// falukant/data/candidate.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Candidate extends Model {}
|
||||
|
||||
Candidate.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
election_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Candidate',
|
||||
tableName: 'candidate',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Candidate;
|
||||
45
backend/models/falukant/data/child_relation.js
Normal file
45
backend/models/falukant/data/child_relation.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class ChildRelation extends Model {}
|
||||
|
||||
ChildRelation.init(
|
||||
{
|
||||
fatherCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
motherCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
childCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
fatherName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
motherName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
nameSet: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'ChildRelation',
|
||||
tableName: 'child_relation', // exakter Tabellenname
|
||||
schema: 'falukant_data', // exaktes Schema
|
||||
freezeTableName: true, // keine Pluralisierung
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default ChildRelation;
|
||||
37
backend/models/falukant/data/credit.js
Normal file
37
backend/models/falukant/data/credit.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// models/falukant/data/credit.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Credit extends Model {}
|
||||
|
||||
Credit.init({
|
||||
// aufgenommener Kredit-Betrag
|
||||
amount: {
|
||||
type: DataTypes.DECIMAL(14,2),
|
||||
allowNull: false,
|
||||
},
|
||||
// noch offener Kreditbetrag
|
||||
remainingAmount: {
|
||||
type: DataTypes.DECIMAL(14,2),
|
||||
allowNull: false,
|
||||
},
|
||||
// Zinssatz als Prozentsatz (z.B. 3.5 für 3.5%)
|
||||
interestRate: {
|
||||
type: DataTypes.DECIMAL(5,2),
|
||||
allowNull: false,
|
||||
},
|
||||
// Verknüpfung auf FalukantUser
|
||||
falukantUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Credit',
|
||||
tableName: 'credit',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Credit;
|
||||
21
backend/models/falukant/data/debtors_prism.js
Normal file
21
backend/models/falukant/data/debtors_prism.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class DebtorsPrism extends Model {}
|
||||
|
||||
DebtorsPrism.init({
|
||||
// Verknüpfung auf FalukantCharacter
|
||||
characterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'DebtorsPrism',
|
||||
tableName: 'debtors_prism',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default DebtorsPrism;
|
||||
34
backend/models/falukant/data/election.js
Normal file
34
backend/models/falukant/data/election.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// falukant/data/election.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Election extends Model {}
|
||||
|
||||
Election.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
political_office_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
posts_to_fill: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Election',
|
||||
tableName: 'election',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Election;
|
||||
34
backend/models/falukant/data/election_result.js
Normal file
34
backend/models/falukant/data/election_result.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// falukant/data/election_result.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class ElectionResult extends Model {}
|
||||
|
||||
ElectionResult.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
election_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
candidate_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
votes_received: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'ElectionResult',
|
||||
tableName: 'election_result',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default ElectionResult;
|
||||
48
backend/models/falukant/data/learning.js
Normal file
48
backend/models/falukant/data/learning.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Learning extends Model {}
|
||||
|
||||
Learning.init(
|
||||
{
|
||||
learningRecipientId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
productId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
learnAllProducts: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
},
|
||||
associatedFalukantUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
associatedLearningCharacterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
learningIsExecuted: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Learning',
|
||||
tableName: 'learning',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default Learning;
|
||||
30
backend/models/falukant/data/occupied_political_office.js
Normal file
30
backend/models/falukant/data/occupied_political_office.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// falukant/data/occupied_political_office.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class OccupiedPoliticalOffice extends Model {}
|
||||
|
||||
OccupiedPoliticalOffice.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
political_office_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'OccupiedPoliticalOffice',
|
||||
tableName: 'occupied_political_office',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default OccupiedPoliticalOffice;
|
||||
46
backend/models/falukant/data/party.js
Normal file
46
backend/models/falukant/data/party.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Party extends Model {}
|
||||
|
||||
Party.init({
|
||||
partyTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'party_type_id'
|
||||
},
|
||||
falukantUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'falukant_user_id'
|
||||
},
|
||||
musicTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'music_type'
|
||||
},
|
||||
banquetteTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'banquette_type'
|
||||
},
|
||||
servantRatio: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'servant_ratio'
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
defaultValue: 0
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Party',
|
||||
tableName: 'party',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Party;
|
||||
26
backend/models/falukant/data/partyInvitedNobility.js
Normal file
26
backend/models/falukant/data/partyInvitedNobility.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Model, DataTypes } from 'sequelize'
|
||||
import { sequelize } from '../../../utils/sequelize.js'
|
||||
|
||||
class PartyInvitedNobility extends Model {}
|
||||
|
||||
PartyInvitedNobility.init({
|
||||
partyId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'party_id'
|
||||
},
|
||||
titleOfNobilityId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'title_of_nobility_id'
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PartyInvitedNobility',
|
||||
tableName: 'party_invited_nobility',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true
|
||||
})
|
||||
|
||||
export default PartyInvitedNobility
|
||||
34
backend/models/falukant/data/political_office.js
Normal file
34
backend/models/falukant/data/political_office.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// backend/models/falukant/data/political_office.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalOffice extends Model {}
|
||||
|
||||
PoliticalOffice.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
officeTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
characterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
regionId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PoliticalOffice',
|
||||
tableName: 'political_office',
|
||||
schema: 'falukant_data',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default PoliticalOffice;
|
||||
39
backend/models/falukant/data/vote.js
Normal file
39
backend/models/falukant/data/vote.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// falukant/data/vote.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class Vote extends Model {}
|
||||
|
||||
Vote.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
election_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
voter_character_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
candidate_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
timestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Vote',
|
||||
tableName: 'vote',
|
||||
schema: 'falukant_data',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default Vote;
|
||||
37
backend/models/falukant/log/health_activity.js
Normal file
37
backend/models/falukant/log/health_activity.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class HealthActivity extends Model { }
|
||||
|
||||
HealthActivity.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
characterId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
activityTr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
successPercentage: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'health_activity',
|
||||
tableName: 'health_activity',
|
||||
schema: 'falukant_log',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default HealthActivity;
|
||||
@@ -0,0 +1,45 @@
|
||||
// falukant/predefine/political_office_benefit.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
import PoliticalOfficeBenefitType from '../type/political_office_benefit_type.js';
|
||||
|
||||
class PoliticalOfficeBenefit extends Model {}
|
||||
|
||||
PoliticalOfficeBenefit.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
political_office_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
benefit_type_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
value: {
|
||||
type: DataTypes.JSONB,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PoliticalOfficeBenefit',
|
||||
tableName: 'political_office_benefit',
|
||||
schema: 'falukant_predefine',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
// Association
|
||||
PoliticalOfficeBenefit.belongsTo(PoliticalOfficeBenefitType, {
|
||||
foreignKey: 'benefit_type_id',
|
||||
as: 'benefitType'
|
||||
});
|
||||
PoliticalOfficeBenefitType.hasMany(PoliticalOfficeBenefit, {
|
||||
foreignKey: 'benefit_type_id',
|
||||
as: 'benefits'
|
||||
});
|
||||
|
||||
export default PoliticalOfficeBenefit;
|
||||
@@ -0,0 +1,30 @@
|
||||
// falukant/predefine/political_office_prerequisite.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalOfficePrerequisite extends Model {}
|
||||
|
||||
PoliticalOfficePrerequisite.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
political_office_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
prerequisite: {
|
||||
type: DataTypes.JSONB,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PoliticalOfficePrerequisite',
|
||||
tableName: 'political_office_prerequisite',
|
||||
schema: 'falukant_predefine',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default PoliticalOfficePrerequisite;
|
||||
31
backend/models/falukant/type/banquette.js
Normal file
31
backend/models/falukant/type/banquette.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class BanquetteType extends Model {}
|
||||
|
||||
BanquetteType.init(
|
||||
{
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
reputationGrowth: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'BanquetteType',
|
||||
tableName: 'banquette',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default BanquetteType;
|
||||
23
backend/models/falukant/type/learn_recipient.js
Normal file
23
backend/models/falukant/type/learn_recipient.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class LearnRecipient extends Model {}
|
||||
|
||||
LearnRecipient.init(
|
||||
{
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'LearnRecipient',
|
||||
tableName: 'learn_recipient',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default LearnRecipient;
|
||||
31
backend/models/falukant/type/music.js
Normal file
31
backend/models/falukant/type/music.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class MusicType extends Model {}
|
||||
|
||||
MusicType.init(
|
||||
{
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
reputationGrowth: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'MusicType',
|
||||
tableName: 'music',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default MusicType;
|
||||
36
backend/models/falukant/type/party.js
Normal file
36
backend/models/falukant/type/party.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PartyType extends Model {}
|
||||
|
||||
PartyType.init(
|
||||
{
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
forMarriage: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
},
|
||||
reputationGrowth: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
}
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'PartyType',
|
||||
tableName: 'party',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default PartyType;
|
||||
@@ -0,0 +1,26 @@
|
||||
// falukant/type/political_office_benefit_type.js
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalOfficeBenefitType extends Model {}
|
||||
|
||||
PoliticalOfficeBenefitType.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PoliticalOfficeBenefitType',
|
||||
tableName: 'political_office_benefit_type',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default PoliticalOfficeBenefitType;
|
||||
38
backend/models/falukant/type/political_office_type.js
Normal file
38
backend/models/falukant/type/political_office_type.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class PoliticalOfficeType extends Model {}
|
||||
|
||||
PoliticalOfficeType.init({
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
seatsPerRegion: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
regionType: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
termLength: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'PoliticalOfficeType',
|
||||
tableName: 'political_office_type',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default PoliticalOfficeType;
|
||||
@@ -8,6 +8,11 @@ TitleOfNobility.init({
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
level: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'Title',
|
||||
|
||||
@@ -4,12 +4,16 @@ import { sequelize } from '../../../utils/sequelize.js';
|
||||
class TitleRequirement extends Model { }
|
||||
|
||||
TitleRequirement.init({
|
||||
titleId: {
|
||||
id : {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
titleId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
requirementType: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
@@ -19,12 +23,19 @@ TitleRequirement.init({
|
||||
allowNull: false,
|
||||
},
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'TitleRequirement',
|
||||
sequelize,
|
||||
modelName: 'TitleRequirement',
|
||||
tableName: 'title_requirement',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{
|
||||
unique: true,
|
||||
fields: ['title_id', 'requirement_type'],
|
||||
name: 'title_requirement_titleid_reqtype_unique'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export default TitleRequirement;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// models/index.js
|
||||
|
||||
import SettingsType from './type/settings.js';
|
||||
import UserParamValue from './type/user_param_value.js';
|
||||
import UserParamType from './type/user_param.js';
|
||||
@@ -32,6 +34,7 @@ import MessageHistory from './forum/message_history.js';
|
||||
import MessageImage from './forum/message_image.js';
|
||||
import ForumForumPermission from './forum/forum_forum_permission.js';
|
||||
import Friendship from './community/friendship.js';
|
||||
|
||||
import FalukantUser from './falukant/data/user.js';
|
||||
import RegionType from './falukant/type/region.js';
|
||||
import RegionData from './falukant/data/region.js';
|
||||
@@ -58,90 +61,136 @@ import DaySell from './falukant/log/daysell.js';
|
||||
import Notification from './falukant/log/notification.js';
|
||||
import MarriageProposal from './falukant/data/marriage_proposal.js';
|
||||
import RelationshipType from './falukant/type/relationship.js';
|
||||
import Relationship from './falukant/data/relationship.js';
|
||||
import CharacterTrait from './falukant/type/character_trait.js';
|
||||
import FalukantCharacterTrait from './falukant/data/falukant_character_trait.js';
|
||||
import Mood from './falukant/type/mood.js';
|
||||
import PromotionalGift from './falukant/type/promotional_gift.js';
|
||||
import PromotionalGiftCharacterTrait from './falukant/predefine/promotional_gift_character_trait.js';
|
||||
import PromotionalGiftMood from './falukant/predefine/promotional_gift_mood.js';
|
||||
import Relationship from './falukant/data/relationship.js';
|
||||
import PromotionalGiftLog from './falukant/log/promotional_gift.js';
|
||||
import HouseType from './falukant/type/house.js';
|
||||
import BuyableHouse from './falukant/data/buyable_house.js';
|
||||
import UserHouse from './falukant/data/user_house.js';
|
||||
import PartyType from './falukant/type/party.js';
|
||||
import Party from './falukant/data/party.js';
|
||||
import MusicType from './falukant/type/music.js';
|
||||
import BanquetteType from './falukant/type/banquette.js';
|
||||
import PartyInvitedNobility from './falukant/data/partyInvitedNobility.js';
|
||||
import ChildRelation from './falukant/data/child_relation.js';
|
||||
import LearnRecipient from './falukant/type/learn_recipient.js';
|
||||
import Learning from './falukant/data/learning.js';
|
||||
import Credit from './falukant/data/credit.js';
|
||||
import DebtorsPrism from './falukant/data/debtors_prism.js';
|
||||
import HealthActivity from './falukant/log/health_activity.js';
|
||||
|
||||
// — Politische Ämter (Politics) —
|
||||
import PoliticalOfficeType from './falukant/type/political_office_type.js';
|
||||
import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js';
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import Election from './falukant/data/election.js';
|
||||
import Candidate from './falukant/data/candidate.js';
|
||||
import Vote from './falukant/data/vote.js';
|
||||
import ElectionResult from './falukant/data/election_result.js';
|
||||
|
||||
const models = {
|
||||
SettingsType,
|
||||
UserParamValue,
|
||||
UserParamType,
|
||||
UserRightType,
|
||||
User,
|
||||
UserParam,
|
||||
Login,
|
||||
UserRight,
|
||||
InterestType,
|
||||
InterestTranslationType,
|
||||
Interest,
|
||||
ContactMessage,
|
||||
UserParamVisibilityType,
|
||||
UserParamVisibility,
|
||||
Folder,
|
||||
Image,
|
||||
ImageVisibilityType,
|
||||
ImageVisibilityUser,
|
||||
FolderImageVisibility,
|
||||
ImageImageVisibility,
|
||||
FolderVisibilityUser,
|
||||
GuestbookEntry,
|
||||
DiaryHistory,
|
||||
Diary,
|
||||
Forum,
|
||||
ForumPermission,
|
||||
ForumForumPermission,
|
||||
ForumUserPermission,
|
||||
Title,
|
||||
TitleHistory,
|
||||
Message,
|
||||
MessageHistory,
|
||||
MessageImage,
|
||||
Friendship,
|
||||
RegionType,
|
||||
RegionData,
|
||||
FalukantUser,
|
||||
FalukantPredefineFirstname,
|
||||
FalukantPredefineLastname,
|
||||
FalukantCharacter,
|
||||
FalukantStock,
|
||||
FalukantStockType,
|
||||
ProductType,
|
||||
Knowledge,
|
||||
TitleOfNobility,
|
||||
TitleRequirement,
|
||||
BranchType,
|
||||
Branch,
|
||||
Production,
|
||||
Inventory,
|
||||
BuyableStock,
|
||||
MoneyFlow,
|
||||
Director,
|
||||
DirectorProposal,
|
||||
TownProductWorth,
|
||||
DayProduction,
|
||||
DaySell,
|
||||
Notification,
|
||||
MarriageProposal,
|
||||
RelationshipType,
|
||||
Relationship,
|
||||
CharacterTrait,
|
||||
FalukantCharacterTrait,
|
||||
Mood,
|
||||
PromotionalGift,
|
||||
PromotionalGiftCharacterTrait,
|
||||
PromotionalGiftMood,
|
||||
PromotionalGiftLog,
|
||||
HouseType,
|
||||
BuyableHouse,
|
||||
UserHouse,
|
||||
SettingsType,
|
||||
UserParamValue,
|
||||
UserParamType,
|
||||
UserRightType,
|
||||
User,
|
||||
UserParam,
|
||||
Login,
|
||||
UserRight,
|
||||
InterestType,
|
||||
InterestTranslationType,
|
||||
Interest,
|
||||
ContactMessage,
|
||||
UserParamVisibilityType,
|
||||
UserParamVisibility,
|
||||
Folder,
|
||||
Image,
|
||||
ImageVisibilityType,
|
||||
ImageVisibilityUser,
|
||||
FolderImageVisibility,
|
||||
ImageImageVisibility,
|
||||
FolderVisibilityUser,
|
||||
GuestbookEntry,
|
||||
DiaryHistory,
|
||||
Diary,
|
||||
Forum,
|
||||
ForumPermission,
|
||||
ForumForumPermission,
|
||||
ForumUserPermission,
|
||||
Title,
|
||||
TitleHistory,
|
||||
Message,
|
||||
MessageHistory,
|
||||
MessageImage,
|
||||
Friendship,
|
||||
|
||||
// Falukant core
|
||||
RegionType,
|
||||
RegionData,
|
||||
FalukantUser,
|
||||
FalukantPredefineFirstname,
|
||||
FalukantPredefineLastname,
|
||||
FalukantCharacter,
|
||||
FalukantStock,
|
||||
FalukantStockType,
|
||||
ProductType,
|
||||
Knowledge,
|
||||
TitleOfNobility,
|
||||
TitleRequirement,
|
||||
BranchType,
|
||||
Branch,
|
||||
Production,
|
||||
Inventory,
|
||||
BuyableStock,
|
||||
MoneyFlow,
|
||||
Director,
|
||||
DirectorProposal,
|
||||
TownProductWorth,
|
||||
DayProduction,
|
||||
DaySell,
|
||||
Notification,
|
||||
MarriageProposal,
|
||||
RelationshipType,
|
||||
Relationship,
|
||||
CharacterTrait,
|
||||
FalukantCharacterTrait,
|
||||
Mood,
|
||||
PromotionalGift,
|
||||
PromotionalGiftCharacterTrait,
|
||||
PromotionalGiftMood,
|
||||
PromotionalGiftLog,
|
||||
HouseType,
|
||||
BuyableHouse,
|
||||
UserHouse,
|
||||
PartyType,
|
||||
MusicType,
|
||||
BanquetteType,
|
||||
Party,
|
||||
PartyInvitedNobility,
|
||||
ChildRelation,
|
||||
LearnRecipient,
|
||||
Learning,
|
||||
Credit,
|
||||
DebtorsPrism,
|
||||
HealthActivity,
|
||||
|
||||
// Politics
|
||||
PoliticalOfficeType,
|
||||
PoliticalOfficeRequirement,
|
||||
PoliticalOfficeBenefitType,
|
||||
PoliticalOfficeBenefit,
|
||||
PoliticalOffice,
|
||||
Election,
|
||||
Candidate,
|
||||
Vote,
|
||||
ElectionResult,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
@@ -180,6 +180,67 @@ export async function createTriggers() {
|
||||
$function$;
|
||||
`;
|
||||
|
||||
const createChildRelationNameFunction = `
|
||||
CREATE OR REPLACE FUNCTION falukant_data.populate_child_relation_names()
|
||||
RETURNS TRIGGER AS $$
|
||||
DECLARE
|
||||
v_first_name TEXT;
|
||||
v_last_name TEXT;
|
||||
v_full_father TEXT;
|
||||
v_full_mother TEXT;
|
||||
BEGIN
|
||||
-- Vaternamen holen
|
||||
SELECT pf.name, pl.name
|
||||
INTO v_first_name, v_last_name
|
||||
FROM falukant_data.character c
|
||||
JOIN falukant_predefine.firstname pf ON pf.id = c.first_name
|
||||
JOIN falukant_predefine.lastname pl ON pl.id = c.last_name
|
||||
WHERE c.id = NEW.father_character_id;
|
||||
|
||||
v_full_father := v_first_name || ' ' || v_last_name;
|
||||
|
||||
-- Mutternamen holen
|
||||
SELECT pf.name, pl.name
|
||||
INTO v_first_name, v_last_name
|
||||
FROM falukant_data.character c
|
||||
JOIN falukant_predefine.firstname pf ON pf.id = c.first_name
|
||||
JOIN falukant_predefine.lastname pl ON pl.id = c.last_name
|
||||
WHERE c.id = NEW.mother_character_id;
|
||||
|
||||
v_full_mother := v_first_name || ' ' || v_last_name;
|
||||
|
||||
-- Felder füllen
|
||||
NEW.father_name := v_full_father;
|
||||
NEW.mother_name := v_full_mother;
|
||||
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
`;
|
||||
|
||||
const createChildRelationNameTrigger = `
|
||||
DROP TRIGGER IF EXISTS trg_child_relation_populate_names
|
||||
ON falukant_data.child_relation;
|
||||
CREATE TRIGGER trg_child_relation_populate_names
|
||||
BEFORE INSERT ON falukant_data.child_relation
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION falukant_data.populate_child_relation_names();
|
||||
`;
|
||||
|
||||
const createRandomMoodUpdateMethod = `
|
||||
CREATE OR REPLACE FUNCTION falukant_data.get_random_mood_id()
|
||||
RETURNS INTEGER AS $$
|
||||
BEGIN
|
||||
RETURN (
|
||||
SELECT id
|
||||
FROM falukant_type.mood
|
||||
ORDER BY random()
|
||||
LIMIT 1
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql VOLATILE;
|
||||
`;
|
||||
|
||||
try {
|
||||
await sequelize.query(createTriggerFunction);
|
||||
await sequelize.query(createInsertTrigger);
|
||||
@@ -193,7 +254,10 @@ export async function createTriggers() {
|
||||
await sequelize.query(createKnowledgeTriggerMethod);
|
||||
await sequelize.query(createKnowledgeTrigger);
|
||||
await sequelize.query(updateMoney);
|
||||
await initializeCharacterTraitTrigger();
|
||||
await sequelize.query(createChildRelationNameFunction);
|
||||
await sequelize.query(createChildRelationNameTrigger);
|
||||
await sequelize.query(createRandomMoodUpdateMethod);
|
||||
await initializeCharacterTraitTrigger();
|
||||
|
||||
console.log('Triggers created successfully');
|
||||
} catch (error) {
|
||||
@@ -250,4 +314,3 @@ export const initializeCharacterTraitTrigger = async () => {
|
||||
console.error('❌ Fehler beim Erstellen des Triggers:', error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user