feat: 完成sys模块迁移,对齐PHP/Java框架
- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AgreementController } from './controllers/api/AgreementController';
|
||||
import { AgreementService } from './services/api/AgreementService';
|
||||
import { CoreAgreementService } from './services/core/CoreAgreementService';
|
||||
import { Agreement } from './entities/Agreement';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Agreement])],
|
||||
controllers: [AgreementController],
|
||||
providers: [AgreementService, CoreAgreementService],
|
||||
exports: [AgreementService, CoreAgreementService],
|
||||
})
|
||||
export class AgreementModule {}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { Controller, Get, Post, Body, Param, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
||||
import { AgreementService } from '../../services/api/AgreementService';
|
||||
|
||||
@Controller('api/agreement')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class AgreementController {
|
||||
constructor(private readonly agreementService: AgreementService) {}
|
||||
|
||||
@Get('list')
|
||||
async list(@Query() query: any) {
|
||||
return this.agreementService.getList(query);
|
||||
}
|
||||
|
||||
@Get('info/:agreement_id')
|
||||
async info(@Param('agreement_id') agreement_id: number) {
|
||||
return this.agreementService.getInfo(agreement_id);
|
||||
}
|
||||
|
||||
@Get('type/:agreement_type')
|
||||
async getByType(@Param('agreement_type') agreement_type: string, @Query() query: any) {
|
||||
return this.agreementService.getByType(agreement_type, query);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
||||
import { BaseEntity } from '../../../core/base/BaseEntity';
|
||||
|
||||
@Entity('agreement')
|
||||
export class Agreement extends BaseEntity {
|
||||
@PrimaryGeneratedColumn({ name: 'agreement_id' })
|
||||
agreement_id: number;
|
||||
|
||||
@Column({ name: 'site_id', type: 'int', default: 0 })
|
||||
declare site_id: number;
|
||||
|
||||
@Column({ name: 'agreement_type', type: 'varchar', length: 50, default: '' })
|
||||
agreement_type: string;
|
||||
|
||||
@Column({ name: 'agreement_title', type: 'varchar', length: 255, default: '' })
|
||||
agreement_title: string;
|
||||
|
||||
@Column({ name: 'agreement_content', type: 'text', nullable: true })
|
||||
agreement_content: string;
|
||||
|
||||
@Column({ name: 'agreement_status', type: 'tinyint', default: 0 })
|
||||
agreement_status: number;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CoreAgreementService } from '../core/CoreAgreementService';
|
||||
|
||||
@Injectable()
|
||||
export class AgreementService {
|
||||
constructor(private readonly coreAgreementService: CoreAgreementService) {}
|
||||
|
||||
async getList(query: any) {
|
||||
return this.coreAgreementService.getList(query);
|
||||
}
|
||||
|
||||
async getInfo(agreement_id: number) {
|
||||
return this.coreAgreementService.getInfo(agreement_id);
|
||||
}
|
||||
|
||||
async getByType(agreement_type: string, query: any) {
|
||||
return this.coreAgreementService.getByType(agreement_type, query);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '@wwjCore/base/BaseService';
|
||||
import { Agreement } from '../../entities/Agreement';
|
||||
|
||||
@Injectable()
|
||||
export class CoreAgreementService extends BaseService<Agreement> {
|
||||
constructor(
|
||||
@InjectRepository(Agreement)
|
||||
private agreementRepository: Repository<Agreement>,
|
||||
) {
|
||||
super(agreementRepository);
|
||||
}
|
||||
|
||||
async getList(query: any) {
|
||||
return this.agreementRepository.find();
|
||||
}
|
||||
|
||||
async getInfo(agreement_id: number) {
|
||||
return this.agreementRepository.findOne({ where: { agreement_id } });
|
||||
}
|
||||
|
||||
async getByType(agreement_type: string, query: any) {
|
||||
return this.agreementRepository.findOne({
|
||||
where: { agreement_type, agreement_status: 1 }
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user