feat: 实现出库导入、区块链存证、查询日志、看板与系统设置
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiPropertyOptional, ApiTags } from '@nestjs/swagger';
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { QueryResult } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { buildPage } from '../common/utils/pagination.util';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
|
||||
class QueryLogQueryDto extends PaginationDto {
|
||||
@ApiPropertyOptional({ description: '关键词(短码)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
keyword?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '查询结果', enum: QueryResult })
|
||||
@IsOptional()
|
||||
@IsEnum(QueryResult)
|
||||
result?: QueryResult;
|
||||
|
||||
@ApiPropertyOptional({ description: '开始时间' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
startTime?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: '结束时间' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
endTime?: string;
|
||||
}
|
||||
|
||||
@ApiTags('查询日志')
|
||||
@ApiBearerAuth()
|
||||
@Controller('query-logs')
|
||||
export class QueryLogController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: '查询日志列表' })
|
||||
async list(@Query() query: QueryLogQueryDto) {
|
||||
const where: Prisma.QueryLogWhereInput = {};
|
||||
if (query.keyword) where.shortCode = { contains: query.keyword };
|
||||
if (query.result) where.queryResult = query.result;
|
||||
if (query.startTime || query.endTime) {
|
||||
where.queriedAt = {};
|
||||
if (query.startTime) where.queriedAt.gte = new Date(query.startTime);
|
||||
if (query.endTime) where.queriedAt.lte = new Date(query.endTime);
|
||||
}
|
||||
const [list, total] = await this.prisma.$transaction([
|
||||
this.prisma.queryLog.findMany({
|
||||
where,
|
||||
orderBy: { id: 'desc' },
|
||||
skip: query.skip,
|
||||
take: query.take,
|
||||
}),
|
||||
this.prisma.queryLog.count({ where }),
|
||||
]);
|
||||
return buildPage(list, total, query.page, query.pageSize);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user