- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换 - 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片 - 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转 - 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出 - 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志 - 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票 - 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏 - 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
77 行
2.0 KiB
TypeScript
77 行
2.0 KiB
TypeScript
import { Init, Inject, Provide } from '@midwayjs/core';
|
||
import { BaseService } from '@cool-midway/core';
|
||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||
import { Repository } from 'typeorm';
|
||
import { CardInfoEntity } from '../entity/info';
|
||
import { CardPortalService } from './portal';
|
||
|
||
/**
|
||
* 名片增删改载荷(Cool CRUD 传入对象、主键或主键列表)
|
||
*/
|
||
interface CardModifyRecord {
|
||
id?: string | number;
|
||
slug?: string;
|
||
}
|
||
|
||
/**
|
||
* 后台名片信息服务
|
||
*/
|
||
@Provide()
|
||
export class CardInfoService extends BaseService {
|
||
@InjectEntityModel(CardInfoEntity)
|
||
cardInfoEntity: Repository<CardInfoEntity>;
|
||
|
||
@Inject()
|
||
cardPortalService: CardPortalService;
|
||
|
||
@Init()
|
||
async init() {
|
||
await super.init();
|
||
this.setEntity(this.cardInfoEntity);
|
||
}
|
||
|
||
/**
|
||
* 新增/修改/删除后清理门户缓存
|
||
*/
|
||
async modifyAfter(
|
||
data: CardModifyRecord | Array<CardModifyRecord | string | number> | string | number,
|
||
type: 'delete' | 'update' | 'add'
|
||
): Promise<void> {
|
||
if (type !== 'add' && type !== 'update' && type !== 'delete') {
|
||
return;
|
||
}
|
||
const keys = this.collectCacheKeys(data);
|
||
for (const key of keys) {
|
||
await this.cardPortalService.clearPortalCache(key);
|
||
}
|
||
}
|
||
|
||
private collectCacheKeys(
|
||
data: CardModifyRecord | Array<CardModifyRecord | string | number> | string | number
|
||
): Array<string | number> {
|
||
if (data === undefined || data === null || data === '') {
|
||
return [];
|
||
}
|
||
if (typeof data === 'number') {
|
||
return [data];
|
||
}
|
||
if (typeof data === 'string') {
|
||
return data
|
||
.split(',')
|
||
.map(item => item.trim())
|
||
.filter(item => item.length > 0);
|
||
}
|
||
if (Array.isArray(data)) {
|
||
return data.flatMap(item => this.collectCacheKeys(item));
|
||
}
|
||
const keys: Array<string | number> = [];
|
||
if (data.id !== undefined && data.id !== null && data.id !== '') {
|
||
keys.push(data.id);
|
||
}
|
||
if (data.slug) {
|
||
keys.push(data.slug);
|
||
}
|
||
return keys;
|
||
}
|
||
}
|