Added movability of dialogs
This commit is contained in:
@@ -5,6 +5,9 @@ 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';
|
||||
|
||||
export default function setupAssociations() {
|
||||
SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' });
|
||||
@@ -18,7 +21,23 @@ export default function setupAssociations() {
|
||||
|
||||
UserRight.belongsTo(User, { foreignKey: 'userId' });
|
||||
UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' });
|
||||
UserRightType.hasMany(UserRight, { foreignKey: 'rightTypeId', as: 'rightType' });
|
||||
|
||||
UserParamType.hasMany(UserParamValue, { foreignKey: 'userParamTypeId', as: 'user_param_values' });
|
||||
UserParamValue.belongsTo(UserParamType, { foreignKey: 'userParamTypeId', as: 'user_param_type' });
|
||||
|
||||
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_interest' });
|
||||
Interest.belongsTo(InterestType, { foreignKey: 'userinterestId', as: 'user_interest_type' });
|
||||
Interest.belongsTo(User, { foreignKey: 'userId', as: 'user_interest' });
|
||||
|
||||
InterestTranslationType.belongsTo(UserParamValue, {
|
||||
foreignKey: 'language',
|
||||
targetKey: 'id',
|
||||
as: 'user_param_value'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
11
backend/models/community/interest.js
Normal file
11
backend/models/community/interest.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const interest = sequelize.define('interest_type', {
|
||||
}, {
|
||||
tableName: 'interest',
|
||||
schema: 'community',
|
||||
underscored: true
|
||||
});
|
||||
|
||||
export default interest;
|
||||
@@ -6,6 +6,10 @@ import User from './community/user.js';
|
||||
import UserParam from './community/user_param.js';
|
||||
import Login from './logs/login.js';
|
||||
import UserRight from './community/user_right.js';
|
||||
import InterestType from './type/interest.js';
|
||||
import InterestTranslationType from './type/interest_translation.js';
|
||||
import Interest from './community/interest.js';
|
||||
import ContactMessage from './service/contactmessage.js';
|
||||
|
||||
const models = {
|
||||
SettingsType,
|
||||
@@ -16,6 +20,10 @@ const models = {
|
||||
UserParam,
|
||||
Login,
|
||||
UserRight,
|
||||
InterestType,
|
||||
InterestTranslationType,
|
||||
Interest,
|
||||
ContactMessage,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
65
backend/models/service/contactmessage.js
Normal file
65
backend/models/service/contactmessage.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
import { encrypt, decrypt } from '../../utils/encryption.js';
|
||||
|
||||
const ContactMessage = sequelize.define('contact_message', {
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
set(value) {
|
||||
if (value) {
|
||||
const encryptedValue = encrypt(value);
|
||||
this.setDataValue('email', encryptedValue.toString('hex'));
|
||||
}
|
||||
},
|
||||
get() {
|
||||
const value = this.getDataValue('email');
|
||||
if (value) {
|
||||
return decrypt(Buffer.from(value, 'hex'));
|
||||
}
|
||||
}
|
||||
},
|
||||
message: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
set(value) {
|
||||
if (value) {
|
||||
const encryptedValue = encrypt(value);
|
||||
this.setDataValue('message', encryptedValue.toString('hex'));
|
||||
}
|
||||
},
|
||||
get() {
|
||||
const value = this.getDataValue('message');
|
||||
if (value) {
|
||||
return decrypt(Buffer.from(value, 'hex'));
|
||||
}
|
||||
}
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
set(value) {
|
||||
if (value) {
|
||||
const encryptedValue = encrypt(value);
|
||||
this.setDataValue('name', encryptedValue.toString('hex'));
|
||||
}
|
||||
},
|
||||
get() {
|
||||
const value = this.getDataValue('name');
|
||||
if (value) {
|
||||
return decrypt(Buffer.from(value, 'hex'));
|
||||
}
|
||||
}
|
||||
},
|
||||
allowDataSave: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false
|
||||
},
|
||||
}, {
|
||||
tableName: 'contact_message',
|
||||
timestamps: true,
|
||||
schema: 'service',
|
||||
underscored: true
|
||||
});
|
||||
|
||||
export default ContactMessage;
|
||||
25
backend/models/type/interest.js
Normal file
25
backend/models/type/interest.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const Interest = sequelize.define('interest_type', {
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
allowed: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
},
|
||||
adultOnly: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true,
|
||||
}
|
||||
}, {
|
||||
tableName: 'interest',
|
||||
schema: 'type',
|
||||
underscored: true
|
||||
});
|
||||
|
||||
export default Interest;
|
||||
30
backend/models/type/interest_translation.js
Normal file
30
backend/models/type/interest_translation.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
import Interest from '../type/interest.js';
|
||||
|
||||
const interestTranslation = sequelize.define('interest_translation_type', {
|
||||
translation: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
language: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
interestsId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Interest,
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE'
|
||||
},
|
||||
}, {
|
||||
tableName: 'interest_translation',
|
||||
schema: 'type',
|
||||
underscored: true
|
||||
});
|
||||
|
||||
export default interestTranslation;
|
||||
Reference in New Issue
Block a user