From 5012d3d7bfd08574e0e71532b18c795e8967f8e9 Mon Sep 17 00:00:00 2001 From: rustdreamer Date: Mon, 4 Sep 2023 16:16:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A6=BB=E5=BC=80=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.controller.ts | 29 +++++++++++++++++++++++++++++ src/node-other-visitor.entity.ts | 8 ++++++++ 2 files changed, 37 insertions(+) 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; }