feat: M4-08 — release & decision module (changelogs, ADR, checklist)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s

- Add DecisionRecord and ReleaseChecklist Prisma models
- ReleaseController: CRUD for changelogs, decisions, checklists
- AAPI: /admin-api/release/changelogs, /decisions, /checklists

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
WangDL 2026-05-24 18:14:53 +08:00
parent 5d84769ac0
commit cefc4d51c9
4 changed files with 118 additions and 0 deletions

View File

@ -1442,3 +1442,29 @@ model AgentArtifact {
@@index([taskId]) @@index([taskId])
@@index([type]) @@index([type])
} }
model DecisionRecord {
id String @id @default(cuid())
title String @db.VarChar(255)
context String? @db.Text
decision String? @db.Text
rationale String? @db.Text
status String @default("proposed") @db.VarChar(32)
createdBy String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([status])
}
model ReleaseChecklist {
id String @id @default(cuid())
version String @db.VarChar(50)
item String @db.VarChar(255)
checked Boolean @default(false)
sortOrder Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([version])
}

View File

@ -56,6 +56,7 @@ import { BackupModule } from './modules/backup/backup.module';
import { ReportingModule } from './modules/reporting/reporting.module'; import { ReportingModule } from './modules/reporting/reporting.module';
import { ProjectCenterModule } from './modules/project-center/project-center.module'; import { ProjectCenterModule } from './modules/project-center/project-center.module';
import { HermesAgentModule } from './modules/hermes-agent/hermes-agent.module'; import { HermesAgentModule } from './modules/hermes-agent/hermes-agent.module';
import { ReleaseModule } from './modules/release/release.module';
import { JwtAuthGuard } from './common/guards/jwt-auth.guard'; import { JwtAuthGuard } from './common/guards/jwt-auth.guard';
import { RolesGuard } from './common/guards/roles.guard'; import { RolesGuard } from './common/guards/roles.guard';
@ -157,6 +158,7 @@ import appleConfig from './config/apple.config';
ReportingModule, ReportingModule,
ProjectCenterModule, ProjectCenterModule,
HermesAgentModule, HermesAgentModule,
ReleaseModule,
], ],
providers: [ providers: [
{ provide: APP_GUARD, useClass: RateLimitGuard }, { provide: APP_GUARD, useClass: RateLimitGuard },

View File

@ -0,0 +1,83 @@
import { Controller, Get, Post, Patch, Delete, Param, Body, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { PrismaService } from '../../infrastructure/database/prisma.service';
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
@ApiTags('admin-release')
@ApiBearerAuth()
@Controller('admin-api/release')
@UseGuards(AdminAuthGuard, AdminRolesGuard)
export class ReleaseController {
constructor(private readonly prisma: PrismaService) {}
// ═══ Changelogs ═══
@Get('changelogs')
@ApiOperation({ summary: '版本日志列表' })
async listChangelogs() {
return this.prisma.appChangelog.findMany({ orderBy: { createdAt: 'desc' } });
}
@Post('changelogs')
@ApiOperation({ summary: '创建版本日志' })
async createChangelog(@Body() dto: { version: string; title: string; content: string; platform?: string }) {
return this.prisma.appChangelog.create({ data: { ...dto, platform: dto.platform || 'ios' } });
}
@Patch('changelogs/:id')
@ApiOperation({ summary: '更新版本日志' })
async updateChangelog(@Param('id') id: string, @Body() dto: Record<string, any>) {
return this.prisma.appChangelog.update({ where: { id }, data: dto });
}
@Delete('changelogs/:id')
@ApiOperation({ summary: '删除版本日志' })
async deleteChangelog(@Param('id') id: string) {
await this.prisma.appChangelog.delete({ where: { id } });
return { ok: true };
}
// ═══ Decision Records (ADR) ═══
@Get('decisions')
@ApiOperation({ summary: '决策记录列表' })
async listDecisions() {
return this.prisma.decisionRecord.findMany({ orderBy: { createdAt: 'desc' } });
}
@Post('decisions')
@ApiOperation({ summary: '创建决策记录' })
async createDecision(@Body() dto: { title: string; context?: string; decision?: string; rationale?: string }) {
return this.prisma.decisionRecord.create({ data: dto });
}
@Patch('decisions/:id')
@ApiOperation({ summary: '更新决策记录' })
async updateDecision(@Param('id') id: string, @Body() dto: Record<string, any>) {
return this.prisma.decisionRecord.update({ where: { id }, data: dto });
}
// ═══ Release Checklist ═══
@Get('checklists/:version')
@ApiOperation({ summary: '版本回归清单' })
async listChecklist(@Param('version') version: string) {
return this.prisma.releaseChecklist.findMany({
where: { version },
orderBy: { sortOrder: 'asc' },
});
}
@Post('checklists')
@ApiOperation({ summary: '添加检查项' })
async addChecklistItem(@Body() dto: { version: string; item: string; sortOrder?: number }) {
return this.prisma.releaseChecklist.create({ data: dto });
}
@Patch('checklists/:id')
@ApiOperation({ summary: '更新检查项(标记完成)' })
async toggleChecklist(@Param('id') id: string, @Body() dto: { checked?: boolean; item?: string }) {
return this.prisma.releaseChecklist.update({ where: { id }, data: dto });
}
}

View File

@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { ReleaseController } from './release.controller';
@Module({
controllers: [ReleaseController],
})
export class ReleaseModule {}