diff --git a/src/app.controller.ts b/src/app.controller.ts index 0a61da9..7a62937 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -60,6 +60,13 @@ export class UpdateVisitorNumber { public card_number: string; } +export class UpdateVisitorEnd { + @ApiProperty({ description: "id" }) + @IsString() + @IsNotEmpty() + public id: string; +} + export class CreateVisitor { @ApiProperty({ description: "申请人" }) @IsString() @@ -371,6 +378,28 @@ export class AppController { return result; } + @Put("/visitor/end") + async updateVisitorEnd(@Body() data: UpdateVisitorEnd) { + const node_other_visitor = await this.nodeOtherVisitorRepository.findOne({ where: { id: data.id } }) + if (!node_other_visitor) { + throw new BadRequestException("数据不存在") + } + node_other_visitor.end_time= new Date(); + const result = await this.nodeOtherVisitorRepository.save(node_other_visitor); + return result; + } + + @Put("/visitor/start") + async updateVisitorStart(@Body() data: UpdateVisitorEnd) { + const node_other_visitor = await this.nodeOtherVisitorRepository.findOne({ where: { id: data.id } }) + if (!node_other_visitor) { + throw new BadRequestException("数据不存在") + } + node_other_visitor.start_time = new Date(); + const result = await this.nodeOtherVisitorRepository.save(node_other_visitor); + return result; + } + @Post('upload/base64') async louploadBase64Filegin( @Body() input: any, diff --git a/src/node-other-visitor.entity.ts b/src/node-other-visitor.entity.ts index f41e16d..7254efd 100644 --- a/src/node-other-visitor.entity.ts +++ b/src/node-other-visitor.entity.ts @@ -33,4 +33,12 @@ export class NodeOtherVisitorEntity extends Base { @ApiProperty({ description: "" }) @Column({ length: 36, nullable: true, type: 'char' }) public node_visitor_id: string; + + @ApiProperty({ description: "进入时间" }) + @Column({ nullable: true }) + public start_time: Date; + + @ApiProperty({ description: "离开时间" }) + @Column({ nullable: true }) + public end_time: Date; }