- Added functionality to manage selected users for adult folders and erotic videos, allowing for more granular visibility control. - Introduced new endpoints and methods in the SocialNetworkController and SocialNetworkService to handle selected users. - Updated the frontend components to include input fields for selected users in CreateFolderDialog, EditImageDialog, and EroticPicturesView. - Enhanced the routing to support fetching erotic folders and videos by username, improving user experience in profile views.
1137 lines
45 KiB
JavaScript
1137 lines
45 KiB
JavaScript
import RoomType from './chat/room_type.js';
|
|
import ChatRight from './chat/rights.js';
|
|
import ChatUserRight from './chat/user_rights.js';
|
|
import ChatUser from './chat/user.js';
|
|
import Room from './chat/room.js';
|
|
import User from './community/user.js';
|
|
import UserParam from './community/user_param.js';
|
|
import UserDashboard from './community/user_dashboard.js';
|
|
import UserParamType from './type/user_param.js';
|
|
import UserRightType from './type/user_right.js';
|
|
import UserRight from './community/user_right.js';
|
|
import SettingsType from './type/settings.js';
|
|
import UserParamValue from './type/user_param_value.js';
|
|
import InterestType from './type/interest.js';
|
|
import InterestTranslationType from './type/interest_translation.js';
|
|
import Interest from './community/interest.js';
|
|
import UserParamVisibilityType from './type/user_param_visibility.js';
|
|
import UserParamVisibility from './community/user_param_visibility.js';
|
|
import Folder from './community/folder.js';
|
|
import Image from './community/image.js';
|
|
import EroticVideo from './community/erotic_video.js';
|
|
import EroticContentReport from './community/erotic_content_report.js';
|
|
import ImageVisibilityType from './type/image_visibility.js';
|
|
import ImageVisibilityUser from './community/image_visibility_user.js';
|
|
import FolderImageVisibility from './community/folder_image_visibility.js';
|
|
import ImageImageVisibility from './community/image_image_visibility.js';
|
|
import FolderVisibilityUser from './community/folder_visibility_user.js';
|
|
import EroticVideoImageVisibility from './community/erotic_video_image_visibility.js';
|
|
import EroticVideoVisibilityUser from './community/erotic_video_visibility_user.js';
|
|
import GuestbookEntry from './community/guestbook.js';
|
|
import Forum from './forum/forum.js';
|
|
import Title from './forum/title.js';
|
|
import Message from './forum/message.js';
|
|
import MessageImage from './forum/message_image.js';
|
|
import MessageHistory from './forum/message_history.js';
|
|
import TitleHistory from './forum/title_history.js';
|
|
import ForumPermission from './forum/forum_permission.js';
|
|
import ForumUserPermission from './forum/forum_user_permission.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';
|
|
import FalukantCharacter from './falukant/data/character.js';
|
|
import FalukantPredefineFirstname from './falukant/predefine/firstname.js';
|
|
import FalukantPredefineLastname from './falukant/predefine/lastname.js';
|
|
import FalukantStock from './falukant/data/stock.js';
|
|
import FalukantStockType from './falukant/type/stock.js';
|
|
import Knowledge from './falukant/data/product_knowledge.js';
|
|
import ProductType from './falukant/type/product.js';
|
|
import TitleOfNobility from './falukant/type/title_of_nobility.js';
|
|
import TitleBenefit from './falukant/type/title_benefit.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/buyable_stock.js';
|
|
import MoneyFlow from './falukant/log/moneyflow.js';
|
|
import Director from './falukant/data/director.js';
|
|
import DirectorProposal from './falukant/data/director_proposal.js';
|
|
import TownProductWorth from './falukant/data/town_product_worth.js';
|
|
import DayProduction from './falukant/log/dayproduction.js';
|
|
import DaySell from './falukant/log/daysell.js';
|
|
import MarriageProposal from './falukant/data/marriage_proposal.js';
|
|
import Notification from './falukant/log/notification.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 RelationshipType from './falukant/type/relationship.js';
|
|
import Relationship from './falukant/data/relationship.js';
|
|
import RelationshipState from './falukant/data/relationship_state.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 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';
|
|
import PoliticalOfficePrerequisite from './falukant/predefine/political_office_prerequisite.js';
|
|
import PoliticalOfficeHistory from './falukant/log/political_office_history.js';
|
|
import ElectionHistory from './falukant/log/election_history.js';
|
|
import ChurchOfficeType from './falukant/type/church_office_type.js';
|
|
import ChurchOfficeRequirement from './falukant/predefine/church_office_requirement.js';
|
|
import ChurchOffice from './falukant/data/church_office.js';
|
|
import ChurchApplication from './falukant/data/church_application.js';
|
|
import Underground from './falukant/data/underground.js';
|
|
import UndergroundType from './falukant/type/underground.js';
|
|
import VehicleType from './falukant/type/vehicle.js';
|
|
import Vehicle from './falukant/data/vehicle.js';
|
|
import Transport from './falukant/data/transport.js';
|
|
import RegionDistance from './falukant/data/region_distance.js';
|
|
import WeatherType from './falukant/type/weather.js';
|
|
import Weather from './falukant/data/weather.js';
|
|
import ProductWeatherEffect from './falukant/type/product_weather_effect.js';
|
|
import ProductPriceHistory from './falukant/log/product_price_history.js';
|
|
import Blog from './community/blog.js';
|
|
import BlogPost from './community/blog_post.js';
|
|
import VocabCourse from './community/vocab_course.js';
|
|
import VocabCourseLesson from './community/vocab_course_lesson.js';
|
|
import VocabCourseEnrollment from './community/vocab_course_enrollment.js';
|
|
import VocabCourseProgress from './community/vocab_course_progress.js';
|
|
import VocabGrammarExerciseType from './community/vocab_grammar_exercise_type.js';
|
|
import VocabGrammarExercise from './community/vocab_grammar_exercise.js';
|
|
import VocabGrammarExerciseProgress from './community/vocab_grammar_exercise_progress.js';
|
|
import CalendarEvent from './community/calendar_event.js';
|
|
import Campaign from './match3/campaign.js';
|
|
import Match3Level from './match3/level.js';
|
|
import Objective from './match3/objective.js';
|
|
import UserProgress from './match3/userProgress.js';
|
|
import UserLevelProgress from './match3/userLevelProgress.js';
|
|
import TaxiGameState from './taxi/taxiGameState.js';
|
|
import TaxiLevelStats from './taxi/taxiLevelStats.js';
|
|
import TaxiMapType from './taxi/taxiMapType.js';
|
|
import TaxiMap from './taxi/taxiMap.js';
|
|
import TaxiMapTile from './taxi/taxiMapTile.js';
|
|
import TaxiMapTileHouse from './taxi/taxiMapTileHouse.js';
|
|
import TaxiStreetName from './taxi/taxiStreetName.js';
|
|
import TaxiMapTileStreet from './taxi/taxiMapTileStreet.js';
|
|
import TaxiHighscore from './minigames/taxiHighscore.js';
|
|
|
|
export default function setupAssociations() {
|
|
// RoomType 1:n Room
|
|
RoomType.hasMany(Room, { foreignKey: 'roomTypeId', as: 'rooms' });
|
|
Room.belongsTo(RoomType, { foreignKey: 'roomTypeId', as: 'roomType' });
|
|
// ChatUser <-> ChatRight n:m
|
|
ChatUser.belongsToMany(ChatRight, {
|
|
through: ChatUserRight,
|
|
foreignKey: 'chat_user_id',
|
|
otherKey: 'chat_right_id',
|
|
as: 'rights',
|
|
});
|
|
ChatRight.belongsToMany(ChatUser, {
|
|
through: ChatUserRight,
|
|
foreignKey: 'chat_right_id',
|
|
otherKey: 'chat_user_id',
|
|
as: 'users',
|
|
});
|
|
// ChatUser zu FalukantUser
|
|
ChatUser.belongsTo(FalukantUser, { foreignKey: 'falukant_user_id', as: 'falukantUser' });
|
|
FalukantUser.hasOne(ChatUser, { foreignKey: 'falukant_user_id', as: 'chatUser' });
|
|
// Chat Room associations
|
|
Room.belongsTo(User, { foreignKey: 'owner_id', as: 'owner' });
|
|
User.hasMany(Room, { foreignKey: 'owner_id', as: 'ownedRooms' });
|
|
|
|
Room.belongsTo(UserParamValue, { foreignKey: 'gender_restriction_id', as: 'genderRestriction' });
|
|
UserParamValue.hasMany(Room, { foreignKey: 'gender_restriction_id', as: 'roomsWithGenderRestriction' });
|
|
// UserParam related associations
|
|
SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' });
|
|
UserParamType.belongsTo(SettingsType, { foreignKey: 'settingsId', as: 'settings_type' });
|
|
|
|
UserParamType.hasMany(UserParam, { foreignKey: 'paramTypeId', as: 'user_params' });
|
|
UserParam.belongsTo(UserParamType, { foreignKey: 'paramTypeId', as: 'paramType' });
|
|
|
|
User.hasMany(UserParam, { foreignKey: 'userId', as: 'user_params' });
|
|
UserParam.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
|
|
User.hasOne(UserDashboard, { foreignKey: 'userId', as: 'dashboard' });
|
|
UserDashboard.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
|
|
UserParamValue.belongsTo(UserParamType, { foreignKey: 'userParamTypeId', as: 'user_param_value_type' });
|
|
UserParamType.hasMany(UserParamValue, { foreignKey: 'userParamTypeId', as: 'user_param_type_value' });
|
|
|
|
UserRight.belongsTo(User, { foreignKey: 'userId', as: 'user_with_rights' });
|
|
UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' });
|
|
UserRightType.hasMany(UserRight, { foreignKey: 'rightTypeId', as: 'user_rights' });
|
|
|
|
UserParam.hasMany(UserParamVisibility, { foreignKey: 'param_id', as: 'param_visibilities' });
|
|
UserParamVisibility.belongsTo(UserParam, { foreignKey: 'param_id', as: 'param' });
|
|
|
|
UserParamVisibility.belongsTo(UserParamVisibilityType, { foreignKey: 'visibility', as: 'visibility_type' });
|
|
UserParamVisibilityType.hasMany(UserParamVisibility, { foreignKey: 'visibility', as: 'user_param_visibilities' });
|
|
|
|
// Interest related associations
|
|
InterestType.hasMany(InterestTranslationType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
|
InterestTranslationType.belongsTo(InterestType, { foreignKey: 'interestsId', as: 'interest_translations' });
|
|
|
|
InterestType.hasMany(Interest, { foreignKey: 'userinterestId', as: 'user_interest_type' });
|
|
User.hasMany(Interest, { foreignKey: 'userId', as: 'user_interests' });
|
|
Interest.belongsTo(InterestType, { foreignKey: 'userinterestId', as: 'interest_type' });
|
|
Interest.belongsTo(User, { foreignKey: 'userId', as: 'interest_owner' });
|
|
|
|
// Folder and Image related associations
|
|
Folder.belongsTo(User, { foreignKey: 'userId' });
|
|
User.hasMany(Folder, { foreignKey: 'userId' });
|
|
|
|
Folder.belongsTo(Folder, { foreignKey: 'parentId', as: 'parent' });
|
|
Folder.hasMany(Folder, { foreignKey: 'parentId', as: 'children' });
|
|
|
|
Image.belongsTo(Folder, { foreignKey: 'folderId' });
|
|
Folder.hasMany(Image, { foreignKey: 'folderId' });
|
|
|
|
Image.belongsTo(User, { foreignKey: 'userId' });
|
|
User.hasMany(Image, { foreignKey: 'userId' });
|
|
|
|
EroticVideo.belongsTo(User, { foreignKey: 'userId', as: 'owner' });
|
|
User.hasMany(EroticVideo, { foreignKey: 'userId', as: 'eroticVideos' });
|
|
|
|
EroticContentReport.belongsTo(User, { foreignKey: 'reporterId', as: 'reporter' });
|
|
User.hasMany(EroticContentReport, { foreignKey: 'reporterId', as: 'eroticContentReports' });
|
|
EroticContentReport.belongsTo(User, { foreignKey: 'handledBy', as: 'moderator' });
|
|
User.hasMany(EroticContentReport, { foreignKey: 'handledBy', as: 'handledEroticContentReports' });
|
|
|
|
// Image visibility associations
|
|
Folder.belongsToMany(ImageVisibilityType, {
|
|
through: FolderImageVisibility,
|
|
foreignKey: 'folderId',
|
|
otherKey: 'visibilityTypeId'
|
|
});
|
|
ImageVisibilityType.belongsToMany(Folder, {
|
|
through: FolderImageVisibility,
|
|
foreignKey: 'visibilityTypeId',
|
|
otherKey: 'folderId'
|
|
});
|
|
|
|
Image.belongsToMany(ImageVisibilityType, {
|
|
through: ImageImageVisibility,
|
|
foreignKey: 'imageId',
|
|
otherKey: 'visibilityTypeId'
|
|
});
|
|
ImageVisibilityType.belongsToMany(Image, {
|
|
through: ImageImageVisibility,
|
|
foreignKey: 'visibilityTypeId',
|
|
otherKey: 'imageId'
|
|
});
|
|
|
|
EroticVideo.belongsToMany(ImageVisibilityType, {
|
|
through: EroticVideoImageVisibility,
|
|
foreignKey: 'eroticVideoId',
|
|
otherKey: 'visibilityTypeId'
|
|
});
|
|
ImageVisibilityType.belongsToMany(EroticVideo, {
|
|
through: EroticVideoImageVisibility,
|
|
foreignKey: 'visibilityTypeId',
|
|
otherKey: 'eroticVideoId'
|
|
});
|
|
|
|
Folder.belongsToMany(ImageVisibilityUser, {
|
|
through: FolderVisibilityUser,
|
|
foreignKey: 'folderId',
|
|
otherKey: 'visibilityUserId'
|
|
});
|
|
ImageVisibilityUser.belongsToMany(Folder, {
|
|
through: FolderVisibilityUser,
|
|
foreignKey: 'visibilityUserId',
|
|
otherKey: 'folderId'
|
|
});
|
|
|
|
EroticVideo.belongsToMany(User, {
|
|
through: EroticVideoVisibilityUser,
|
|
foreignKey: 'eroticVideoId',
|
|
otherKey: 'userId',
|
|
as: 'selectedVisibilityUsers'
|
|
});
|
|
User.belongsToMany(EroticVideo, {
|
|
through: EroticVideoVisibilityUser,
|
|
foreignKey: 'userId',
|
|
otherKey: 'eroticVideoId',
|
|
as: 'visibleEroticVideos'
|
|
});
|
|
|
|
// Guestbook related associations
|
|
User.hasMany(GuestbookEntry, { foreignKey: 'recipientId', as: 'receivedEntries' });
|
|
User.hasMany(GuestbookEntry, { foreignKey: 'senderId', as: 'sentEntries' });
|
|
GuestbookEntry.belongsTo(User, { foreignKey: 'recipientId', as: 'recipient' });
|
|
GuestbookEntry.belongsTo(User, { foreignKey: 'senderId', as: 'sender' });
|
|
|
|
// Forum related associations
|
|
Forum.hasMany(Title, { foreignKey: 'forumId' });
|
|
Title.belongsTo(Forum, { foreignKey: 'forumId' });
|
|
|
|
Title.belongsTo(User, { foreignKey: 'createdBy', as: 'createdByUser' });
|
|
User.hasMany(Title, { foreignKey: 'createdBy', as: 'titles' });
|
|
|
|
Title.hasMany(Message, { foreignKey: 'titleId', as: 'messages' });
|
|
Message.belongsTo(Title, { foreignKey: 'titleId', as: 'title' });
|
|
|
|
Message.belongsTo(User, { foreignKey: 'createdBy', as: 'lastMessageUser' });
|
|
User.hasMany(Message, { foreignKey: 'createdBy', as: 'userMessages' });
|
|
|
|
Message.hasMany(MessageImage, { foreignKey: 'messageId' });
|
|
MessageImage.belongsTo(Message, { foreignKey: 'messageId' });
|
|
|
|
Message.hasMany(MessageHistory, { foreignKey: 'messageId' });
|
|
MessageHistory.belongsTo(Message, { foreignKey: 'messageId' });
|
|
|
|
Title.hasMany(TitleHistory, { foreignKey: 'titleId' });
|
|
TitleHistory.belongsTo(Title, { foreignKey: 'titleId' });
|
|
|
|
// Forum permissions associations
|
|
Forum.hasMany(ForumUserPermission, { foreignKey: 'forumId', as: 'userPermissions' });
|
|
ForumUserPermission.belongsTo(Forum, { foreignKey: 'forumId' });
|
|
|
|
User.hasMany(ForumUserPermission, { foreignKey: 'userId', as: 'userPermissions' });
|
|
ForumUserPermission.belongsTo(User, { foreignKey: 'userId' });
|
|
|
|
Forum.belongsToMany(ForumPermission, {
|
|
through: ForumForumPermission,
|
|
foreignKey: 'forumId',
|
|
as: 'associatedPermissions'
|
|
});
|
|
|
|
ForumPermission.belongsToMany(Forum, {
|
|
through: ForumForumPermission,
|
|
foreignKey: 'permissionId',
|
|
as: 'forums'
|
|
});
|
|
|
|
ForumPermission.hasMany(ForumUserPermission, { foreignKey: 'permissionId' });
|
|
ForumUserPermission.belongsTo(ForumPermission, { foreignKey: 'permissionId' });
|
|
|
|
Friendship.belongsTo(User, { foreignKey: 'user1Id', as: 'friendSender' });
|
|
Friendship.belongsTo(User, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
|
User.hasMany(Friendship, { foreignKey: 'user1Id', as: 'friendSender' });
|
|
User.hasMany(Friendship, { foreignKey: 'user2Id', as: 'friendReceiver' });
|
|
|
|
User.hasMany(FalukantUser, { foreignKey: 'userId', as: 'falukantData' });
|
|
FalukantUser.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
|
|
RegionType.hasMany(RegionType, { foreignKey: 'parentId', as: 'children' });
|
|
RegionType.belongsTo(RegionType, { foreignKey: 'parentId', as: 'parent' });
|
|
|
|
RegionData.hasMany(RegionData, { foreignKey: 'parentId', as: 'children' });
|
|
RegionData.belongsTo(RegionData, { foreignKey: 'parentId', as: 'parent' });
|
|
|
|
RegionData.belongsTo(RegionType, { foreignKey: 'regionTypeId', as: 'regionType' });
|
|
RegionType.hasMany(RegionData, { foreignKey: 'regionTypeId', as: 'regions' });
|
|
|
|
Weather.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasOne(Weather, { foreignKey: 'regionId', as: 'weather' });
|
|
|
|
Weather.belongsTo(WeatherType, { foreignKey: 'weatherTypeId', as: 'weatherType' });
|
|
WeatherType.hasMany(Weather, { foreignKey: 'weatherTypeId', as: 'weathers' });
|
|
|
|
ProductWeatherEffect.belongsTo(ProductType, { foreignKey: 'productId', as: 'product' });
|
|
ProductType.hasMany(ProductWeatherEffect, { foreignKey: 'productId', as: 'weatherEffects' });
|
|
|
|
ProductWeatherEffect.belongsTo(WeatherType, { foreignKey: 'weatherTypeId', as: 'weatherType' });
|
|
WeatherType.hasMany(ProductWeatherEffect, { foreignKey: 'weatherTypeId', as: 'productEffects' });
|
|
|
|
Production.belongsTo(WeatherType, { foreignKey: 'weatherTypeId', as: 'weatherType' });
|
|
WeatherType.hasMany(Production, { foreignKey: 'weatherTypeId', as: 'productions' });
|
|
|
|
FalukantUser.belongsTo(RegionData, { foreignKey: 'mainBranchRegionId', as: 'mainBranchRegion' });
|
|
RegionData.hasMany(FalukantUser, { foreignKey: 'mainBranchRegionId', as: 'users' });
|
|
|
|
FalukantCharacter.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
|
FalukantUser.hasOne(FalukantCharacter, { foreignKey: 'userId', as: 'character' });
|
|
|
|
FalukantCharacter.belongsTo(FalukantPredefineFirstname, { foreignKey: 'firstName', as: 'definedFirstName' });
|
|
FalukantPredefineFirstname.hasMany(FalukantCharacter, { foreignKey: 'firstName', as: 'charactersWithFirstName' });
|
|
|
|
FalukantCharacter.belongsTo(FalukantPredefineLastname, { foreignKey: 'lastName', as: 'definedLastName' });
|
|
FalukantPredefineLastname.hasMany(FalukantCharacter, { foreignKey: 'lastName', as: 'charactersWithLastName' });
|
|
|
|
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' });
|
|
|
|
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' });
|
|
|
|
TitleRequirement.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
|
TitleOfNobility.hasMany(TitleRequirement, { foreignKey: 'titleId', as: 'requirements' });
|
|
TitleOfNobility.hasMany(TitleBenefit, { foreignKey: 'titleId', as: 'benefits' });
|
|
TitleBenefit.belongsTo(TitleOfNobility, { foreignKey: 'titleId', as: 'title' });
|
|
|
|
Branch.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasMany(Branch, { foreignKey: 'regionId', as: 'branches' });
|
|
|
|
Branch.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
|
FalukantUser.hasMany(Branch, { foreignKey: 'falukantUserId', as: 'branches' });
|
|
|
|
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' });
|
|
|
|
MoneyFlow.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'user' });
|
|
FalukantUser.hasMany(MoneyFlow, { foreignKey: 'falukantUserId', as: 'flows' });
|
|
|
|
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' });
|
|
|
|
Director.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
|
FalukantCharacter.hasMany(Director, { foreignKey: 'directorCharacterId', as: 'directors' });
|
|
|
|
DirectorProposal.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
|
FalukantUser.hasMany(DirectorProposal, { foreignKey: 'employerUserId', as: 'directorProposals' });
|
|
|
|
DirectorProposal.belongsTo(FalukantCharacter, { foreignKey: 'directorCharacterId', as: 'character' });
|
|
FalukantCharacter.hasMany(DirectorProposal, { foreignKey: 'directorCharacterId', as: 'directorProposals' });
|
|
|
|
TownProductWorth.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
|
ProductType.hasMany(TownProductWorth, { foreignKey: 'productId', as: 'townProductWorths' });
|
|
|
|
TownProductWorth.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasMany(TownProductWorth, { foreignKey: 'regionId', as: 'townProductWorths' });
|
|
|
|
DayProduction.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
|
ProductType.hasMany(DayProduction, { foreignKey: 'productId', as: 'dayProductions' });
|
|
|
|
DayProduction.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasMany(DayProduction, { foreignKey: 'regionId', as: 'dayProductions' });
|
|
|
|
DayProduction.belongsTo(FalukantUser, { foreignKey: 'producerId', as: 'user' });
|
|
FalukantUser.hasMany(DayProduction, { foreignKey: 'producerId', as: 'dayProductions' });
|
|
|
|
DaySell.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
|
ProductType.hasMany(DaySell, { foreignKey: 'productId', as: 'daySells' });
|
|
|
|
DaySell.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasMany(DaySell, { foreignKey: 'regionId', as: 'daySells' });
|
|
|
|
DaySell.belongsTo(FalukantUser, { foreignKey: 'sellerId', as: 'user' });
|
|
FalukantUser.hasMany(DaySell, { foreignKey: 'sellerId', as: 'daySells' });
|
|
|
|
// Produkt-Preishistorie (Zeitreihe für Preiskurven)
|
|
ProductPriceHistory.belongsTo(ProductType, { foreignKey: 'productId', as: 'productType' });
|
|
ProductType.hasMany(ProductPriceHistory, { foreignKey: 'productId', as: 'priceHistory' });
|
|
|
|
ProductPriceHistory.belongsTo(RegionData, { foreignKey: 'regionId', as: 'region' });
|
|
RegionData.hasMany(ProductPriceHistory, { foreignKey: 'regionId', as: 'productPriceHistory' });
|
|
|
|
Notification.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
|
FalukantUser.hasMany(Notification, { foreignKey: 'userId', as: 'notifications' });
|
|
|
|
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', });
|
|
|
|
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.hasOne(RelationshipState, { foreignKey: 'relationshipId', as: 'state' });
|
|
RelationshipState.belongsTo(Relationship, { foreignKey: 'relationshipId', as: 'relationship' });
|
|
|
|
PromotionalGiftLog.belongsTo(PromotionalGift, { foreignKey: 'giftId', as: 'gift' });
|
|
PromotionalGift.hasMany(PromotionalGiftLog, { foreignKey: 'giftId', as: 'logs' });
|
|
|
|
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'senderCharacterId', as: 'character' });
|
|
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'senderCharacterId', as: 'logs' });
|
|
|
|
PromotionalGiftLog.belongsTo(FalukantCharacter, { foreignKey: 'recipientCharacterId', as: 'recipient' });
|
|
FalukantCharacter.hasMany(PromotionalGiftLog, { foreignKey: 'recipientCharacterId', as: 'giftlogs' });
|
|
|
|
// Vehicles & Transports
|
|
|
|
VehicleType.hasMany(Vehicle, {
|
|
foreignKey: 'vehicleTypeId',
|
|
as: 'vehicles',
|
|
});
|
|
Vehicle.belongsTo(VehicleType, {
|
|
foreignKey: 'vehicleTypeId',
|
|
as: 'type',
|
|
});
|
|
|
|
FalukantUser.hasMany(Vehicle, {
|
|
foreignKey: 'falukantUserId',
|
|
as: 'vehicles',
|
|
});
|
|
Vehicle.belongsTo(FalukantUser, {
|
|
foreignKey: 'falukantUserId',
|
|
as: 'owner',
|
|
});
|
|
|
|
RegionData.hasMany(Vehicle, {
|
|
foreignKey: 'regionId',
|
|
as: 'vehicles',
|
|
});
|
|
Vehicle.belongsTo(RegionData, {
|
|
foreignKey: 'regionId',
|
|
as: 'region',
|
|
});
|
|
|
|
// Region distances
|
|
RegionData.hasMany(RegionDistance, {
|
|
foreignKey: 'sourceRegionId',
|
|
as: 'distancesFrom',
|
|
});
|
|
RegionData.hasMany(RegionDistance, {
|
|
foreignKey: 'targetRegionId',
|
|
as: 'distancesTo',
|
|
});
|
|
RegionDistance.belongsTo(RegionData, {
|
|
foreignKey: 'sourceRegionId',
|
|
as: 'sourceRegion',
|
|
});
|
|
RegionDistance.belongsTo(RegionData, {
|
|
foreignKey: 'targetRegionId',
|
|
as: 'targetRegion',
|
|
});
|
|
|
|
Transport.belongsTo(RegionData, {
|
|
foreignKey: 'sourceRegionId',
|
|
as: 'sourceRegion',
|
|
});
|
|
Transport.belongsTo(RegionData, {
|
|
foreignKey: 'targetRegionId',
|
|
as: 'targetRegion',
|
|
});
|
|
|
|
RegionData.hasMany(Transport, {
|
|
foreignKey: 'sourceRegionId',
|
|
as: 'outgoingTransports',
|
|
});
|
|
RegionData.hasMany(Transport, {
|
|
foreignKey: 'targetRegionId',
|
|
as: 'incomingTransports',
|
|
});
|
|
|
|
Transport.belongsTo(ProductType, {
|
|
foreignKey: 'productId',
|
|
as: 'productType',
|
|
});
|
|
ProductType.hasMany(Transport, {
|
|
foreignKey: 'productId',
|
|
as: 'transports',
|
|
});
|
|
|
|
Transport.belongsTo(Vehicle, {
|
|
foreignKey: 'vehicleId',
|
|
as: 'vehicle',
|
|
});
|
|
Vehicle.hasMany(Transport, {
|
|
foreignKey: 'vehicleId',
|
|
as: 'transports',
|
|
});
|
|
|
|
PromotionalGift.hasMany(PromotionalGiftCharacterTrait, { foreignKey: 'gift_id', as: 'characterTraits' });
|
|
PromotionalGift.hasMany(PromotionalGiftMood, { foreignKey: 'gift_id', as: 'promotionalgiftmoods' });
|
|
|
|
PromotionalGiftCharacterTrait.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactertrait' });
|
|
PromotionalGiftMood.belongsTo(PromotionalGift, { foreignKey: 'gift_id', as: 'promotionalgiftcharactermood' });
|
|
|
|
HouseType.hasMany(BuyableHouse, { foreignKey: 'houseTypeId', as: 'buyableHouses' });
|
|
BuyableHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
|
|
|
HouseType.hasMany(UserHouse, { foreignKey: 'houseTypeId', as: 'userHouses' });
|
|
UserHouse.belongsTo(HouseType, { foreignKey: 'houseTypeId', as: 'houseType' });
|
|
|
|
FalukantUser.hasOne(UserHouse, { foreignKey: 'userId', as: 'userHouse' });
|
|
UserHouse.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'houseUser' });
|
|
|
|
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: 'partyId',
|
|
otherKey: 'titleOfNobilityId',
|
|
as: 'invitedNobilities',
|
|
});
|
|
TitleOfNobility.belongsToMany(Party, {
|
|
through: PartyInvitedNobility,
|
|
foreignKey: 'titleOfNobilityId',
|
|
otherKey: 'partyId',
|
|
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',
|
|
constraints: false
|
|
}
|
|
);
|
|
|
|
LearnRecipient.hasMany(Learning, {
|
|
foreignKey: 'learningRecipientId',
|
|
as: 'learnings',
|
|
constraints: false
|
|
});
|
|
|
|
Learning.belongsTo(FalukantUser, {
|
|
foreignKey: 'associatedFalukantUserId',
|
|
as: 'learner',
|
|
constraints: false
|
|
}
|
|
);
|
|
|
|
FalukantUser.hasMany(Learning, {
|
|
foreignKey: 'associatedFalukantUserId',
|
|
as: 'learnings',
|
|
constraints: false
|
|
});
|
|
|
|
Learning.belongsTo(ProductType, {
|
|
foreignKey: 'productId',
|
|
as: 'productType',
|
|
constraints: false
|
|
});
|
|
|
|
ProductType.hasMany(Learning, {
|
|
foreignKey: 'productId',
|
|
as: 'learnings',
|
|
constraints: false
|
|
});
|
|
|
|
Learning.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'associatedLearningCharacterId',
|
|
as: 'learningCharacter',
|
|
constraints: false
|
|
});
|
|
|
|
FalukantCharacter.hasMany(Learning, {
|
|
foreignKey: 'associatedLearningCharacterId',
|
|
as: 'learningsCharacter',
|
|
constraints: false
|
|
});
|
|
|
|
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.hasOne(PoliticalOffice, {
|
|
foreignKey: 'characterId',
|
|
as: 'heldOffice'
|
|
});
|
|
|
|
// elections
|
|
Election.belongsTo(PoliticalOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'officeType'
|
|
});
|
|
PoliticalOfficeType.hasMany(Election, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'elections'
|
|
});
|
|
|
|
Election.belongsTo(RegionData, {
|
|
foreignKey: 'regionId',
|
|
as: 'region'
|
|
});
|
|
|
|
RegionData.hasMany(Election, {
|
|
foreignKey: 'regionId',
|
|
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'
|
|
});
|
|
|
|
PoliticalOfficePrerequisite.belongsTo(PoliticalOfficeType, {
|
|
foreignKey: 'office_type_id',
|
|
as: 'officeTypePrerequisite',
|
|
});
|
|
|
|
PoliticalOfficeType.hasMany(PoliticalOfficePrerequisite, {
|
|
foreignKey: 'office_type_id',
|
|
as: 'prerequisites',
|
|
});
|
|
|
|
PoliticalOfficeHistory.belongsTo(PoliticalOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'officeTypeHistory',
|
|
});
|
|
|
|
PoliticalOfficeType.hasMany(PoliticalOfficeHistory, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'history',
|
|
});
|
|
|
|
FalukantCharacter.hasMany(PoliticalOfficeHistory, {
|
|
foreignKey: 'characterId',
|
|
as: 'officeHistories',
|
|
});
|
|
PoliticalOfficeHistory.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'characterId',
|
|
as: 'character',
|
|
});
|
|
|
|
ElectionHistory.belongsTo(PoliticalOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'officeTypeHistory',
|
|
});
|
|
|
|
PoliticalOfficeType.hasMany(ElectionHistory, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'electionHistory',
|
|
}
|
|
);
|
|
|
|
// — Church Offices —
|
|
|
|
// Requirements for church office
|
|
ChurchOfficeRequirement.belongsTo(ChurchOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'officeType'
|
|
});
|
|
ChurchOfficeType.hasMany(ChurchOfficeRequirement, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'requirements'
|
|
});
|
|
|
|
// Prerequisite office type
|
|
ChurchOfficeRequirement.belongsTo(ChurchOfficeType, {
|
|
foreignKey: 'prerequisiteOfficeTypeId',
|
|
as: 'prerequisiteOfficeType'
|
|
});
|
|
|
|
// Actual church office holdings
|
|
ChurchOffice.belongsTo(ChurchOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'type'
|
|
});
|
|
ChurchOfficeType.hasMany(ChurchOffice, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'offices'
|
|
});
|
|
|
|
ChurchOffice.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'characterId',
|
|
as: 'holder'
|
|
});
|
|
FalukantCharacter.hasOne(ChurchOffice, {
|
|
foreignKey: 'characterId',
|
|
as: 'heldChurchOffice'
|
|
});
|
|
|
|
// Supervisor relationship
|
|
ChurchOffice.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'supervisorId',
|
|
as: 'supervisor'
|
|
});
|
|
|
|
// Region relationship
|
|
ChurchOffice.belongsTo(RegionData, {
|
|
foreignKey: 'regionId',
|
|
as: 'region'
|
|
});
|
|
RegionData.hasMany(ChurchOffice, {
|
|
foreignKey: 'regionId',
|
|
as: 'churchOffices'
|
|
});
|
|
|
|
// Applications for church office
|
|
ChurchApplication.belongsTo(ChurchOfficeType, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'officeType'
|
|
});
|
|
ChurchOfficeType.hasMany(ChurchApplication, {
|
|
foreignKey: 'officeTypeId',
|
|
as: 'applications'
|
|
});
|
|
|
|
ChurchApplication.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'characterId',
|
|
as: 'applicant'
|
|
});
|
|
FalukantCharacter.hasMany(ChurchApplication, {
|
|
foreignKey: 'characterId',
|
|
as: 'churchApplications'
|
|
});
|
|
|
|
ChurchApplication.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'supervisorId',
|
|
as: 'supervisor'
|
|
});
|
|
FalukantCharacter.hasMany(ChurchApplication, {
|
|
foreignKey: 'supervisorId',
|
|
as: 'supervisedApplications'
|
|
});
|
|
|
|
ChurchApplication.belongsTo(RegionData, {
|
|
foreignKey: 'regionId',
|
|
as: 'region'
|
|
});
|
|
RegionData.hasMany(ChurchApplication, {
|
|
foreignKey: 'regionId',
|
|
as: 'churchApplications'
|
|
});
|
|
|
|
Underground.belongsTo(UndergroundType, {
|
|
foreignKey: 'undergroundTypeId',
|
|
as: 'undergroundType'
|
|
});
|
|
UndergroundType.hasMany(Underground, {
|
|
foreignKey: 'undergroundTypeId',
|
|
as: 'undergrounds'
|
|
});
|
|
|
|
// 2) Täter (performer)
|
|
Underground.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'performerId',
|
|
as: 'performer'
|
|
});
|
|
FalukantCharacter.hasMany(Underground, {
|
|
foreignKey: 'performerId',
|
|
as: 'performedUndergrounds'
|
|
});
|
|
|
|
// 3) Opfer (victim)
|
|
Underground.belongsTo(FalukantCharacter, {
|
|
foreignKey: 'victimId',
|
|
as: 'victim'
|
|
});
|
|
FalukantCharacter.hasMany(Underground, {
|
|
foreignKey: 'victimId',
|
|
as: 'victimUndergrounds'
|
|
});
|
|
|
|
// Blog associations
|
|
Blog.belongsTo(User, { foreignKey: 'user_id', as: 'owner' });
|
|
User.hasMany(Blog, { foreignKey: 'user_id', as: 'blogs' });
|
|
BlogPost.belongsTo(Blog, { foreignKey: 'blog_id', as: 'blog' });
|
|
Blog.hasMany(BlogPost, { foreignKey: 'blog_id', as: 'posts' });
|
|
BlogPost.belongsTo(User, { foreignKey: 'user_id', as: 'author' });
|
|
User.hasMany(BlogPost, { foreignKey: 'user_id', as: 'blogPosts' });
|
|
|
|
// Match3 Campaign & Levels
|
|
Campaign.hasMany(Match3Level, { foreignKey: 'campaignId', as: 'levels' });
|
|
Match3Level.belongsTo(Campaign, { foreignKey: 'campaignId', as: 'campaign' });
|
|
Match3Level.hasMany(Objective, { foreignKey: 'levelId', as: 'objectives' });
|
|
Objective.belongsTo(Match3Level, { foreignKey: 'levelId', as: 'level' });
|
|
// User progress tracking
|
|
Campaign.hasMany(UserProgress, { foreignKey: 'campaignId', as: 'userProgressEntries' });
|
|
UserProgress.belongsTo(Campaign, { foreignKey: 'campaignId', as: 'campaign' });
|
|
UserProgress.hasMany(UserLevelProgress, { foreignKey: 'userProgressId', as: 'levelProgress' });
|
|
UserLevelProgress.belongsTo(UserProgress, { foreignKey: 'userProgressId', as: 'userProgress' });
|
|
Match3Level.hasMany(UserLevelProgress, { foreignKey: 'levelId', as: 'userLevelProgress' });
|
|
UserLevelProgress.belongsTo(Match3Level, { foreignKey: 'levelId', as: 'level' });
|
|
|
|
// Taxi Game associations
|
|
TaxiGameState.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasOne(TaxiGameState, { foreignKey: 'userId', as: 'taxiGameState' });
|
|
|
|
TaxiLevelStats.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(TaxiLevelStats, { foreignKey: 'userId', as: 'taxiLevelStats' });
|
|
|
|
// Taxi Map associations
|
|
TaxiMap.belongsTo(TaxiMapType, { foreignKey: 'mapTypeId', as: 'mapType' });
|
|
TaxiMapType.hasMany(TaxiMap, { foreignKey: 'mapTypeId', as: 'maps' });
|
|
|
|
// Tiles
|
|
TaxiMap.hasMany(TaxiMapTile, { foreignKey: 'mapId', as: 'tiles' });
|
|
TaxiMapTile.belongsTo(TaxiMap, { foreignKey: 'mapId', as: 'map' });
|
|
|
|
// Street name models
|
|
TaxiMapTileStreet.belongsTo(TaxiMap, { foreignKey: 'map_id', as: 'map' });
|
|
TaxiMap.hasMany(TaxiMapTileStreet, { foreignKey: 'map_id', as: 'tileStreets' });
|
|
|
|
TaxiMapTileStreet.belongsTo(TaxiStreetName, { foreignKey: 'street_name_h_id', as: 'streetNameH' });
|
|
TaxiMapTileStreet.belongsTo(TaxiStreetName, { foreignKey: 'street_name_v_id', as: 'streetNameV' });
|
|
|
|
// Houses per tile (one row per corner)
|
|
TaxiMap.hasMany(TaxiMapTileHouse, { foreignKey: 'map_id', as: 'tileHouses' });
|
|
TaxiMapTileHouse.belongsTo(TaxiMap, { foreignKey: 'map_id', as: 'map' });
|
|
|
|
// Taxi Highscore associations
|
|
TaxiHighscore.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(TaxiHighscore, { foreignKey: 'userId', as: 'taxiHighscores' });
|
|
|
|
TaxiHighscore.belongsTo(TaxiMap, { foreignKey: 'mapId', as: 'map' });
|
|
TaxiMap.hasMany(TaxiHighscore, { foreignKey: 'mapId', as: 'highscores' });
|
|
|
|
// Vocab Course associations
|
|
VocabCourse.belongsTo(User, { foreignKey: 'ownerUserId', as: 'owner' });
|
|
User.hasMany(VocabCourse, { foreignKey: 'ownerUserId', as: 'ownedCourses' });
|
|
|
|
VocabCourseLesson.belongsTo(VocabCourse, { foreignKey: 'courseId', as: 'course' });
|
|
VocabCourse.hasMany(VocabCourseLesson, { foreignKey: 'courseId', as: 'lessons' });
|
|
|
|
VocabCourseEnrollment.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(VocabCourseEnrollment, { foreignKey: 'userId', as: 'courseEnrollments' });
|
|
VocabCourseEnrollment.belongsTo(VocabCourse, { foreignKey: 'courseId', as: 'course' });
|
|
VocabCourse.hasMany(VocabCourseEnrollment, { foreignKey: 'courseId', as: 'enrollments' });
|
|
|
|
VocabCourseProgress.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(VocabCourseProgress, { foreignKey: 'userId', as: 'courseProgress' });
|
|
VocabCourseProgress.belongsTo(VocabCourse, { foreignKey: 'courseId', as: 'course' });
|
|
VocabCourse.hasMany(VocabCourseProgress, { foreignKey: 'courseId', as: 'progress' });
|
|
VocabCourseProgress.belongsTo(VocabCourseLesson, { foreignKey: 'lessonId', as: 'lesson' });
|
|
VocabCourseLesson.hasMany(VocabCourseProgress, { foreignKey: 'lessonId', as: 'progress' });
|
|
|
|
// Grammar Exercise associations
|
|
VocabGrammarExercise.belongsTo(VocabCourseLesson, { foreignKey: 'lessonId', as: 'lesson' });
|
|
VocabCourseLesson.hasMany(VocabGrammarExercise, { foreignKey: 'lessonId', as: 'grammarExercises' });
|
|
VocabGrammarExercise.belongsTo(VocabGrammarExerciseType, { foreignKey: 'exerciseTypeId', as: 'exerciseType' });
|
|
VocabGrammarExerciseType.hasMany(VocabGrammarExercise, { foreignKey: 'exerciseTypeId', as: 'exercises' });
|
|
VocabGrammarExercise.belongsTo(User, { foreignKey: 'createdByUserId', as: 'creator' });
|
|
User.hasMany(VocabGrammarExercise, { foreignKey: 'createdByUserId', as: 'createdGrammarExercises' });
|
|
|
|
VocabGrammarExerciseProgress.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(VocabGrammarExerciseProgress, { foreignKey: 'userId', as: 'grammarExerciseProgress' });
|
|
VocabGrammarExerciseProgress.belongsTo(VocabGrammarExercise, { foreignKey: 'exerciseId', as: 'exercise' });
|
|
VocabGrammarExercise.hasMany(VocabGrammarExerciseProgress, { foreignKey: 'exerciseId', as: 'progress' });
|
|
|
|
// Calendar associations
|
|
CalendarEvent.belongsTo(User, { foreignKey: 'userId', as: 'user' });
|
|
User.hasMany(CalendarEvent, { foreignKey: 'userId', as: 'calendarEvents' });
|
|
}
|