628 lines
20 KiB
TypeScript
628 lines
20 KiB
TypeScript
import { Injectable, OnModuleInit, Logger } from '@nestjs/common';
|
|
import { Prisma } from '@prisma/client';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
import { SmsService, SmsLogQuery } from '../common/services/sms.service';
|
|
import { DEFAULT_UI_TEXTS } from './default-ui-texts';
|
|
|
|
export class ScientificTermData {
|
|
term?: string;
|
|
definition?: string;
|
|
wikiId?: string;
|
|
}
|
|
|
|
export const CANONICAL_ALIASES: Record<string, string[]> = {
|
|
// Brand & Logo
|
|
BRAND_LOGO_TEXT_EN: ['site_logo_text_en'],
|
|
site_logo_text_en: ['BRAND_LOGO_TEXT_EN'],
|
|
BRAND_LOGO_TEXT_FA: ['site_logo_text_fa', 'brand_name_fa'],
|
|
site_logo_text_fa: ['BRAND_LOGO_TEXT_FA', 'brand_name_fa'],
|
|
brand_name_fa: ['BRAND_LOGO_TEXT_FA', 'site_logo_text_fa'],
|
|
BRAND_LOGO_SUBTITLE: ['site_logo_subtitle', 'brand_subtitle'],
|
|
site_logo_subtitle: ['BRAND_LOGO_SUBTITLE', 'brand_subtitle'],
|
|
brand_subtitle: ['BRAND_LOGO_SUBTITLE', 'site_logo_subtitle'],
|
|
BRAND_LOGO_URL: ['site_logo', 'brand_logo_url'],
|
|
site_logo: ['BRAND_LOGO_URL', 'brand_logo_url'],
|
|
brand_logo_url: ['BRAND_LOGO_URL', 'site_logo'],
|
|
|
|
// Contact Info
|
|
CONTACT_PHONE: [
|
|
'contact_phone',
|
|
'maintenance_contact_phone',
|
|
'footer_phone',
|
|
'supportPhone',
|
|
],
|
|
contact_phone: [
|
|
'CONTACT_PHONE',
|
|
'maintenance_contact_phone',
|
|
'footer_phone',
|
|
'supportPhone',
|
|
],
|
|
maintenance_contact_phone: [
|
|
'CONTACT_PHONE',
|
|
'contact_phone',
|
|
'footer_phone',
|
|
'supportPhone',
|
|
],
|
|
footer_phone: [
|
|
'CONTACT_PHONE',
|
|
'contact_phone',
|
|
'maintenance_contact_phone',
|
|
'supportPhone',
|
|
],
|
|
supportPhone: [
|
|
'CONTACT_PHONE',
|
|
'contact_phone',
|
|
'maintenance_contact_phone',
|
|
'footer_phone',
|
|
],
|
|
|
|
CONTACT_PHONE_LINK: ['contact_phone_link', 'maintenance_contact_phone_link'],
|
|
contact_phone_link: ['CONTACT_PHONE_LINK', 'maintenance_contact_phone_link'],
|
|
maintenance_contact_phone_link: ['CONTACT_PHONE_LINK', 'contact_phone_link'],
|
|
|
|
CONTACT_EMAIL: ['contact_email', 'footer_email'],
|
|
contact_email: ['CONTACT_EMAIL', 'footer_email'],
|
|
footer_email: ['CONTACT_EMAIL', 'contact_email'],
|
|
|
|
CONTACT_ADDRESS: ['contact_address', 'footer_address'],
|
|
contact_address: ['CONTACT_ADDRESS', 'footer_address'],
|
|
footer_address: ['CONTACT_ADDRESS', 'contact_address'],
|
|
|
|
SOCIAL_WHATSAPP: ['contact_whatsapp'],
|
|
contact_whatsapp: ['SOCIAL_WHATSAPP'],
|
|
SOCIAL_TELEGRAM: ['contact_telegram'],
|
|
contact_telegram: ['SOCIAL_TELEGRAM'],
|
|
SOCIAL_INSTAGRAM: ['contact_instagram'],
|
|
contact_instagram: ['SOCIAL_INSTAGRAM'],
|
|
|
|
// Financial & Shipping
|
|
SHIPPING_FEE: ['shipping_fee', 'standardShippingFee'],
|
|
shipping_fee: ['SHIPPING_FEE', 'standardShippingFee'],
|
|
standardShippingFee: ['SHIPPING_FEE', 'shipping_fee'],
|
|
|
|
MIN_ORDER_AMOUNT: ['min_order_amount', 'minOrderAmount'],
|
|
min_order_amount: ['MIN_ORDER_AMOUNT', 'minOrderAmount'],
|
|
minOrderAmount: ['MIN_ORDER_AMOUNT', 'min_order_amount'],
|
|
|
|
FREE_SHIPPING_THRESHOLD: ['free_shipping_threshold', 'freeShippingThreshold'],
|
|
free_shipping_threshold: ['FREE_SHIPPING_THRESHOLD', 'freeShippingThreshold'],
|
|
freeShippingThreshold: ['FREE_SHIPPING_THRESHOLD', 'free_shipping_threshold'],
|
|
|
|
B2B_DISCOUNT_PERCENT: ['b2b_discount_percent', 'b2bDiscountPercent'],
|
|
b2b_discount_percent: ['B2B_DISCOUNT_PERCENT', 'b2bDiscountPercent'],
|
|
b2bDiscountPercent: ['B2B_DISCOUNT_PERCENT', 'b2b_discount_percent'],
|
|
|
|
TAX_PERCENTAGE: ['tax_percentage', 'taxPercentage'],
|
|
tax_percentage: ['TAX_PERCENTAGE', 'taxPercentage'],
|
|
taxPercentage: ['TAX_PERCENTAGE', 'tax_percentage'],
|
|
|
|
CHARITY_ROUND_STEP: ['charity_round_step', 'charityRoundStep'],
|
|
charity_round_step: ['CHARITY_ROUND_STEP', 'charityRoundStep'],
|
|
charityRoundStep: ['CHARITY_ROUND_STEP', 'charity_round_step'],
|
|
|
|
// Zibal Gateway & Tokens
|
|
ZIBAL_EBANK_TOKEN: [
|
|
'zibal_ebank_token',
|
|
'ZIBAL_API_KEY',
|
|
'zibal_api_key',
|
|
'ZIBAL_TOKEN',
|
|
'zibal_token',
|
|
],
|
|
zibal_ebank_token: [
|
|
'ZIBAL_EBANK_TOKEN',
|
|
'ZIBAL_API_KEY',
|
|
'zibal_api_key',
|
|
'ZIBAL_TOKEN',
|
|
'zibal_token',
|
|
],
|
|
ZIBAL_API_KEY: [
|
|
'ZIBAL_EBANK_TOKEN',
|
|
'zibal_ebank_token',
|
|
'zibal_api_key',
|
|
'ZIBAL_TOKEN',
|
|
'zibal_token',
|
|
],
|
|
zibal_api_key: [
|
|
'ZIBAL_EBANK_TOKEN',
|
|
'zibal_ebank_token',
|
|
'ZIBAL_API_KEY',
|
|
'ZIBAL_TOKEN',
|
|
'zibal_token',
|
|
],
|
|
ZIBAL_MERCHANT: ['zibal_merchant', 'merchantId', 'merchant'],
|
|
zibal_merchant: ['ZIBAL_MERCHANT', 'merchantId', 'merchant'],
|
|
ZIBAL_EBANK_ACCOUNT_ID: ['zibal_ebank_account_id', 'accountId'],
|
|
zibal_ebank_account_id: ['ZIBAL_EBANK_ACCOUNT_ID', 'accountId'],
|
|
|
|
// Modes
|
|
MAINTENANCE_MODE: ['maintenance_mode'],
|
|
maintenance_mode: ['MAINTENANCE_MODE'],
|
|
CATALOG_ONLY_MODE: ['catalog_mode'],
|
|
catalog_mode: ['CATALOG_ONLY_MODE'],
|
|
};
|
|
|
|
@Injectable()
|
|
export class SettingsService implements OnModuleInit {
|
|
private readonly logger = new Logger(SettingsService.name);
|
|
|
|
constructor(
|
|
private prisma: PrismaService,
|
|
private smsService: SmsService,
|
|
) {}
|
|
|
|
async onModuleInit() {
|
|
await this.seedDefaultUiTexts();
|
|
}
|
|
|
|
async seedDefaultUiTexts() {
|
|
try {
|
|
const existing = await this.prisma.uiText.findMany({
|
|
select: { key: true },
|
|
});
|
|
const existingKeys = new Set(existing.map((e) => e.key));
|
|
|
|
const missingEntries = Object.entries(DEFAULT_UI_TEXTS).filter(
|
|
([key]) => !existingKeys.has(key),
|
|
);
|
|
|
|
if (missingEntries.length > 0) {
|
|
await this.prisma.uiText.createMany({
|
|
data: missingEntries.map(([key, value]) => ({ key, value })),
|
|
skipDuplicates: true,
|
|
});
|
|
this.logger.log(
|
|
`[SettingsService] Auto-seeded ${missingEntries.length} default UI texts.`,
|
|
);
|
|
}
|
|
} catch (err: any) {
|
|
this.logger.warn(
|
|
`[SettingsService] Failed to auto-seed UI texts: ${err?.message || err}`,
|
|
);
|
|
}
|
|
}
|
|
|
|
async getUiTexts() {
|
|
// Ensure default texts exist
|
|
await this.seedDefaultUiTexts();
|
|
|
|
const [uiTexts, settings] = await Promise.all([
|
|
this.prisma.uiText.findMany(),
|
|
this.prisma.setting.findMany(),
|
|
]);
|
|
|
|
const mergedMap = new Map<string, string>();
|
|
|
|
// 1. Add all from uiTexts
|
|
uiTexts.forEach((u) => {
|
|
mergedMap.set(u.key, u.value);
|
|
});
|
|
|
|
// 2. Add from settings and unpack object keys
|
|
settings.forEach((s) => {
|
|
const valStr =
|
|
typeof s.value === 'string' ? s.value : JSON.stringify(s.value);
|
|
mergedMap.set(s.key, valStr);
|
|
|
|
if (
|
|
typeof s.value === 'object' &&
|
|
s.value !== null &&
|
|
!Array.isArray(s.value)
|
|
) {
|
|
Object.entries(s.value as Record<string, any>).forEach(([k, v]) => {
|
|
mergedMap.set(k, String(v));
|
|
});
|
|
}
|
|
});
|
|
|
|
// If b2bRegistrationOpen is set, sync b2b_enabled
|
|
if (mergedMap.has('b2bRegistrationOpen')) {
|
|
const val = mergedMap.get('b2bRegistrationOpen')!;
|
|
mergedMap.set('b2b_enabled', val);
|
|
}
|
|
|
|
return Array.from(mergedMap.entries()).map(([key, value]) => ({
|
|
key,
|
|
value,
|
|
}));
|
|
}
|
|
|
|
async updateUiText(key: string, value: string) {
|
|
const strVal = String(value ?? '');
|
|
const allKeysToUpdate = new Set<string>([key]);
|
|
const aliases = CANONICAL_ALIASES[key] || [];
|
|
aliases.forEach((a) => allKeysToUpdate.add(a));
|
|
|
|
for (const k of allKeysToUpdate) {
|
|
try {
|
|
await this.prisma.setting.upsert({
|
|
where: { key: k },
|
|
update: { value: strVal },
|
|
create: { key: k, value: strVal, category: 'general' },
|
|
});
|
|
} catch (e) {
|
|
this.logger.warn(`Failed to sync setting key ${k}: ${e}`);
|
|
}
|
|
|
|
await this.prisma.uiText.upsert({
|
|
where: { key: k },
|
|
update: { value: strVal },
|
|
create: { key: k, value: strVal },
|
|
});
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
key,
|
|
value: strVal,
|
|
syncedKeys: Array.from(allKeysToUpdate),
|
|
};
|
|
}
|
|
|
|
async updateBulkUiTexts(texts: Record<string, string>) {
|
|
if (!texts || typeof texts !== 'object') return { success: true };
|
|
const entries = Object.entries(texts);
|
|
for (const [key, value] of entries) {
|
|
await this.updateUiText(key, String(value ?? ''));
|
|
}
|
|
return { success: true, count: entries.length };
|
|
}
|
|
|
|
async getFinancialSettings() {
|
|
const texts = await this.getUiTexts();
|
|
const map = new Map<string, string>();
|
|
texts.forEach((t) => map.set(t.key, t.value));
|
|
|
|
const standardShippingFee = Number(
|
|
map.get('SHIPPING_FEE') ||
|
|
map.get('shipping_fee') ||
|
|
map.get('standardShippingFee') ||
|
|
'0',
|
|
);
|
|
const minOrderAmount = Number(
|
|
map.get('MIN_ORDER_AMOUNT') ||
|
|
map.get('min_order_amount') ||
|
|
map.get('minOrderAmount') ||
|
|
'0',
|
|
);
|
|
const freeShippingThreshold = Number(
|
|
map.get('FREE_SHIPPING_THRESHOLD') ||
|
|
map.get('free_shipping_threshold') ||
|
|
map.get('freeShippingThreshold') ||
|
|
'2000000',
|
|
);
|
|
const taxPercentage = Number(
|
|
map.get('TAX_PERCENTAGE') ||
|
|
map.get('tax_percentage') ||
|
|
map.get('taxPercentage') ||
|
|
'10',
|
|
);
|
|
const b2bDiscountPercent = Number(
|
|
map.get('B2B_DISCOUNT_PERCENT') ||
|
|
map.get('b2b_discount_percent') ||
|
|
map.get('b2bDiscountPercent') ||
|
|
'0',
|
|
);
|
|
const charityRoundStep = Number(
|
|
map.get('CHARITY_ROUND_STEP') ||
|
|
map.get('charity_round_step') ||
|
|
map.get('charityRoundStep') ||
|
|
'10000',
|
|
);
|
|
const walletWithdrawalEnabled =
|
|
map.get('walletWithdrawalEnabled') === 'true';
|
|
|
|
return {
|
|
standardShippingFee,
|
|
minOrderAmount,
|
|
freeShippingThreshold,
|
|
taxPercentage,
|
|
b2bDiscountPercent,
|
|
charityRoundStep,
|
|
charityDonationOptions: [10000, 20000, 50000],
|
|
walletWithdrawalEnabled,
|
|
};
|
|
}
|
|
|
|
async updateFinancialSettings(data: any) {
|
|
const updates: Record<string, string> = {};
|
|
|
|
if (data.standardShippingFee !== undefined) {
|
|
updates['SHIPPING_FEE'] = String(data.standardShippingFee);
|
|
updates['shipping_fee'] = String(data.standardShippingFee);
|
|
updates['standardShippingFee'] = String(data.standardShippingFee);
|
|
}
|
|
if (data.shippingFee !== undefined) {
|
|
updates['SHIPPING_FEE'] = String(data.shippingFee);
|
|
updates['shipping_fee'] = String(data.shippingFee);
|
|
updates['standardShippingFee'] = String(data.shippingFee);
|
|
}
|
|
if (data.minOrderAmount !== undefined) {
|
|
updates['MIN_ORDER_AMOUNT'] = String(data.minOrderAmount);
|
|
updates['min_order_amount'] = String(data.minOrderAmount);
|
|
updates['minOrderAmount'] = String(data.minOrderAmount);
|
|
}
|
|
if (data.freeShippingThreshold !== undefined) {
|
|
updates['FREE_SHIPPING_THRESHOLD'] = String(data.freeShippingThreshold);
|
|
updates['free_shipping_threshold'] = String(data.freeShippingThreshold);
|
|
updates['freeShippingThreshold'] = String(data.freeShippingThreshold);
|
|
}
|
|
if (data.taxPercentage !== undefined) {
|
|
updates['TAX_PERCENTAGE'] = String(data.taxPercentage);
|
|
updates['tax_percentage'] = String(data.taxPercentage);
|
|
updates['taxPercentage'] = String(data.taxPercentage);
|
|
}
|
|
if (data.b2bDiscountPercent !== undefined) {
|
|
updates['B2B_DISCOUNT_PERCENT'] = String(data.b2bDiscountPercent);
|
|
updates['b2b_discount_percent'] = String(data.b2bDiscountPercent);
|
|
updates['b2bDiscountPercent'] = String(data.b2bDiscountPercent);
|
|
}
|
|
if (data.charityRoundStep !== undefined) {
|
|
updates['CHARITY_ROUND_STEP'] = String(data.charityRoundStep);
|
|
updates['charity_round_step'] = String(data.charityRoundStep);
|
|
updates['charityRoundStep'] = String(data.charityRoundStep);
|
|
}
|
|
if (data.walletWithdrawalEnabled !== undefined) {
|
|
updates['walletWithdrawalEnabled'] = String(data.walletWithdrawalEnabled);
|
|
}
|
|
|
|
await this.updateBulkUiTexts(updates);
|
|
return this.getFinancialSettings();
|
|
}
|
|
|
|
async getScientificTerms() {
|
|
return this.prisma.scientificTerm.findMany();
|
|
}
|
|
|
|
async upsertScientificTerm(key: string, data: ScientificTermData) {
|
|
const term = String(data?.term || '');
|
|
const definition = String(data?.definition || '');
|
|
const wikiId = String(data?.wikiId || 'general');
|
|
|
|
return this.prisma.scientificTerm.upsert({
|
|
where: { key },
|
|
update: {
|
|
term,
|
|
definition,
|
|
wikiId,
|
|
},
|
|
create: {
|
|
key,
|
|
term,
|
|
definition,
|
|
wikiId,
|
|
},
|
|
});
|
|
}
|
|
|
|
async deleteScientificTerm(key: string) {
|
|
return this.prisma.scientificTerm.delete({
|
|
where: { key },
|
|
});
|
|
}
|
|
|
|
async getCategorySetting(category: string) {
|
|
if (category === 'system') {
|
|
const texts = await this.getUiTexts();
|
|
const map = new Map<string, string>();
|
|
texts.forEach((t) => map.set(t.key, t.value));
|
|
|
|
const isMaintenance =
|
|
map.get('MAINTENANCE_MODE') === 'true' ||
|
|
map.get('maintenance_mode') === 'true' ||
|
|
map.get('maintenanceMode') === 'true';
|
|
const allowGuestCheckout = map.get('allowGuestCheckout') !== 'false';
|
|
const b2bRegistrationOpen =
|
|
map.get('b2bRegistrationOpen') !== 'false' &&
|
|
map.get('b2b_enabled') !== 'false';
|
|
const supportPhone =
|
|
map.get('CONTACT_PHONE') ||
|
|
map.get('contact_phone') ||
|
|
map.get('supportPhone') ||
|
|
'۰۲۱-۸۸۸۸۴۴۴۴';
|
|
|
|
return {
|
|
maintenanceMode: isMaintenance,
|
|
allowGuestCheckout,
|
|
b2bRegistrationOpen,
|
|
supportPhone,
|
|
};
|
|
}
|
|
|
|
if (category === 'seo') {
|
|
const texts = await this.getUiTexts();
|
|
const map = new Map<string, string>();
|
|
texts.forEach((t) => map.set(t.key, t.value));
|
|
|
|
const setting = await this.prisma.setting.findFirst({
|
|
where: { category: 'seo' },
|
|
});
|
|
const storedObj =
|
|
setting && typeof setting.value === 'object' && setting.value !== null
|
|
? (setting.value as Record<string, any>)
|
|
: {};
|
|
|
|
return {
|
|
brandNameFa:
|
|
storedObj.brandNameFa ||
|
|
storedObj.brand_name_fa ||
|
|
map.get('brand_name_fa') ||
|
|
map.get('BRAND_LOGO_TEXT_FA') ||
|
|
'کنینا ایران',
|
|
brandNameEn:
|
|
storedObj.brandNameEn ||
|
|
storedObj.brand_name_en ||
|
|
map.get('brand_name_en') ||
|
|
map.get('BRAND_LOGO_TEXT_EN') ||
|
|
'Canina Iran',
|
|
titleSeparator:
|
|
storedObj.titleSeparator ||
|
|
storedObj.title_separator ||
|
|
map.get('title_separator') ||
|
|
'|',
|
|
titlePosition:
|
|
storedObj.titlePosition ||
|
|
storedObj.title_position ||
|
|
map.get('title_position') ||
|
|
'suffix',
|
|
defaultMetaTitle:
|
|
storedObj.defaultMetaTitle ||
|
|
map.get('defaultMetaTitle') ||
|
|
map.get('home_meta_title') ||
|
|
'کنینا ایران | نماینده رسمی مکملهای دارویی Canina آلمان',
|
|
defaultMetaDescription:
|
|
storedObj.defaultMetaDescription ||
|
|
map.get('defaultMetaDescription') ||
|
|
map.get('home_meta_desc') ||
|
|
'فروشگاه تخصصی و نماینده انحصاری مکملهای درمانی و تقویتی سگ و گربه کنینا آلمان با فرمولاسیون دارویی و تاییدیه بالینی.',
|
|
keywords:
|
|
storedObj.keywords ||
|
|
map.get('keywords') ||
|
|
map.get('home_keywords') ||
|
|
'مکمل سگ, مکمل گربه, مکمل دارویی حیوانات, Canina Germany',
|
|
canonicalBaseUrl:
|
|
storedObj.canonicalBaseUrl ||
|
|
map.get('canonicalBaseUrl') ||
|
|
'https://canina.ir',
|
|
ogImageUrl:
|
|
storedObj.ogImageUrl ||
|
|
map.get('ogImageUrl') ||
|
|
'/assets/images/regenerated_image_1779109861747.png',
|
|
};
|
|
}
|
|
|
|
const setting = await this.prisma.setting.findFirst({
|
|
where: { category },
|
|
});
|
|
return setting ? setting.value : {};
|
|
}
|
|
|
|
async updateCategorySetting(category: string, value: Prisma.InputJsonValue) {
|
|
const key = `${category}_config`;
|
|
const res = await this.prisma.setting.upsert({
|
|
where: { key },
|
|
update: { category, value },
|
|
create: { key, category, value },
|
|
});
|
|
|
|
// If system config is updated, also sync individual keys into uiText for fast & reliable lookup
|
|
if (category === 'system' && typeof value === 'object' && value !== null) {
|
|
const obj = value as Record<string, any>;
|
|
const updates: Record<string, string> = {};
|
|
|
|
if ('maintenanceMode' in obj) {
|
|
const valStr = String(Boolean(obj.maintenanceMode));
|
|
updates['MAINTENANCE_MODE'] = valStr;
|
|
updates['maintenance_mode'] = valStr;
|
|
updates['maintenanceMode'] = valStr;
|
|
}
|
|
if ('supportPhone' in obj) {
|
|
updates['CONTACT_PHONE'] = String(obj.supportPhone);
|
|
updates['contact_phone'] = String(obj.supportPhone);
|
|
updates['supportPhone'] = String(obj.supportPhone);
|
|
}
|
|
if ('b2bRegistrationOpen' in obj) {
|
|
const valStr = String(Boolean(obj.b2bRegistrationOpen));
|
|
updates['b2bRegistrationOpen'] = valStr;
|
|
updates['b2b_enabled'] = valStr;
|
|
}
|
|
if ('allowGuestCheckout' in obj) {
|
|
updates['allowGuestCheckout'] = String(Boolean(obj.allowGuestCheckout));
|
|
}
|
|
|
|
await this.updateBulkUiTexts(updates);
|
|
}
|
|
|
|
// If seo config is updated, sync individual keys into uiText for unified frontend consumption
|
|
if (category === 'seo' && typeof value === 'object' && value !== null) {
|
|
const obj = value as Record<string, any>;
|
|
const updates: Record<string, string> = {};
|
|
|
|
if (obj.brandNameFa || obj.brand_name_fa) {
|
|
const brand = String(obj.brandNameFa || obj.brand_name_fa);
|
|
updates['brand_name_fa'] = brand;
|
|
updates['BRAND_LOGO_TEXT_FA'] = brand;
|
|
}
|
|
if (obj.brandNameEn || obj.brand_name_en) {
|
|
const brandEn = String(obj.brandNameEn || obj.brand_name_en);
|
|
updates['brand_name_en'] = brandEn;
|
|
}
|
|
if (obj.titleSeparator || obj.title_separator) {
|
|
updates['title_separator'] = String(
|
|
obj.titleSeparator || obj.title_separator,
|
|
);
|
|
}
|
|
if (obj.titlePosition || obj.title_position) {
|
|
updates['title_position'] = String(
|
|
obj.titlePosition || obj.title_position,
|
|
);
|
|
}
|
|
if (obj.defaultMetaTitle) {
|
|
updates['defaultMetaTitle'] = String(obj.defaultMetaTitle);
|
|
}
|
|
if (obj.defaultMetaDescription) {
|
|
updates['defaultMetaDescription'] = String(obj.defaultMetaDescription);
|
|
}
|
|
if (obj.keywords) {
|
|
updates['keywords'] = String(obj.keywords);
|
|
}
|
|
if (obj.canonicalBaseUrl) {
|
|
updates['canonicalBaseUrl'] = String(obj.canonicalBaseUrl);
|
|
}
|
|
if (obj.ogImageUrl) {
|
|
updates['ogImageUrl'] = String(obj.ogImageUrl);
|
|
}
|
|
|
|
if (Object.keys(updates).length > 0) {
|
|
await this.updateBulkUiTexts(updates);
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
async getSmsSettings() {
|
|
return this.smsService.getSmsConfig();
|
|
}
|
|
|
|
async getSmsCredit() {
|
|
return this.smsService.getCredit();
|
|
}
|
|
|
|
async updateSmsSettings(value: Prisma.InputJsonValue) {
|
|
const key = 'sms_config';
|
|
return this.prisma.setting.upsert({
|
|
where: { key },
|
|
update: { category: 'sms', value },
|
|
create: { key, category: 'sms', value },
|
|
});
|
|
}
|
|
|
|
async testSms(targetPhone: string, patternId?: number, args?: string[]) {
|
|
return this.smsService.testSms(targetPhone, patternId, args);
|
|
}
|
|
|
|
async getPatterns() {
|
|
return this.smsService.getPatterns();
|
|
}
|
|
|
|
async addPattern(title: string, body: string, blackListId?: number) {
|
|
return this.smsService.addPattern(title, body, blackListId);
|
|
}
|
|
|
|
async editPattern(bodyId: number, body: string) {
|
|
return this.smsService.editPattern(bodyId, body);
|
|
}
|
|
|
|
async getSmsLogs(query: SmsLogQuery) {
|
|
return this.smsService.getSmsLogs(query);
|
|
}
|
|
|
|
async deleteSmsLog(id: string) {
|
|
return this.smsService.deleteSmsLog(id);
|
|
}
|
|
|
|
async clearAllSmsLogs() {
|
|
return this.smsService.clearAllSmsLogs();
|
|
}
|
|
}
|