完善访客接口
parent
696ec918e8
commit
b312dcd929
@ -1,33 +1,202 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsArray, IsBoolean, IsDateString, IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
import { NodeVisitorEntity } from './node-visitor.entity';
|
||||||
|
import { DataSource } from 'typeorm';
|
||||||
|
import * as bluebird from 'bluebird';
|
||||||
|
import { NodeOtherVisitorEntity } from './node-other-visitor.entity';
|
||||||
|
|
||||||
|
export class Electronics {
|
||||||
|
@ApiProperty({ description: "电子产品名称" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class VisitorList {
|
||||||
|
@ApiProperty({ description: "访客姓名" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客身份证号" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public identity_card_no: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "国籍(中国/其他国籍)" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public nationality_type: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "国籍名称" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public nationality: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateVisitor {
|
||||||
|
@ApiProperty({ description: "申请人" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public applicant: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请人部门" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public applicant_department: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请日期" })
|
||||||
|
@IsDateString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public apply_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请单号" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public code: string;
|
||||||
|
|
||||||
|
// TODO 确定访客类型
|
||||||
|
@ApiProperty({ description: "来访类型" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visitor_type: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "来访区域" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public area: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "来访单位" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visitor_unit: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客人数" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visitor_number: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "交通方式" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public transport: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "车牌号" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public plate_no: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "起始日期" })
|
||||||
|
@IsDateString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public start_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "截止日期" })
|
||||||
|
@IsDateString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public end_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访人" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visited_staff: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访部门" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visited_deparment: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访部门" })
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public purpose: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "携带的电子产品", type: [Electronics] })
|
||||||
|
@IsArray()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public electronics: Electronics[];
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客清单", type: [VisitorList] })
|
||||||
|
@IsArray()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public visitor_list: VisitorList[];
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客是否有可能接触受控设备" })
|
||||||
|
@IsBoolean()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public may_access_sensitive_info: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class AppController {
|
export class AppController {
|
||||||
constructor(private readonly appService: AppService) {}
|
constructor(
|
||||||
|
private readonly appService: AppService,
|
||||||
|
|
||||||
|
private readonly dataSource: DataSource,
|
||||||
|
) { }
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
getHello(): string {
|
getHello(): string {
|
||||||
return this.appService.getHello();
|
return this.appService.getHello();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("/doc/json")
|
// @Get("/doc/json")
|
||||||
getDoc(): string {
|
// getDoc(): string {
|
||||||
const json = fs.readFileSync("swagger-spec.json", "utf-8");
|
// const json = fs.readFileSync("swagger-spec.json", "utf-8");
|
||||||
|
|
||||||
return JSON.parse(json);
|
// return JSON.parse(json);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Get("/app.config")
|
// @Get("/app.config")
|
||||||
appConfig() {
|
// appConfig() {
|
||||||
return {
|
// return {
|
||||||
app_id: process.env.QUNSENSE_SUITE_ID
|
// app_id: process.env.QUNSENSE_SUITE_ID
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Get("/WW_verify_n9zX2u8E9ShFgYmx.txt")
|
// @Get("/WW_verify_n9zX2u8E9ShFgYmx.txt")
|
||||||
// config(): string {
|
// config(): string {
|
||||||
// return "n9zX2u8E9ShFgYmx";
|
// return "n9zX2u8E9ShFgYmx";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Post("/visitor")
|
||||||
|
async create(@Body() data: CreateVisitor) {
|
||||||
|
return await this.dataSource.transaction(async transactionalEntityManager => {
|
||||||
|
|
||||||
|
const new_node_visitor = new NodeVisitorEntity();
|
||||||
|
new_node_visitor.applicant = data.applicant;
|
||||||
|
new_node_visitor.applicant_department = data.applicant_department;
|
||||||
|
new_node_visitor.apply_date = data.apply_date;
|
||||||
|
new_node_visitor.code = data.code;
|
||||||
|
new_node_visitor.visitor_type = data.visitor_type;
|
||||||
|
new_node_visitor.area = data.area;
|
||||||
|
new_node_visitor.visitor_unit = data.visitor_unit;
|
||||||
|
new_node_visitor.visitor_number = data.visitor_number;
|
||||||
|
new_node_visitor.transport = data.transport;
|
||||||
|
new_node_visitor.plate_no = data.plate_no;
|
||||||
|
new_node_visitor.start_date = data.start_date;
|
||||||
|
new_node_visitor.end_date = data.end_date;
|
||||||
|
new_node_visitor.visited_staff = data.visited_staff;
|
||||||
|
new_node_visitor.visited_deparment = data.visited_deparment;
|
||||||
|
new_node_visitor.purpose = data.purpose;
|
||||||
|
new_node_visitor.electronics = JSON.stringify(data.electronics);
|
||||||
|
// new_node_visitor.visitor_list = data.visitor_list;
|
||||||
|
new_node_visitor.may_access_sensitive_info = data.may_access_sensitive_info;
|
||||||
|
const result = await transactionalEntityManager.save(new_node_visitor);
|
||||||
|
|
||||||
|
await bluebird.each(data.visitor_list, async (item) => {
|
||||||
|
const new_node_other_visitor = new NodeOtherVisitorEntity();
|
||||||
|
new_node_other_visitor.name = item.name;
|
||||||
|
new_node_other_visitor.identity_card_no = item.identity_card_no;
|
||||||
|
new_node_other_visitor.nationality_type = item.nationality_type;
|
||||||
|
new_node_other_visitor.nationality = item.nationality;
|
||||||
|
})
|
||||||
|
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
import { BaseEntity, Column, Entity, Index, JoinColumn, OneToMany, OneToOne } from 'typeorm';
|
||||||
|
import { createHmac } from 'crypto';
|
||||||
|
import { Base } from './common';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
// 访客
|
||||||
|
@Entity({ name: 'node-other-visitor' })
|
||||||
|
export class NodeOtherVisitorEntity extends Base {
|
||||||
|
@ApiProperty({ description: "访客姓名" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客身份证号" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public identity_card_no: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "国籍(中国/其他国籍)" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public nationality_type: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "国籍名称" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public nationality: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "" })
|
||||||
|
@Column({ length: 36, nullable: true, type: 'char' })
|
||||||
|
public node_visitor_id: string;
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
import { BaseEntity, Column, Entity, Index, JoinColumn, OneToMany, OneToOne } from 'typeorm';
|
||||||
|
import { createHmac } from 'crypto';
|
||||||
|
import { Base } from './common';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
// 访客
|
||||||
|
@Entity({ name: 'node-visitor' })
|
||||||
|
export class NodeVisitorEntity extends Base {
|
||||||
|
@ApiProperty({ description: "申请人" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public applicant: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请人部门" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public applicant_department: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请日期" })
|
||||||
|
@Column({ nullable: true, type: 'date' })
|
||||||
|
public apply_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "申请单号" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public code: string;
|
||||||
|
|
||||||
|
// TODO 确定访客类型
|
||||||
|
@ApiProperty({ description: "来访类型" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public visitor_type: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "来访区域" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public area: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "来访单位" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public visitor_unit: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客人数" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public visitor_number: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "交通方式" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public transport: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "车牌号" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public plate_no: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "起始日期" })
|
||||||
|
@Column({ nullable: true, type: 'date' })
|
||||||
|
public start_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "截止日期" })
|
||||||
|
@Column({ nullable: true, type: 'date' })
|
||||||
|
public end_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访人" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public visited_staff: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访部门" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public visited_deparment: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "被访部门" })
|
||||||
|
@Column({ length: 150, nullable: true, type: 'char' })
|
||||||
|
public purpose: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: "携带的电子产品" })
|
||||||
|
@Column({ length: 255, nullable: true, type: 'char' })
|
||||||
|
public electronics: string;
|
||||||
|
|
||||||
|
// @ApiProperty({ description: "访客清单", type: [VisitorList] })
|
||||||
|
// @IsArray()
|
||||||
|
// @IsNotEmpty()
|
||||||
|
// public visitor_list: VisitorList[];
|
||||||
|
|
||||||
|
@ApiProperty({ description: "访客是否有可能接触受控设备" })
|
||||||
|
@Column({ nullable: true })
|
||||||
|
public may_access_sensitive_info: boolean;
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
import { BaseEntity, Column, Entity, Index, JoinColumn, OneToMany, OneToOne } from 'typeorm';
|
||||||
|
import { createHmac } from 'crypto';
|
||||||
|
import { Base } from './common';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
// 访客
|
||||||
|
@Entity({ name: 'visitor' })
|
||||||
|
export class VisitorEntity extends Base {
|
||||||
|
@ApiProperty({ description: '真实姓名' })
|
||||||
|
@Column({ length: 50, nullable: true, type: 'char' })
|
||||||
|
public true_name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '手机号' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public mobile: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '公司' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public company: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '邀请码' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public code: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '邀请码' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public card_code: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '二维码有效时间' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public qrCode?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '事由' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public reason?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '身份证号' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public id_number?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '受访人' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public interviewee?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '楼层' })
|
||||||
|
@Column({ length: 50 })
|
||||||
|
public floor?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '开始日期' })
|
||||||
|
@Column({ type: "date" })
|
||||||
|
public start_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '开始时间' })
|
||||||
|
@Column({ type: "time" })
|
||||||
|
public start_time: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '结束日期' })
|
||||||
|
@Column({ type: "date" })
|
||||||
|
public end_date: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '结束时间' })
|
||||||
|
@Column({ type: "time" })
|
||||||
|
public end_time: string;
|
||||||
|
|
||||||
|
// #[sea_orm(column_type = "Char(Some(36))", nullable)]
|
||||||
|
// pub create_user_id: Option<String>,
|
||||||
|
|
||||||
|
// #[sea_orm(column_type = "DateTime", indexed)]
|
||||||
|
// #[component(value_type = String)]
|
||||||
|
// pub created_date: DateTime<Utc>,
|
||||||
|
|
||||||
|
// #[sea_orm(column_type = "DateTime")]
|
||||||
|
// #[component(value_type = String)]
|
||||||
|
// pub updated_date: DateTime<Utc>,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue