|
|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
import { Body, Controller, Get, Post } from '@nestjs/common';
|
|
|
|
|
import { BadRequestException, Body, Controller, Get, Post } from '@nestjs/common';
|
|
|
|
|
import { AppService } from './app.service';
|
|
|
|
|
import * as fs from 'fs';
|
|
|
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
|
import { IsArray, IsBoolean, IsDateString, IsNotEmpty, IsString } from 'class-validator';
|
|
|
|
|
import { IsArray, IsBoolean, IsDate, IsDateString, IsNotEmpty, IsString } from 'class-validator';
|
|
|
|
|
import { NodeVisitorEntity } from './node-visitor.entity';
|
|
|
|
|
import { DataSource } from 'typeorm';
|
|
|
|
|
import * as bluebird from 'bluebird';
|
|
|
|
|
@ -165,12 +165,21 @@ export class AppController {
|
|
|
|
|
|
|
|
|
|
@Post("/visitor")
|
|
|
|
|
async create(@Body() data: CreateVisitor) {
|
|
|
|
|
if (new Date(data.apply_date).toString() == "Invalid Date") {
|
|
|
|
|
throw new BadRequestException("apply_date 格式不正确")
|
|
|
|
|
}
|
|
|
|
|
if (new Date(data.start_date).toString() == "Invalid Date") {
|
|
|
|
|
throw new BadRequestException("start_date 格式不正确")
|
|
|
|
|
}
|
|
|
|
|
if (new Date(data.end_date).toString() == "Invalid Date") {
|
|
|
|
|
throw new BadRequestException("end_date 格式不正确")
|
|
|
|
|
}
|
|
|
|
|
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.apply_date = new Date(data.apply_date).toLocaleDateString();
|
|
|
|
|
new_node_visitor.code = data.code;
|
|
|
|
|
new_node_visitor.visitor_type = data.visitor_type;
|
|
|
|
|
new_node_visitor.area = data.area;
|
|
|
|
|
@ -178,8 +187,8 @@ export class AppController {
|
|
|
|
|
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.start_date = new Date(data.start_date).toLocaleDateString();
|
|
|
|
|
new_node_visitor.end_date = new Date(data.end_date).toLocaleDateString();
|
|
|
|
|
new_node_visitor.visited_staff = data.visited_staff;
|
|
|
|
|
new_node_visitor.visited_deparment = data.visited_deparment;
|
|
|
|
|
new_node_visitor.purpose = data.purpose;
|
|
|
|
|
@ -196,7 +205,7 @@ export class AppController {
|
|
|
|
|
new_node_other_visitor.nationality = item.nationality;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
return { statusCode: 201, data: result };
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|