feat: 完成sys模块迁移,对齐PHP/Java框架
- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { SysAgreement } from '../../entity/sysAgreement.entity';
|
||||
|
||||
@Injectable()
|
||||
export class SysAgreementService {
|
||||
constructor(
|
||||
@InjectRepository(SysAgreement)
|
||||
private readonly repo: Repository<SysAgreement>,
|
||||
) {}
|
||||
|
||||
async getList() {
|
||||
return this.repo.find({
|
||||
order: { create_time: 'DESC' },
|
||||
});
|
||||
}
|
||||
|
||||
async getAgreement(key: string) {
|
||||
return this.repo.findOne({ where: { agreement_key: key } });
|
||||
}
|
||||
|
||||
async setAgreement(key: string, title: string, content: string) {
|
||||
const existing = await this.repo.findOne({ where: { agreement_key: key } });
|
||||
|
||||
if (existing) {
|
||||
await this.repo.update(existing.id, {
|
||||
title,
|
||||
content,
|
||||
update_time: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
} else {
|
||||
const agreement = this.repo.create({
|
||||
agreement_key: key,
|
||||
title,
|
||||
content,
|
||||
create_time: Math.floor(Date.now() / 1000),
|
||||
update_time: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
await this.repo.save(agreement);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user