feat: 合同管理及车辆使用管理初始化

This commit is contained in:
louis 2024-02-29 09:56:03 +08:00
parent 88a97ee162
commit f402438a5a
9 changed files with 138 additions and 37 deletions

View File

@ -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 '下载附件'
);

View File

@ -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)',

View File

@ -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 {}

View File

@ -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<MenuEntity[]>
@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;
}

View File

@ -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]
})

View File

@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('vehicle-usage')
export class VehicleUsageController {}

View File

@ -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;
}

View File

@ -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 {}

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class VehicleUsageService {}