- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换 - 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片 - 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转 - 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出 - 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志 - 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票 - 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏 - 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
110 行
2.9 KiB
TypeScript
110 行
2.9 KiB
TypeScript
import { Provide } from '@midwayjs/core';
|
|
import { BaseService } from '@cool-midway/core';
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { BaseAuditLogEntity } from '../entity/audit';
|
|
|
|
export interface AuditRecordDTO {
|
|
module: string;
|
|
action: string;
|
|
operatorId?: number | null;
|
|
operatorName?: string | null;
|
|
ip?: string | null;
|
|
detail?: string | null;
|
|
status?: number;
|
|
}
|
|
|
|
export interface AuditQueryDTO {
|
|
module?: string;
|
|
action?: string;
|
|
status?: number;
|
|
keyWord?: string;
|
|
startDate?: string;
|
|
endDate?: string;
|
|
page?: number;
|
|
size?: number;
|
|
}
|
|
|
|
export interface AuditPaginationResult {
|
|
list: BaseAuditLogEntity[];
|
|
total: number;
|
|
page: number;
|
|
size: number;
|
|
}
|
|
|
|
/**
|
|
* 安全审计日志服务
|
|
*/
|
|
@Provide()
|
|
export class BaseAuditLogService extends BaseService {
|
|
@InjectEntityModel(BaseAuditLogEntity)
|
|
baseAuditLogEntity: Repository<BaseAuditLogEntity>;
|
|
|
|
/**
|
|
* 自动落库记录一条安全审计日志
|
|
*/
|
|
async record(dto: AuditRecordDTO): Promise<BaseAuditLogEntity> {
|
|
const log = new BaseAuditLogEntity();
|
|
log.module = dto.module;
|
|
log.action = dto.action;
|
|
log.operatorId = dto.operatorId ?? null;
|
|
log.operatorName = dto.operatorName ?? null;
|
|
log.ip = dto.ip ?? null;
|
|
log.detail = dto.detail ?? null;
|
|
log.status = dto.status !== undefined ? Number(dto.status) : 1;
|
|
|
|
return await this.baseAuditLogEntity.save(log);
|
|
}
|
|
|
|
/**
|
|
* 多条件组合过滤与分页检索
|
|
*/
|
|
async filterLogs(query: AuditQueryDTO): Promise<AuditPaginationResult> {
|
|
const page = Math.max(1, Number(query.page) || 1);
|
|
const size = Math.max(1, Number(query.size) || 20);
|
|
const skip = (page - 1) * size;
|
|
|
|
// 构建过滤条件
|
|
const where: Record<string, unknown> = {};
|
|
if (query.module) {
|
|
where.module = query.module;
|
|
}
|
|
if (query.action) {
|
|
where.action = query.action;
|
|
}
|
|
if (query.status !== undefined && query.status !== null) {
|
|
where.status = Number(query.status);
|
|
}
|
|
|
|
const [allList, total] = await this.baseAuditLogEntity.findAndCount({
|
|
where: Object.keys(where).length > 0 ? where : undefined,
|
|
order: { createTime: 'DESC' },
|
|
});
|
|
|
|
let resultList = allList;
|
|
|
|
// 关键字模糊匹配 (operatorName, action, ip, module)
|
|
if (query.keyWord) {
|
|
const kw = query.keyWord.toLowerCase();
|
|
resultList = resultList.filter((item) => {
|
|
return (
|
|
(item.operatorName && item.operatorName.toLowerCase().includes(kw)) ||
|
|
(item.action && item.action.toLowerCase().includes(kw)) ||
|
|
(item.module && item.module.toLowerCase().includes(kw)) ||
|
|
(item.ip && item.ip.toLowerCase().includes(kw))
|
|
);
|
|
});
|
|
}
|
|
|
|
const finalTotal = query.keyWord ? resultList.length : total;
|
|
const paginatedList = resultList.slice(skip, skip + size);
|
|
|
|
return {
|
|
list: paginatedList,
|
|
total: finalTotal,
|
|
page,
|
|
size,
|
|
};
|
|
}
|
|
}
|