feat(v2.2): 建立分区关系表和AppData迁移预演
This commit is contained in:
@@ -12,6 +12,13 @@ const VALID_TRANSITIONS: Record<string, string[]> = {
|
||||
[RequirementStatus.DELIVERED]: [],
|
||||
};
|
||||
|
||||
function createFallbackRequirementCode() {
|
||||
return `REQ-${Date.now().toString(36).toUpperCase()}-${Math.random()
|
||||
.toString(36)
|
||||
.slice(2, 6)
|
||||
.toUpperCase()}`;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class RequirementService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
@@ -20,6 +27,7 @@ export class RequirementService {
|
||||
return this.prisma.requirement.create({
|
||||
data: {
|
||||
productId,
|
||||
code: dto.code?.trim() || createFallbackRequirementCode(),
|
||||
title: dto.title,
|
||||
description: dto.description || '',
|
||||
priority: dto.priority ?? 0,
|
||||
@@ -51,8 +59,9 @@ export class RequirementService {
|
||||
async update(productId: string, id: string, dto: UpdateRequirementDto) {
|
||||
await this.findOne(productId, id);
|
||||
return this.prisma.requirement.update({
|
||||
where: { id },
|
||||
where: { id_productId: { id, productId } },
|
||||
data: {
|
||||
...(dto.code !== undefined && { code: dto.code }),
|
||||
...(dto.title !== undefined && { title: dto.title }),
|
||||
...(dto.description !== undefined && { description: dto.description }),
|
||||
...(dto.priority !== undefined && { priority: dto.priority }),
|
||||
@@ -69,13 +78,13 @@ export class RequirementService {
|
||||
);
|
||||
}
|
||||
return this.prisma.requirement.update({
|
||||
where: { id },
|
||||
where: { id_productId: { id, productId } },
|
||||
data: { status: newStatus },
|
||||
});
|
||||
}
|
||||
|
||||
async remove(productId: string, id: string) {
|
||||
await this.findOne(productId, id);
|
||||
return this.prisma.requirement.delete({ where: { id } });
|
||||
return this.prisma.requirement.delete({ where: { id_productId: { id, productId } } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user