some fixes

This commit is contained in:
2025-10-22 21:22:44 +09:00
parent 46fad7ecc2
commit 6ff35e26f4
514 changed files with 156165 additions and 0 deletions

View File

@@ -0,0 +1,195 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Banner = sequelize.define('Banner', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false,
validate: {
notEmpty: true,
len: [1, 200]
}
},
subtitle: {
type: DataTypes.STRING,
allowNull: true,
validate: {
len: [0, 300]
}
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
buttonText: {
type: DataTypes.STRING,
allowNull: true,
validate: {
len: [0, 50]
}
},
buttonUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
image: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Banner background image URL'
},
mobileImage: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Mobile-optimized banner image URL'
},
position: {
type: DataTypes.ENUM('hero', 'secondary', 'footer'),
defaultValue: 'hero',
allowNull: false
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
comment: 'Display order (lower numbers appear first)'
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true,
allowNull: false
},
startDate: {
type: DataTypes.DATE,
allowNull: true,
comment: 'Banner start display date'
},
endDate: {
type: DataTypes.DATE,
allowNull: true,
comment: 'Banner end display date'
},
clickCount: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false
},
impressions: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false
},
targetAudience: {
type: DataTypes.ENUM('all', 'mobile', 'desktop'),
defaultValue: 'all',
allowNull: false
},
backgroundColor: {
type: DataTypes.STRING,
allowNull: true,
validate: {
is: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
},
comment: 'Hex color code for banner background'
},
textColor: {
type: DataTypes.STRING,
allowNull: true,
validate: {
is: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
},
comment: 'Hex color code for banner text'
},
animation: {
type: DataTypes.ENUM('none', 'fade', 'slide', 'zoom'),
defaultValue: 'none',
allowNull: false
},
metadata: {
type: DataTypes.JSONB,
allowNull: true,
defaultValue: {},
comment: 'Additional banner metadata and settings'
}
}, {
tableName: 'banners',
timestamps: true,
paranoid: true,
indexes: [
{
fields: ['isActive']
},
{
fields: ['position']
},
{
fields: ['order']
},
{
fields: ['startDate', 'endDate']
}
]
});
// Virtual field for checking if banner is currently active
Banner.prototype.isCurrentlyActive = function() {
if (!this.isActive) return false;
const now = new Date();
if (this.startDate && now < this.startDate) return false;
if (this.endDate && now > this.endDate) return false;
return true;
};
// Method to increment click count
Banner.prototype.recordClick = async function() {
this.clickCount += 1;
await this.save();
return this;
};
// Method to increment impressions
Banner.prototype.recordImpression = async function() {
this.impressions += 1;
await this.save();
return this;
};
// Static method to get active banners
Banner.getActiveBanners = async function(position = null) {
const whereClause = {
isActive: true
};
if (position) {
whereClause.position = position;
}
const now = new Date();
return await this.findAll({
where: {
...whereClause,
[require('sequelize').Op.or]: [
{ startDate: null },
{ startDate: { [require('sequelize').Op.lte]: now } }
],
[require('sequelize').Op.or]: [
{ endDate: null },
{ endDate: { [require('sequelize').Op.gte]: now } }
]
},
order: [['order', 'ASC'], ['createdAt', 'DESC']]
});
};
module.exports = Banner;

View File

@@ -0,0 +1,195 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Banner = sequelize.define('Banner', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false,
validate: {
notEmpty: true,
len: [1, 200]
}
},
subtitle: {
type: DataTypes.STRING,
allowNull: true,
validate: {
len: [0, 300]
}
},
description: {
type: DataTypes.TEXT,
allowNull: true
},
buttonText: {
type: DataTypes.STRING,
allowNull: true,
validate: {
len: [0, 50]
}
},
buttonUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
image: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Banner background image URL'
},
mobileImage: {
type: DataTypes.STRING,
allowNull: true,
comment: 'Mobile-optimized banner image URL'
},
position: {
type: DataTypes.ENUM('hero', 'secondary', 'footer'),
defaultValue: 'hero',
allowNull: false
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
comment: 'Display order (lower numbers appear first)'
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true,
allowNull: false
},
startDate: {
type: DataTypes.DATE,
allowNull: true,
comment: 'Banner start display date'
},
endDate: {
type: DataTypes.DATE,
allowNull: true,
comment: 'Banner end display date'
},
clickCount: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false
},
impressions: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false
},
targetAudience: {
type: DataTypes.ENUM('all', 'mobile', 'desktop'),
defaultValue: 'all',
allowNull: false
},
backgroundColor: {
type: DataTypes.STRING,
allowNull: true,
validate: {
is: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
},
comment: 'Hex color code for banner background'
},
textColor: {
type: DataTypes.STRING,
allowNull: true,
validate: {
is: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
},
comment: 'Hex color code for banner text'
},
animation: {
type: DataTypes.ENUM('none', 'fade', 'slide', 'zoom'),
defaultValue: 'none',
allowNull: false
},
metadata: {
type: DataTypes.JSONB,
allowNull: true,
defaultValue: {},
comment: 'Additional banner metadata and settings'
}
}, {
tableName: 'banners',
timestamps: true,
paranoid: true,
indexes: [
{
fields: ['isActive']
},
{
fields: ['position']
},
{
fields: ['order']
},
{
fields: ['startDate', 'endDate']
}
]
});
// Virtual field for checking if banner is currently active
Banner.prototype.isCurrentlyActive = function() {
if (!this.isActive) return false;
const now = new Date();
if (this.startDate && now < this.startDate) return false;
if (this.endDate && now > this.endDate) return false;
return true;
};
// Method to increment click count
Banner.prototype.recordClick = async function() {
this.clickCount += 1;
await this.save();
return this;
};
// Method to increment impressions
Banner.prototype.recordImpression = async function() {
this.impressions += 1;
await this.save();
return this;
};
// Static method to get active banners
Banner.getActiveBanners = async function(position = null) {
const whereClause = {
isActive: true
};
if (position) {
whereClause.position = position;
}
const now = new Date();
return await this.findAll({
where: {
...whereClause,
[require('sequelize').Op.or]: [
{ startDate: null },
{ startDate: { [require('sequelize').Op.lte]: now } }
],
[require('sequelize').Op.or]: [
{ endDate: null },
{ endDate: { [require('sequelize').Op.gte]: now } }
]
},
order: [['order', 'ASC'], ['createdAt', 'DESC']]
});
};
module.exports = Banner;

View File

@@ -0,0 +1,108 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Contact = sequelize.define('Contact', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('name', value.trim());
}
},
email: {
type: DataTypes.STRING,
allowNull: false,
validate: {
isEmail: true
},
set(value) {
this.setDataValue('email', value.toLowerCase().trim());
}
},
phone: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('phone', value ? value.trim() : null);
}
},
company: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('company', value ? value.trim() : null);
}
},
subject: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('subject', value.trim());
}
},
message: {
type: DataTypes.TEXT,
allowNull: false
},
serviceInterest: {
type: DataTypes.ENUM('web-development', 'mobile-app', 'ui-ux-design', 'branding', 'consulting', 'other'),
allowNull: true
},
budget: {
type: DataTypes.ENUM('under-1m', '1m-5m', '5m-10m', '10m-20m', '20m-50m', 'over-50m'),
allowNull: true
},
timeline: {
type: DataTypes.ENUM('asap', '1-month', '1-3-months', '3-6-months', 'flexible'),
allowNull: true
},
status: {
type: DataTypes.ENUM('new', 'in-progress', 'replied', 'closed'),
defaultValue: 'new'
},
priority: {
type: DataTypes.ENUM('low', 'medium', 'high', 'urgent'),
defaultValue: 'medium'
},
source: {
type: DataTypes.ENUM('website', 'telegram', 'email', 'phone', 'referral'),
defaultValue: 'website'
},
isRead: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
adminNotes: {
type: DataTypes.TEXT,
allowNull: true
},
ipAddress: {
type: DataTypes.STRING,
allowNull: true
},
userAgent: {
type: DataTypes.TEXT,
allowNull: true
}
}, {
tableName: 'contacts',
timestamps: true,
indexes: [
{
fields: ['status', 'createdAt']
},
{
fields: ['isRead', 'createdAt']
},
{
fields: ['email']
}
]
});
module.exports = Contact;

View File

@@ -0,0 +1,108 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Contact = sequelize.define('Contact', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('name', value.trim());
}
},
email: {
type: DataTypes.STRING,
allowNull: false,
validate: {
isEmail: true
},
set(value) {
this.setDataValue('email', value.toLowerCase().trim());
}
},
phone: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('phone', value ? value.trim() : null);
}
},
company: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('company', value ? value.trim() : null);
}
},
subject: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
this.setDataValue('subject', value.trim());
}
},
message: {
type: DataTypes.TEXT,
allowNull: false
},
serviceInterest: {
type: DataTypes.ENUM('web-development', 'mobile-app', 'ui-ux-design', 'branding', 'consulting', 'other'),
allowNull: true
},
budget: {
type: DataTypes.ENUM('under-1m', '1m-5m', '5m-10m', '10m-20m', '20m-50m', 'over-50m'),
allowNull: true
},
timeline: {
type: DataTypes.ENUM('asap', '1-month', '1-3-months', '3-6-months', 'flexible'),
allowNull: true
},
status: {
type: DataTypes.ENUM('new', 'in-progress', 'replied', 'closed'),
defaultValue: 'new'
},
priority: {
type: DataTypes.ENUM('low', 'medium', 'high', 'urgent'),
defaultValue: 'medium'
},
source: {
type: DataTypes.ENUM('website', 'telegram', 'email', 'phone', 'referral'),
defaultValue: 'website'
},
isRead: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
adminNotes: {
type: DataTypes.TEXT,
allowNull: true
},
ipAddress: {
type: DataTypes.STRING,
allowNull: true
},
userAgent: {
type: DataTypes.TEXT,
allowNull: true
}
}, {
tableName: 'contacts',
timestamps: true,
indexes: [
{
fields: ['status', 'createdAt']
},
{
fields: ['isRead', 'createdAt']
},
{
fields: ['email']
}
]
});
module.exports = Contact;

View File

@@ -0,0 +1,121 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Portfolio = sequelize.define('Portfolio', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 255]
},
set(value) {
this.setDataValue('title', value.trim());
}
},
description: {
type: DataTypes.TEXT,
allowNull: false
},
shortDescription: {
type: DataTypes.STRING(200),
allowNull: false
},
category: {
type: DataTypes.ENUM('web-development', 'mobile-app', 'ui-ux-design', 'branding', 'e-commerce', 'other'),
allowNull: false
},
technologies: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: []
},
images: {
type: DataTypes.JSONB,
defaultValue: []
},
clientName: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('clientName', value ? value.trim() : null);
}
},
projectUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
githubUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
status: {
type: DataTypes.ENUM('completed', 'in-progress', 'planning'),
defaultValue: 'completed'
},
featured: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
publishedAt: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
},
completedAt: {
type: DataTypes.DATE,
allowNull: true
},
isPublished: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
viewCount: {
type: DataTypes.INTEGER,
defaultValue: 0
},
likes: {
type: DataTypes.INTEGER,
defaultValue: 0
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0
},
seo: {
type: DataTypes.JSONB,
defaultValue: {}
}
}, {
tableName: 'portfolios',
timestamps: true,
indexes: [
{
fields: ['category', 'publishedAt']
},
{
fields: ['featured', 'publishedAt']
},
{
type: 'gin',
fields: ['technologies']
}
]
});
// Virtual for primary image
Portfolio.prototype.getPrimaryImage = function() {
if (!this.images || this.images.length === 0) return null;
const primary = this.images.find(img => img.isPrimary);
return primary || this.images[0];
};
module.exports = Portfolio;

View File

@@ -0,0 +1,121 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Portfolio = sequelize.define('Portfolio', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
title: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 255]
},
set(value) {
this.setDataValue('title', value.trim());
}
},
description: {
type: DataTypes.TEXT,
allowNull: false
},
shortDescription: {
type: DataTypes.STRING(200),
allowNull: false
},
category: {
type: DataTypes.ENUM('web-development', 'mobile-app', 'ui-ux-design', 'branding', 'e-commerce', 'other'),
allowNull: false
},
technologies: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: []
},
images: {
type: DataTypes.JSONB,
defaultValue: []
},
clientName: {
type: DataTypes.STRING,
allowNull: true,
set(value) {
this.setDataValue('clientName', value ? value.trim() : null);
}
},
projectUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
githubUrl: {
type: DataTypes.STRING,
allowNull: true,
validate: {
isUrl: true
}
},
status: {
type: DataTypes.ENUM('completed', 'in-progress', 'planning'),
defaultValue: 'completed'
},
featured: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
publishedAt: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
},
completedAt: {
type: DataTypes.DATE,
allowNull: true
},
isPublished: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
viewCount: {
type: DataTypes.INTEGER,
defaultValue: 0
},
likes: {
type: DataTypes.INTEGER,
defaultValue: 0
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0
},
seo: {
type: DataTypes.JSONB,
defaultValue: {}
}
}, {
tableName: 'portfolios',
timestamps: true,
indexes: [
{
fields: ['category', 'publishedAt']
},
{
fields: ['featured', 'publishedAt']
},
{
type: 'gin',
fields: ['technologies']
}
]
});
// Virtual for primary image
Portfolio.prototype.getPrimaryImage = function() {
if (!this.images || this.images.length === 0) return null;
const primary = this.images.find(img => img.isPrimary);
return primary || this.images[0];
};
module.exports = Portfolio;

View File

@@ -0,0 +1,96 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Service = sequelize.define('Service', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 255]
},
set(value) {
this.setDataValue('name', value.trim());
}
},
description: {
type: DataTypes.TEXT,
allowNull: false
},
shortDescription: {
type: DataTypes.STRING(150),
allowNull: false
},
icon: {
type: DataTypes.STRING,
allowNull: false
},
category: {
type: DataTypes.ENUM('development', 'design', 'consulting', 'marketing', 'maintenance'),
allowNull: false
},
features: {
type: DataTypes.JSONB,
defaultValue: []
},
pricing: {
type: DataTypes.JSONB,
allowNull: false,
validate: {
isValidPricing(value) {
if (!value.basePrice || value.basePrice < 0) {
throw new Error('Base price must be a positive number');
}
}
}
},
estimatedTime: {
type: DataTypes.JSONB,
allowNull: false,
validate: {
isValidTime(value) {
if (!value.min || !value.max || value.min > value.max) {
throw new Error('Invalid estimated time range');
}
}
}
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
featured: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0
},
tags: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: []
},
seo: {
type: DataTypes.JSONB,
defaultValue: {}
}
}, {
tableName: 'services',
timestamps: true,
indexes: [
{
fields: ['category', 'featured', 'order']
},
{
type: 'gin',
fields: ['tags']
}
]
});
module.exports = Service;

View File

@@ -0,0 +1,96 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Service = sequelize.define('Service', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
name: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 255]
},
set(value) {
this.setDataValue('name', value.trim());
}
},
description: {
type: DataTypes.TEXT,
allowNull: false
},
shortDescription: {
type: DataTypes.STRING(150),
allowNull: false
},
icon: {
type: DataTypes.STRING,
allowNull: false
},
category: {
type: DataTypes.ENUM('development', 'design', 'consulting', 'marketing', 'maintenance'),
allowNull: false
},
features: {
type: DataTypes.JSONB,
defaultValue: []
},
pricing: {
type: DataTypes.JSONB,
allowNull: false,
validate: {
isValidPricing(value) {
if (!value.basePrice || value.basePrice < 0) {
throw new Error('Base price must be a positive number');
}
}
}
},
estimatedTime: {
type: DataTypes.JSONB,
allowNull: false,
validate: {
isValidTime(value) {
if (!value.min || !value.max || value.min > value.max) {
throw new Error('Invalid estimated time range');
}
}
}
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
featured: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
order: {
type: DataTypes.INTEGER,
defaultValue: 0
},
tags: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: []
},
seo: {
type: DataTypes.JSONB,
defaultValue: {}
}
}, {
tableName: 'services',
timestamps: true,
indexes: [
{
fields: ['category', 'featured', 'order']
},
{
type: 'gin',
fields: ['tags']
}
]
});
module.exports = Service;

View File

@@ -0,0 +1,82 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const SiteSettings = sequelize.define('SiteSettings', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
siteName: {
type: DataTypes.STRING,
defaultValue: 'SmartSolTech'
},
siteDescription: {
type: DataTypes.TEXT,
defaultValue: 'Innovative technology solutions for modern businesses'
},
logo: {
type: DataTypes.STRING,
defaultValue: '/images/logo.png'
},
favicon: {
type: DataTypes.STRING,
defaultValue: '/images/favicon.ico'
},
contact: {
type: DataTypes.JSONB,
defaultValue: {
email: 'info@smartsoltech.kr',
phone: '+82-10-0000-0000',
address: 'Seoul, South Korea'
}
},
social: {
type: DataTypes.JSONB,
defaultValue: {}
},
telegram: {
type: DataTypes.JSONB,
defaultValue: {
isEnabled: false
}
},
seo: {
type: DataTypes.JSONB,
defaultValue: {
metaTitle: 'SmartSolTech - Technology Solutions',
metaDescription: 'Professional web development, mobile apps, and digital solutions in Korea',
keywords: 'web development, mobile apps, UI/UX design, Korea, technology'
}
},
hero: {
type: DataTypes.JSONB,
defaultValue: {
title: 'Smart Technology Solutions',
subtitle: 'We create innovative digital experiences that drive business growth',
backgroundImage: '/images/hero-bg.jpg',
ctaText: 'Get Started',
ctaLink: '#contact'
}
},
about: {
type: DataTypes.JSONB,
defaultValue: {
title: 'About SmartSolTech',
description: 'We are a team of passionate developers and designers creating cutting-edge technology solutions.',
image: '/images/about.jpg'
}
},
maintenance: {
type: DataTypes.JSONB,
defaultValue: {
isEnabled: false,
message: 'We are currently performing maintenance. Please check back soon.'
}
}
}, {
tableName: 'site_settings',
timestamps: true
});
module.exports = SiteSettings;

View File

@@ -0,0 +1,82 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const SiteSettings = sequelize.define('SiteSettings', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
siteName: {
type: DataTypes.STRING,
defaultValue: 'SmartSolTech'
},
siteDescription: {
type: DataTypes.TEXT,
defaultValue: 'Innovative technology solutions for modern businesses'
},
logo: {
type: DataTypes.STRING,
defaultValue: '/images/logo.png'
},
favicon: {
type: DataTypes.STRING,
defaultValue: '/images/favicon.ico'
},
contact: {
type: DataTypes.JSONB,
defaultValue: {
email: 'info@smartsoltech.kr',
phone: '+82-10-0000-0000',
address: 'Seoul, South Korea'
}
},
social: {
type: DataTypes.JSONB,
defaultValue: {}
},
telegram: {
type: DataTypes.JSONB,
defaultValue: {
isEnabled: false
}
},
seo: {
type: DataTypes.JSONB,
defaultValue: {
metaTitle: 'SmartSolTech - Technology Solutions',
metaDescription: 'Professional web development, mobile apps, and digital solutions in Korea',
keywords: 'web development, mobile apps, UI/UX design, Korea, technology'
}
},
hero: {
type: DataTypes.JSONB,
defaultValue: {
title: 'Smart Technology Solutions',
subtitle: 'We create innovative digital experiences that drive business growth',
backgroundImage: '/images/hero-bg.jpg',
ctaText: 'Get Started',
ctaLink: '#contact'
}
},
about: {
type: DataTypes.JSONB,
defaultValue: {
title: 'About SmartSolTech',
description: 'We are a team of passionate developers and designers creating cutting-edge technology solutions.',
image: '/images/about.jpg'
}
},
maintenance: {
type: DataTypes.JSONB,
defaultValue: {
isEnabled: false,
message: 'We are currently performing maintenance. Please check back soon.'
}
}
}, {
tableName: 'site_settings',
timestamps: true
});
module.exports = SiteSettings;

View File

@@ -0,0 +1,78 @@
const { DataTypes } = require('sequelize');
const bcrypt = require('bcryptjs');
const { sequelize } = require('../config/database');
const User = sequelize.define('User', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true
},
set(value) {
this.setDataValue('email', value.toLowerCase().trim());
}
},
password: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [6, 255]
}
},
name: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 100]
},
set(value) {
this.setDataValue('name', value.trim());
}
},
role: {
type: DataTypes.ENUM('admin', 'moderator'),
defaultValue: 'admin'
},
avatar: {
type: DataTypes.STRING,
allowNull: true
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
lastLogin: {
type: DataTypes.DATE,
allowNull: true
}
}, {
tableName: 'users',
timestamps: true,
hooks: {
beforeSave: async (user) => {
if (user.changed('password')) {
const salt = await bcrypt.genSalt(12);
user.password = await bcrypt.hash(user.password, salt);
}
}
}
});
// Instance methods
User.prototype.comparePassword = async function(candidatePassword) {
return bcrypt.compare(candidatePassword, this.password);
};
User.prototype.updateLastLogin = function() {
this.lastLogin = new Date();
return this.save();
};
module.exports = User;

View File

@@ -0,0 +1,78 @@
const { DataTypes } = require('sequelize');
const bcrypt = require('bcryptjs');
const { sequelize } = require('../config/database');
const User = sequelize.define('User', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true
},
set(value) {
this.setDataValue('email', value.toLowerCase().trim());
}
},
password: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [6, 255]
}
},
name: {
type: DataTypes.STRING,
allowNull: false,
validate: {
len: [1, 100]
},
set(value) {
this.setDataValue('name', value.trim());
}
},
role: {
type: DataTypes.ENUM('admin', 'moderator'),
defaultValue: 'admin'
},
avatar: {
type: DataTypes.STRING,
allowNull: true
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
lastLogin: {
type: DataTypes.DATE,
allowNull: true
}
}, {
tableName: 'users',
timestamps: true,
hooks: {
beforeSave: async (user) => {
if (user.changed('password')) {
const salt = await bcrypt.genSalt(12);
user.password = await bcrypt.hash(user.password, salt);
}
}
}
});
// Instance methods
User.prototype.comparePassword = async function(candidatePassword) {
return bcrypt.compare(candidatePassword, this.password);
};
User.prototype.updateLastLogin = function() {
this.lastLogin = new Date();
return this.save();
};
module.exports = User;

View File

@@ -0,0 +1,23 @@
const { sequelize } = require('../config/database');
// Import models
const User = require('./User');
const Portfolio = require('./Portfolio');
const Service = require('./Service');
const Contact = require('./Contact');
const SiteSettings = require('./SiteSettings');
// Define associations here if needed
// For example:
// Service.belongsToMany(Portfolio, { through: 'ServicePortfolio' });
// Portfolio.belongsToMany(Service, { through: 'ServicePortfolio' });
// Export models and sequelize instance
module.exports = {
sequelize,
User,
Portfolio,
Service,
Contact,
SiteSettings
};

View File

@@ -0,0 +1,23 @@
const { sequelize } = require('../config/database');
// Import models
const User = require('./User');
const Portfolio = require('./Portfolio');
const Service = require('./Service');
const Contact = require('./Contact');
const SiteSettings = require('./SiteSettings');
// Define associations here if needed
// For example:
// Service.belongsToMany(Portfolio, { through: 'ServicePortfolio' });
// Portfolio.belongsToMany(Service, { through: 'ServicePortfolio' });
// Export models and sequelize instance
module.exports = {
sequelize,
User,
Portfolio,
Service,
Contact,
SiteSettings
};

View File

@@ -0,0 +1,25 @@
const { sequelize } = require('../config/database');
// Import models
const User = require('./User');
const Portfolio = require('./Portfolio');
const Service = require('./Service');
const Contact = require('./Contact');
const SiteSettings = require('./SiteSettings');
const Banner = require('./Banner');
// Define associations here if needed
// For example:
// Service.belongsToMany(Portfolio, { through: 'ServicePortfolio' });
// Portfolio.belongsToMany(Service, { through: 'ServicePortfolio' });
// Export models and sequelize instance
module.exports = {
sequelize,
User,
Portfolio,
Service,
Contact,
SiteSettings,
Banner
};

View File

@@ -0,0 +1,25 @@
const { sequelize } = require('../config/database');
// Import models
const User = require('./User');
const Portfolio = require('./Portfolio');
const Service = require('./Service');
const Contact = require('./Contact');
const SiteSettings = require('./SiteSettings');
const Banner = require('./Banner');
// Define associations here if needed
// For example:
// Service.belongsToMany(Portfolio, { through: 'ServicePortfolio' });
// Portfolio.belongsToMany(Service, { through: 'ServicePortfolio' });
// Export models and sequelize instance
module.exports = {
sequelize,
User,
Portfolio,
Service,
Contact,
SiteSettings,
Banner
};