From 09b2e522eb6d99b09b174d9c580af7da70771cc0 Mon Sep 17 00:00:00 2001 From: rustdreamer Date: Tue, 29 Aug 2023 14:43:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.controller.ts | 25 ++++++++++++++++++++++++- src/node-other-visitor.entity.ts | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index 0cff5f8..43f1a25 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,4 +1,4 @@ -import { BadRequestException, Body, Controller, Get, Post, Query, Req } from '@nestjs/common'; +import { BadRequestException, Body, Controller, Get, Post, Put, Query, Req } from '@nestjs/common'; import { AppService } from './app.service'; import * as fs from 'fs'; import { ApiBearerAuth, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; @@ -48,6 +48,18 @@ export class VisitorList { public nationality: string; } +export class UpdateVisitorNumber { + @ApiProperty({ description: "id" }) + @IsString() + @IsNotEmpty() + public id: string; + + @ApiProperty({ description: "card_number" }) + @IsString() + @IsNotEmpty() + public card_number: string; +} + export class CreateVisitor { @ApiProperty({ description: "申请人" }) @IsString() @@ -347,6 +359,17 @@ export class AppController { }); } + @Put("/visitor/number") + async updateVisitor(@Body() data: UpdateVisitorNumber) { + const node_other_visitor = await this.nodeOtherVisitorRepository.findOne({ where: { id: data.id } }) + if (!node_other_visitor) { + throw new BadRequestException("数据不存在") + } + node_other_visitor.card_number = data.card_number; + 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 218a072..f41e16d 100644 --- a/src/node-other-visitor.entity.ts +++ b/src/node-other-visitor.entity.ts @@ -26,6 +26,10 @@ export class NodeOtherVisitorEntity extends Base { @Column({ length: 150, nullable: true, type: 'char' }) public nationality: string; + @ApiProperty({ description: "访客卡编号" }) + @Column({ length: 150, nullable: true, type: 'char' }) + public card_number: string; + @ApiProperty({ description: "" }) @Column({ length: 36, nullable: true, type: 'char' }) public node_visitor_id: string;