diff --git a/deploy/sql/contracts.sql b/deploy/sql/contracts.sql deleted file mode 100644 index b010e9f..0000000 --- a/deploy/sql/contracts.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE contracts ( - id INT AUTO_INCREMENT PRIMARY KEY , - contract_number VARCHAR(255) COMMENT '合同编号', - title VARCHAR(255) COMMENT '合同标题', - type VARCHAR(255) COMMENT '合同类型', - party_a VARCHAR(255) COMMENT '甲方', - party_b VARCHAR(255) COMMENT '乙方', - signing_date DATE COMMENT '签订日期', - delivery_deadline DATE COMMENT '交付期限', - review_result VARCHAR(255) COMMENT '审核结果', - attachment_url VARCHAR(255) COMMENT '下载附件' -); \ No newline at end of file diff --git a/deploy/sql/vehicle_usage.sql b/deploy/sql/vehicle_usage.sql index 081289b..c5973b2 100644 --- a/deploy/sql/vehicle_usage.sql +++ b/deploy/sql/vehicle_usage.sql @@ -1,8 +1,8 @@ CREATE TABLE vehicle_usage ( id INT AUTO_INCREMENT PRIMARY KEY COMMENT '主键,用于唯一标识每条记录', `year` INT COMMENT '年度', - vehicle_name VARCHAR(255) COMMENT '外出使用的车辆名称', - license_plate VARCHAR(255) COMMENT '车牌号', + vehicle_license VARCHAR(255) COMMENT '车牌号', + VARCHAR(255) COMMENT '外出使用的车辆名称', applicant VARCHAR(255) COMMENT '申请人', driver VARCHAR(255) COMMENT '出行司机', current_mileage FLOAT COMMENT '当前车辆里程数(KM)', diff --git a/src/app.module.ts b/src/app.module.ts index d5484cd..5ee2544 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -25,6 +25,9 @@ import { DatabaseModule } from './shared/database/database.module'; import { SocketModule } from './socket/socket.module'; import { ContractModule } from './modules/contract/contract.module'; +import { VehicleUsageModule } from './modules/vehicle-usage/vehicle-usage.module'; +import { VehicleUsageController } from './modules/vehicle-usage/vehicle-usage.controller'; +import { VehicleUsageService } from './modules/vehicle-usage/vehicle-usage.service'; @Module({ imports: [ @@ -53,7 +56,9 @@ import { ContractModule } from './modules/contract/contract.module'; TodoModule, - ContractModule + ContractModule, + + VehicleUsageModule ], providers: [ { provide: APP_FILTER, useClass: AllExceptionsFilter }, @@ -64,7 +69,9 @@ import { ContractModule } from './modules/contract/contract.module'; { provide: APP_INTERCEPTOR, useClass: IdempotenceInterceptor }, { provide: APP_GUARD, useClass: JwtAuthGuard }, - { provide: APP_GUARD, useClass: RbacGuard } - ] + { provide: APP_GUARD, useClass: RbacGuard }, + VehicleUsageService + ], + controllers: [VehicleUsageController] }) export class AppModule {} diff --git a/src/modules/contract/contract.entity.ts b/src/modules/contract/contract.entity.ts index 108c153..e7cfddf 100644 --- a/src/modules/contract/contract.entity.ts +++ b/src/modules/contract/contract.entity.ts @@ -3,37 +3,42 @@ import { Column, Entity, JoinTable, ManyToMany, Relation } from 'typeorm'; import { CommonEntity } from '~/common/entity/common.entity'; @Entity({ name: 'contract' }) -export class RoleEntity extends CommonEntity { - @Column({ length: 100, unique: true, name: 'contract_number' }) +export class ContractEntity extends CommonEntity { + @Column({ + name: 'contract_number', + type: 'varchar', + length: 255, + unique: true, + comment: '合同编号' + }) @ApiProperty({ description: '合同编号' }) contractNumber: string; - @Column({ length: 255, name: 'title', type: 'varchar' }) + @Column({ name: 'title', type: 'varchar', length: 255, comment: '合同标题' }) @ApiProperty({ description: '合同标题' }) title: string; - @Column() - @ApiProperty({ description: '合同类型', type: 'varchar' }) + @Column({ type: 'int', comment: '合同类型' }) + @ApiProperty({ description: '合同类型' }) type: number; - @Column({ name: 'partyA', length: 255, type: 'varchar' }) + @Column({ name: 'party_a', length: 255, type: 'varchar', comment: '甲方' }) @ApiProperty({ description: '甲方' }) partyA: string; - // @Column({ type: 'tinyint', nullable: true, default: 1 }) - // @ApiProperty({ description: '状态:1启用,0禁用' }) - // status: number + @Column({ name: 'party_b', length: 255, type: 'varchar', comment: '乙方' }) + @ApiProperty({ description: '乙方' }) + partyB: string; - // @Column({ nullable: true }) - // @ApiProperty({ description: '是否默认用户' }) - // default: boolean + @Column({ name: 'signing_date', type: 'date', nullable: true }) + @ApiProperty({ description: '签订日期' }) + signingDate: Date; - // @ApiHideProperty() - // @ManyToMany(() => MenuEntity, menu => menu.roles, {}) - // @JoinTable({ - // name: 'sys_role_menus', - // joinColumn: { name: 'role_id', referencedColumnName: 'id' }, - // inverseJoinColumn: { name: 'menu_id', referencedColumnName: 'id' }, - // }) - // menus: Relation + @Column({ name: 'delivery_deadline', type: 'date', nullable: true }) + @ApiProperty({ description: '交付期限' }) + deliveryDeadline: Date; + + @Column({ name: 'status', type: 'tinyint', default: 0, comment: '审核状态' }) + @ApiProperty({ description: '审核状态:0待审核,1同意,2.不同意' }) + status: number; } diff --git a/src/modules/contract/contract.module.ts b/src/modules/contract/contract.module.ts index ad30ded..46dfda5 100644 --- a/src/modules/contract/contract.module.ts +++ b/src/modules/contract/contract.module.ts @@ -1,8 +1,11 @@ import { Module } from '@nestjs/common'; import { ContractController } from './contract.controller'; import { ContractService } from './contract.service'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { ContractEntity } from './contract.entity'; @Module({ + imports: [TypeOrmModule.forFeature([ContractEntity])], controllers: [ContractController], providers: [ContractService] }) diff --git a/src/modules/vehicle-usage/vehicle-usage.controller.ts b/src/modules/vehicle-usage/vehicle-usage.controller.ts new file mode 100644 index 0000000..9c63da7 --- /dev/null +++ b/src/modules/vehicle-usage/vehicle-usage.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('vehicle-usage') +export class VehicleUsageController {} diff --git a/src/modules/vehicle-usage/vehicle-usage.entity.ts b/src/modules/vehicle-usage/vehicle-usage.entity.ts new file mode 100644 index 0000000..abd1972 --- /dev/null +++ b/src/modules/vehicle-usage/vehicle-usage.entity.ts @@ -0,0 +1,78 @@ +import { ApiHideProperty, ApiProperty } from '@nestjs/swagger'; +import { Column, Entity, JoinTable, ManyToMany, Relation } from 'typeorm'; +import { CommonEntity } from '~/common/entity/common.entity'; + +@Entity({ name: 'vehicle_usage' }) +export class VehicleUsageEntity extends CommonEntity { + @Column({ type: 'int', comment: '年度' }) + @ApiProperty({ description: '年度' }) + year: number; + + @Column({ name: 'vehicle_license', type: 'int', comment: '外出使用的车辆名称' }) + @ApiProperty({ description: '外出使用的车辆名称' }) + vehicleLicense: number; + + @Column({ + name: 'applicant', + type: 'varchar', + length: 50, + comment: '申请人' + }) + @ApiProperty({ description: '申请人' }) + applicant: string; + + @Column({ + name: 'driver', + type: 'varchar', + length: 50, + comment: '出行司机' + }) + @ApiProperty({ description: '出行司机', nullable: true }) + driver: string; + + @Column({ name: 'current_mileage', type: 'int', comment: '当前车辆里程数(KM)', nullable: true }) + @ApiProperty({ description: '当前车辆里程数(KM)' }) + currentMileage: number; + + @Column({ + name: 'expected_start_date', + type: 'date', + nullable: true, + comment: '预计出行开始时间' + }) + @ApiProperty({ description: '预计出行开始时间' }) + expectedStartDate: Date; + + @Column({ name: 'expected_end_date', type: 'date', nullable: true, comment: '预计出行结束时间' }) + @ApiProperty({ description: '预计出行结束时间' }) + expectedEndDate: Date; + + @Column({ name: 'purpose', type: 'varchar', length: 255, comment: '使用事由', nullable: true }) + @ApiProperty({ description: '使用事由' }) + purpose: string; + + @Column({ + name: 'actual_return_time', + type: 'date', + nullable: true, + comment: '实际回司时间' + }) + @ApiProperty({ description: '实际回司时间' }) + actualReturnTime: Date; + + @Column({ name: 'return_mileage', type: 'int', comment: '回城车辆里程数(KM)', nullable: true }) + @ApiProperty({ description: '回城车辆里程数(KM)' }) + returnMileage: number; + + @Column({ name: 'reviewer', type: 'varchar', length: 50, comment: '审核人', nullable: true }) + @ApiProperty({ description: '审核人' }) + reviewer: string; + + @Column({ name: 'status', type: 'tinyint', default: 0, comment: '审核状态' }) + @ApiProperty({ description: '审核状态:0待审核,1同意,2.不同意' }) + status: number; + + @Column({ name: 'remarks', type: 'varchar', length: 255, comment: '备注', nullable: true }) + @ApiProperty({ description: '备注' }) + remarks: string; +} diff --git a/src/modules/vehicle-usage/vehicle-usage.module.ts b/src/modules/vehicle-usage/vehicle-usage.module.ts new file mode 100644 index 0000000..d50dfc1 --- /dev/null +++ b/src/modules/vehicle-usage/vehicle-usage.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { VehicleUsageService } from './vehicle-usage.service'; +import { VehicleUsageController } from './vehicle-usage.controller'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { VehicleUsageEntity } from './vehicle-usage.entity'; + +@Module({ + imports: [TypeOrmModule.forFeature([VehicleUsageEntity])], + providers: [VehicleUsageService], + controllers: [VehicleUsageController] +}) +export class VehicleUsageModule {} diff --git a/src/modules/vehicle-usage/vehicle-usage.service.ts b/src/modules/vehicle-usage/vehicle-usage.service.ts new file mode 100644 index 0000000..0ec15a1 --- /dev/null +++ b/src/modules/vehicle-usage/vehicle-usage.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class VehicleUsageService {}