feat: 完善智慧停车综合管理平台源码
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity()
|
||||
export class MapConfig {
|
||||
@PrimaryGeneratedColumn({ type: 'int' })
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
layerType: 'imageOverlay' | 'tileLayer';
|
||||
|
||||
@Column()
|
||||
layerUrlOrPath: string;
|
||||
|
||||
@Column({
|
||||
type: 'json',
|
||||
nullable: true,
|
||||
})
|
||||
imageLayerBounds?: [[number, number], [number, number]];
|
||||
|
||||
@Column({ type: 'json' })
|
||||
mapCenter: [number, number];
|
||||
|
||||
@Column({ type: 'int' })
|
||||
mapZoom: number;
|
||||
|
||||
@Column({ type: 'int', default: 0 })
|
||||
minZoom: number;
|
||||
|
||||
@Column({ type: 'int', default: 18 })
|
||||
maxZoom: number;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@DeleteDateColumn()
|
||||
deletedAt: Date;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { MapConfigService } from './map-config.service';
|
||||
|
||||
describe('MapConfigService', () => {
|
||||
let service: MapConfigService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [MapConfigService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<MapConfigService>(MapConfigService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Repository } from 'typeorm';
|
||||
import { MapConfig } from './map-config.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class MapConfigService {
|
||||
constructor(
|
||||
@InjectRepository(MapConfig) private mapConfigRepo: Repository<MapConfig>,
|
||||
) {}
|
||||
|
||||
async getLatestConfig(): Promise<MapConfig | null> {
|
||||
return (
|
||||
await this.mapConfigRepo.find({
|
||||
order: { id: 'DESC' },
|
||||
take: 1,
|
||||
})
|
||||
)?.[0];
|
||||
}
|
||||
|
||||
async updateConfig(config: Partial<MapConfig>) {
|
||||
await this.mapConfigRepo.save(config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user