修改类型

main
rustdreamer 3 years ago
parent a83daf9a92
commit c5b340c21d

@ -30,6 +30,11 @@ export class VisitorList {
@IsNotEmpty() @IsNotEmpty()
public identity_card_no: string; public identity_card_no: string;
@ApiProperty({ description: "证件类型" })
@IsString()
@IsNotEmpty()
public id_type: string;
@ApiProperty({ description: "国籍(中国/其他国籍)" }) @ApiProperty({ description: "国籍(中国/其他国籍)" })
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
@ -133,7 +138,7 @@ export class CreateVisitor {
@ApiProperty({ description: "访客是否有可能接触受控设备" }) @ApiProperty({ description: "访客是否有可能接触受控设备" })
@IsBoolean() @IsBoolean()
@IsNotEmpty() @IsNotEmpty()
public may_access_sensitive_info: boolean; public may_access_sensitive_info: string;
} }
export class QueryVisitorDto extends CommonPageArgs { export class QueryVisitorDto extends CommonPageArgs {
@ -146,6 +151,16 @@ export class QueryVisitorDto extends CommonPageArgs {
@IsString() @IsString()
@IsOptional() @IsOptional()
search?: string search?: string
@ApiPropertyOptional({ description: "", required: false })
@IsString()
@IsOptional()
start_date?: string
@ApiPropertyOptional({ description: "", required: false })
@IsString()
@IsOptional()
end_date?: string
} }
@Controller() @Controller()
@ -186,8 +201,8 @@ export class AppController {
@Get("/visitors") @Get("/visitors")
@ApiBearerAuth() @ApiBearerAuth()
async get(@Query() query: QueryVisitorDto, @Req() req: any) { async get(@Query() query_data: QueryVisitorDto, @Req() req: any) {
console.log("req", req.headers) // console.log("req", req.headers)
if (!req.headers.authorization) { if (!req.headers.authorization) {
throw new BadRequestException("无权限") throw new BadRequestException("无权限")
} }
@ -203,18 +218,47 @@ export class AppController {
// console.log(e) // console.log(e)
throw new BadRequestException("无权限, 请联系管理员") throw new BadRequestException("无权限, 请联系管理员")
} }
const [list, count] = await this.nodeVisitorRepository.findAndCount({ const where: any = {};
skip: query.skip, if (query_data.start_date) {
take: query.take, where.start_date = query_data.start_date
order: {
created_date: "DESC"
} }
}) if (query_data.end_date) {
where.end_date = query_data.end_date
}
const query = this.nodeVisitorRepository.createQueryBuilder('node-visitor');
query.where(where);
// if (organization_name) {
// query
// .leftJoin(OrganizationEntity, 'organization', `organization.id = bill.organization_id`)
// .andWhere(`organization.full_name like "%${organization_name}%"`)
// }
if (query_data.search) {
const string = `%${query_data.search}%`;
const fields = ['applicant', 'applicant_department', 'code', 'visitor_unit', 'plate_no', 'visited_staff', 'visited_department'];
const searchString = fields.join(' like :search OR node-visitor.');
query.where(`node-visitor.${searchString} like :search`, {
search: string,
});
}
const order_key = 'node-visitor.created_date';
let order_value: any = 'DESC';
const [list, count] = await query
.skip(query_data.skip)
.take(query_data.take)
.orderBy(order_key, order_value)
.getManyAndCount();
// const [list, count] = await this.nodeVisitorRepository.findAndCount({
// skip: query.skip,
// take: query.take,
// order: {
// created_date: "DESC"
// }
// })
const new_list = await bluebird.map(list, async (item) => { const new_list = await bluebird.map(list, async (item) => {
const visitor_list = await this.nodeOtherVisitorRepository.find({ const visitor_list = await this.nodeOtherVisitorRepository.find({
where: { node_visitor_id: item.id }, where: { node_visitor_id: item.id },
order: { order: {
created_date: "ASC" created_date: "DESC"
} }
}) })
return { return {
@ -270,6 +314,7 @@ export class AppController {
new_node_other_visitor.nationality_type = item.nationality_type; new_node_other_visitor.nationality_type = item.nationality_type;
new_node_other_visitor.nationality = item.nationality; new_node_other_visitor.nationality = item.nationality;
new_node_other_visitor.node_visitor_id = result.id; new_node_other_visitor.node_visitor_id = result.id;
new_node_other_visitor.id_type = item.id_type;
await transactionalEntityManager.save(new_node_other_visitor); await transactionalEntityManager.save(new_node_other_visitor);
}) })

@ -14,6 +14,10 @@ export class NodeOtherVisitorEntity extends Base {
@Column({ length: 150, nullable: true, type: 'char' }) @Column({ length: 150, nullable: true, type: 'char' })
public identity_card_no: string; public identity_card_no: string;
@ApiProperty({ description: "证件类型" })
@Column({ length: 150, nullable: true, type: 'char' })
public id_type: string;
@ApiProperty({ description: "国籍(中国/其他国籍)" }) @ApiProperty({ description: "国籍(中国/其他国籍)" })
@Column({ length: 150, nullable: true, type: 'char' }) @Column({ length: 150, nullable: true, type: 'char' })
public nationality_type: string; public nationality_type: string;

@ -63,7 +63,7 @@ export class NodeVisitorEntity extends Base {
@Column({ length: 150, nullable: true, type: 'char' }) @Column({ length: 150, nullable: true, type: 'char' })
public visited_department: string; public visited_department: string;
@ApiProperty({ description: "被访部门" }) @ApiProperty({ description: "" })
@Column({ length: 150, nullable: true, type: 'char' }) @Column({ length: 150, nullable: true, type: 'char' })
public purpose: string; public purpose: string;
@ -78,5 +78,5 @@ export class NodeVisitorEntity extends Base {
@ApiProperty({ description: "访客是否有可能接触受控设备" }) @ApiProperty({ description: "访客是否有可能接触受控设备" })
@Column({ nullable: true }) @Column({ nullable: true })
public may_access_sensitive_info: boolean; public may_access_sensitive_info: string;
} }

Loading…
Cancel
Save