一、超管端设计优化 - 文档管理SOP体系建立,docs目录重组 - 统一用户管理:跨租户全局视角,合并用户管理+公众用户 - 活动监管全模块重构:全部活动(统计卡片+阶段筛选+SuperDetail详情页)、报名数据/作品数据/评审进度(两层合一扁平列表)、成果发布(去Tab+统计+隐藏写操作) - 菜单精简:移除评委管理/评审规则/通知管理 - Bug修复:租户编辑丢失隐藏菜单、pageSize限制、主色统一 二、UGC绘本创作社区P0 - 数据库:10张新表(user_works/user_work_pages/work_tags等) - 子女账号独立化:Child升级为独立User,家长切换+独立登录 - 用户作品库:CRUD+发布审核,8个API - AI创作流程:提交→生成→保存到作品库,4个API - 作品广场:首页改造为推荐流,标签+搜索+排序 - 内容审核(超管端):作品审核+作品管理+标签管理 - 活动联动:WorkSelector作品选择器 - 布局改造:底部5Tab(发现/创作/活动/作品库/我的) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
109 lines
2.3 KiB
TypeScript
109 lines
2.3 KiB
TypeScript
import {
|
|
Injectable,
|
|
NotFoundException,
|
|
} from '@nestjs/common';
|
|
import { PrismaService } from '../../prisma/prisma.service';
|
|
import { CreateAttachmentDto } from './dto/create-attachment.dto';
|
|
import { UpdateAttachmentDto } from './dto/update-attachment.dto';
|
|
|
|
@Injectable()
|
|
export class AttachmentsService {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
async create(createAttachmentDto: CreateAttachmentDto, creatorId?: number) {
|
|
// 验证活动是否存在
|
|
const contest = await this.prisma.contest.findUnique({
|
|
where: { id: createAttachmentDto.contestId },
|
|
});
|
|
|
|
if (!contest) {
|
|
throw new NotFoundException('活动不存在');
|
|
}
|
|
|
|
const data: any = {
|
|
...createAttachmentDto,
|
|
size: createAttachmentDto.size || '0',
|
|
};
|
|
|
|
if (creatorId) {
|
|
data.creator = creatorId;
|
|
}
|
|
|
|
return this.prisma.contestAttachment.create({
|
|
data,
|
|
include: {
|
|
contest: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
async findAll(contestId: number) {
|
|
return this.prisma.contestAttachment.findMany({
|
|
where: {
|
|
contestId,
|
|
validState: 1,
|
|
},
|
|
orderBy: {
|
|
createTime: 'desc',
|
|
},
|
|
include: {
|
|
contest: {
|
|
select: {
|
|
id: true,
|
|
contestName: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
async findOne(id: number) {
|
|
const attachment = await this.prisma.contestAttachment.findFirst({
|
|
where: {
|
|
id,
|
|
validState: 1,
|
|
},
|
|
include: {
|
|
contest: true,
|
|
},
|
|
});
|
|
|
|
if (!attachment) {
|
|
throw new NotFoundException('附件不存在');
|
|
}
|
|
|
|
return attachment;
|
|
}
|
|
|
|
async update(id: number, updateAttachmentDto: UpdateAttachmentDto, modifierId?: number) {
|
|
const attachment = await this.findOne(id);
|
|
|
|
const data: any = { ...updateAttachmentDto };
|
|
|
|
if (modifierId) {
|
|
data.modifier = modifierId;
|
|
}
|
|
|
|
return this.prisma.contestAttachment.update({
|
|
where: { id },
|
|
data,
|
|
include: {
|
|
contest: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
async remove(id: number) {
|
|
await this.findOne(id);
|
|
|
|
// 软删除
|
|
return this.prisma.contestAttachment.update({
|
|
where: { id },
|
|
data: {
|
|
validState: 2,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|