routing improved, settings initialized

This commit is contained in:
Torsten Schulz
2024-07-21 18:47:45 +02:00
parent 12d66d6f9c
commit cd0699f3fd
23 changed files with 476 additions and 69 deletions

View File

@@ -28,9 +28,6 @@ const User = sequelize.define('user', {
password: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('password', bcrypt.hashSync(value, 10));
}
},
registrationDate: {
type: DataTypes.DATE,

View File

@@ -0,0 +1,32 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
import User from './user.js';
import UserRightType from '../type/user_right.js';
const UserRight = sequelize.define('user_right', {
userId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: User,
key: 'id'
}
},
rightTypeId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: UserRightType,
key: 'id'
}
},
}, {
tableName: 'user_right',
schema: 'community',
underscored: true,
});
UserRight.belongsTo(User, { foreignKey: 'userId' });
UserRight.belongsTo(UserRightType, { foreignKey: 'rightTypeId', as: 'rightType' });
export default UserRight;

View File

@@ -2,12 +2,18 @@ import User from './community/user.js';
import UserParam from './community/user_param.js';
import UserParamType from './type/user_param.js';
import Login from './logs/login.js';
import UserRightType from './type/user_right.js';
import UserRight from './community/user_right.js';
import SettingsType from './type/settings_type.js';
const models = {
User,
UserParam,
UserParamType,
Login
Login,
UserRightType,
UserRight,
SettingsType,
};
export default models;

View File

@@ -0,0 +1,15 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
const SettingsType = sequelize.define('settings_type', {
name: {
type: DataTypes.STRING,
allowNull: false
},
}, {
tableName: 'settings',
schema: 'type',
underscored: true
});
export default SettingsType;

View File

@@ -1,15 +1,39 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
import SettingsType from './settings_type.js';
const UserParamType = sequelize.define('user_param_type', {
description: {
type: DataTypes.STRING,
allowNull: false
}
},
minAge: {
type: DataTypes.INTEGER,
allowNull: true
},
gender: {
type: DataTypes.STRING,
allowNull: true
},
datatype: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'string'
},
settingsTypeId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: SettingsType,
key: 'id'
}
},
}, {
tableName: 'user_param',
schema: 'type',
underscored: true
});
UserParamType.belongsTo(SettingsType, { foreignKey: 'settingsTypeId' });
export default UserParamType;

View File

@@ -0,0 +1,15 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
const UserRightType = sequelize.define('user_right_type', {
title: {
type: DataTypes.STRING,
allowNull: false
}
}, {
tableName: 'user_right',
schema: 'type',
underscored: true
});
export default UserRightType;