feat: 完成现有小程序接口的全部迁移至新后端
This commit is contained in:
@@ -18,5 +18,6 @@ import { WorksheetService } from './worksheet.service';
|
||||
AdminResourceController,
|
||||
],
|
||||
providers: [WorksheetService, PublicationService, ResourcePreviewService],
|
||||
exports: [WorksheetService],
|
||||
})
|
||||
export class WorksheetModule {}
|
||||
|
||||
@@ -68,6 +68,17 @@ export class WorksheetService {
|
||||
@Inject(SERVER_CONFIG) private readonly config: ServerConfig,
|
||||
) {}
|
||||
|
||||
/** 首页和推荐在调用者事务中获取同一份公开快照,复用完整可见性与资产解析规则。 */
|
||||
async snapshot(tx: Prisma.TransactionClient): Promise<PublicWorksheet[]> {
|
||||
const rows = await tx.$queryRaw<
|
||||
WorksheetRow[]
|
||||
>`SELECT ${this.columns(this.isNewExpression(new Date()))}
|
||||
FROM public.worksheets w JOIN public.assets a ON a.id=w.preview_asset_id
|
||||
WHERE ${visibleWorksheet} ORDER BY w.sort_order, w.updated_at DESC, w.id LIMIT 10001`;
|
||||
if (rows.length > 10000) throw new Error('Site snapshot exceeds limit');
|
||||
return rows.map((row) => this.toPublic(row));
|
||||
}
|
||||
|
||||
/** 公开查询不提供状态开关,固定要求题型及全部上级分类上线。 */
|
||||
async list(input: WorksheetQueryDto): Promise<WorksheetPage> {
|
||||
const query = parseWorksheetQuery(input);
|
||||
|
||||
Reference in New Issue
Block a user