增加时间判断

main
rustdreamer 2 years ago
parent 484b55b4de
commit 13d0d6de66

@ -4,7 +4,7 @@ import * as fs from 'fs';
import { ApiBearerAuth, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsDateString, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { NodeVisitorEntity } from './node-visitor.entity';
import { DataSource, IsNull, Not, Repository } from 'typeorm';
import { DataSource, IsNull, LessThan, Not, Repository } from 'typeorm';
import * as bluebird from 'bluebird';
import { NodeOtherVisitorEntity } from './node-other-visitor.entity';
import * as moment from 'moment';
@ -229,6 +229,7 @@ export class AppController {
@Get("/visitor")
@ApiBearerAuth()
async getVisiotr(@Query() { identity_card_no }: QueryVisitorByNumberDto, @Req() req: any) {
let date = new Date().getDate();
const node_other_visitor: any = await this.nodeOtherVisitorRepository.findOne({
where: { identity_card_no },
order: {
@ -239,7 +240,12 @@ export class AppController {
const node_visitor = await this.nodeVisitorRepository.findOne({
where: { id: node_other_visitor.node_visitor_id }
})
node_other_visitor.info = node_visitor;
if (new Date(node_visitor.start_date) <= new Date(date) && new Date(node_visitor.end_date) >= new Date(date)) {
node_other_visitor.info = node_visitor;
} else {
return null;
}
}
return node_other_visitor
}
@ -456,7 +462,7 @@ export class AppController {
if (!node_other_visitor) {
throw new BadRequestException("数据不存在")
}
node_other_visitor.end_time= new Date();
node_other_visitor.end_time = new Date();
const result = await this.nodeOtherVisitorRepository.save(node_other_visitor);
return result;
}

Loading…
Cancel
Save