feat: add service management module with CRUD operations

This commit is contained in:
nguyenvanbao
2026-02-03 16:20:07 +07:00
parent d1b931d547
commit 9dc02974a4
21 changed files with 3798 additions and 208 deletions

118
models/service.js Normal file
View File

@@ -0,0 +1,118 @@
const mongoose = require("mongoose");
// Define sub-schemas first
const authorSchema = new mongoose.Schema(
{
name: String,
type: String,
},
{ _id: false },
);
const clientReviewSchema = new mongoose.Schema(
{
id: String,
rating: Number,
content: String,
author: authorSchema,
icon: String,
},
{ _id: false },
);
const featureSchema = new mongoose.Schema(
{
title: String,
description: String,
},
{ _id: false },
);
const faqSchema = new mongoose.Schema(
{
id: String,
question: String,
answer: String,
isExpanded: { type: Boolean, default: false },
},
{ _id: false },
);
const serviceDetailsSchema = new mongoose.Schema(
{
title: String,
description: String,
mainImage: String,
overviewTitle: String,
overviewDescription: String,
additionalDescription: String,
keyFeaturesTitle: String,
keyFeaturesImage: String,
features: [featureSchema],
faqTitle: String,
faqImage: String,
faq: [faqSchema],
},
{ _id: false },
);
// Main service page schema
const serviceSchema = new mongoose.Schema(
{
pageTitle: String,
// Main services section
services: {
title: {
subTitle: String,
mainTitle: String,
},
items: [
{
slug: String,
name: String,
description: String,
image: String,
layout: String,
details: serviceDetailsSchema,
},
],
},
// Destination countries section
destinations: {
backgroundImage: String,
title: {
subTitle: String,
mainTitle: String,
},
},
// Visa types section
visas: {
items: [
{
id: String,
number: String,
name: String,
description: String,
buttonText: String,
buttonLink: String,
},
],
},
// Client reviews section
reviews: {
title: {
subTitle: String,
mainTitle: String,
},
thumb: String,
items: [clientReviewSchema],
},
},
{ timestamps: true },
);
module.exports = mongoose.model("Service", serviceSchema);