test: harden business boundary conditions
This commit is contained in:
@@ -3,6 +3,7 @@ import { OperationLogsService } from './operation-logs.service';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { RequirePermission } from '../auth/decorators/permission.decorator';
|
||||
import { extractRequestInfo } from '../common/request-utils';
|
||||
import { CreateAuditLogDto, QueryOperationLogsDto } from './dto/operation-log.dto';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('operation-logs')
|
||||
@@ -11,29 +12,15 @@ export class OperationLogsController {
|
||||
|
||||
@Get()
|
||||
@RequirePermission('log:view')
|
||||
findAll(
|
||||
@Query('module') module?: string,
|
||||
@Query('userId') userId?: string,
|
||||
@Query('startDate') startDate?: string,
|
||||
@Query('endDate') endDate?: string,
|
||||
@Query('page') page?: string,
|
||||
@Query('pageSize') pageSize?: string,
|
||||
) {
|
||||
return this.service.findAll({
|
||||
module,
|
||||
userId: userId ? +userId : undefined,
|
||||
startDate,
|
||||
endDate,
|
||||
page: page ? +page : 1,
|
||||
pageSize: pageSize ? +pageSize : 50,
|
||||
});
|
||||
findAll(@Query() query: QueryOperationLogsDto) {
|
||||
return this.service.findAll(query);
|
||||
}
|
||||
|
||||
|
||||
@Post('audit')
|
||||
@RequirePermission('log:create')
|
||||
async createAuditLog(
|
||||
@Body() body: { module: string; action: string; targetId?: number; targetType?: string; detail?: string },
|
||||
@Body() body: CreateAuditLogDto,
|
||||
@Request() req: any,
|
||||
) {
|
||||
const { ipAddress, userAgent } = extractRequestInfo(req);
|
||||
|
||||
Reference in New Issue
Block a user