first initialization gallery
This commit is contained in:
@@ -12,6 +12,11 @@ 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 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';
|
||||
|
||||
export default function setupAssociations() {
|
||||
SettingsType.hasMany(UserParamType, { foreignKey: 'settingsId', as: 'user_param_types' });
|
||||
@@ -57,4 +62,37 @@ export default function setupAssociations() {
|
||||
|
||||
Image.belongsTo(User, { foreignKey: 'userId' });
|
||||
User.hasMany(Image, { foreignKey: 'userId' });
|
||||
|
||||
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'
|
||||
});
|
||||
|
||||
Folder.belongsToMany(ImageVisibilityUser, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'folderId',
|
||||
otherKey: 'visibilityUserId'
|
||||
});
|
||||
ImageVisibilityUser.belongsToMany(Folder, {
|
||||
through: FolderVisibilityUser,
|
||||
foreignKey: 'visibilityUserId',
|
||||
otherKey: 'folderId'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,14 +23,6 @@ const Folder = sequelize.define('folder', {
|
||||
key: 'id',
|
||||
},
|
||||
},
|
||||
visibilityType: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: UserParamVisibilityType,
|
||||
key: 'id',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
tableName: 'folder',
|
||||
schema: 'community',
|
||||
|
||||
37
backend/models/community/folder_image_visibility.js
Normal file
37
backend/models/community/folder_image_visibility.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const FolderImageVisibility = sequelize.define('folder_image_visibility', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
folderId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'folder',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
visibilityTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: {
|
||||
schema: 'type',
|
||||
tableName: 'image_visibility_type'
|
||||
},
|
||||
key: 'id'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
tableName: 'folder_image_visibility',
|
||||
schema: 'community',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default FolderImageVisibility;
|
||||
34
backend/models/community/folder_visibility_user.js
Normal file
34
backend/models/community/folder_visibility_user.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const FolderVisibilityUser = sequelize.define('folder_visibility_user', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
folderId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'folder',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
visibilityUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'image_visibility_user',
|
||||
key: 'id'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
tableName: 'folder_visibility_user',
|
||||
schema: 'community',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default FolderVisibilityUser;
|
||||
@@ -36,14 +36,6 @@ const Image = sequelize.define('image', {
|
||||
key: 'id',
|
||||
},
|
||||
},
|
||||
visibilityType: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: UserParamVisibilityType,
|
||||
key: 'id',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
tableName: 'image',
|
||||
schema: 'community',
|
||||
|
||||
37
backend/models/community/image_image_visibility.js
Normal file
37
backend/models/community/image_image_visibility.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const ImageImageVisibility = sequelize.define('image_image_visibility', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
imageId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'image',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
visibilityTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: {
|
||||
schema: 'type',
|
||||
tableName: 'image_visibility_type'
|
||||
},
|
||||
key: 'id'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
tableName: 'image_image_visibility',
|
||||
schema: 'community',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default ImageImageVisibility;
|
||||
26
backend/models/community/image_visibility_user.js
Normal file
26
backend/models/community/image_visibility_user.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const ImageVisibilityUser = sequelize.define('image_visibility_user', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
image_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
user_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
tableName: 'image_visibility_user',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
schema: 'community'
|
||||
});
|
||||
|
||||
export default ImageVisibilityUser;
|
||||
@@ -14,6 +14,11 @@ 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 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';
|
||||
|
||||
const models = {
|
||||
SettingsType,
|
||||
@@ -25,13 +30,18 @@ const models = {
|
||||
Login,
|
||||
UserRight,
|
||||
InterestType,
|
||||
InterestTranslationType,
|
||||
InterestTranslationType,
|
||||
Interest,
|
||||
ContactMessage,
|
||||
UserParamVisibilityType,
|
||||
UserParamVisibility,
|
||||
Folder,
|
||||
Image,
|
||||
ImageVisibilityType,
|
||||
ImageVisibilityUser,
|
||||
FolderImageVisibility,
|
||||
ImageImageVisibility,
|
||||
FolderVisibilityUser,
|
||||
};
|
||||
|
||||
export default models;
|
||||
|
||||
22
backend/models/type/image_visibility.js
Normal file
22
backend/models/type/image_visibility.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { sequelize } from '../../utils/sequelize.js';
|
||||
import { DataTypes } from 'sequelize';
|
||||
|
||||
const ImageVisibilityType = sequelize.define('image_visibility_type', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
tableName: 'image_visibility_type',
|
||||
schema: 'type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
});
|
||||
|
||||
export default ImageVisibilityType;
|
||||
Reference in New Issue
Block a user