feat: 根据名称搜索位置接口
This commit is contained in:
parent
dd3423bfd3
commit
4267adf8f5
@ -20,6 +20,7 @@ import { RolesGuard } from './common/role.guard';
|
||||
import { UserModule } from './user/user.module';
|
||||
import { User } from './user/entities/user.entity';
|
||||
import { TdtmapModule } from './tdtmap/tdtmap.module';
|
||||
import { TdtLocal } from './tdtmap/entities/tdtmap.entity';
|
||||
|
||||
// 使用sqlite和程序内缓存时,全部程序不依赖外部组件
|
||||
// 注意:Webpack打包不适用Sqlite!
|
||||
@ -30,7 +31,7 @@ const enableSqlite:boolean = false
|
||||
enableSqlite ? TypeOrmModule.forRoot({
|
||||
type: 'better-sqlite3',
|
||||
database: 'db.sql',
|
||||
entities: [User],
|
||||
entities: [User, TdtLocal],
|
||||
synchronize: !IS_PROD
|
||||
}) : TypeOrmModule.forRoot({
|
||||
type: 'mysql',
|
||||
@ -39,7 +40,7 @@ const enableSqlite:boolean = false
|
||||
username: MYSQL_USER,
|
||||
password: MYSQL_PASSWD,
|
||||
database: MYSQL_DATABASE,
|
||||
entities: [User],
|
||||
entities: [User, TdtLocal],
|
||||
synchronize: !IS_PROD
|
||||
}),
|
||||
CacheModule.register({
|
||||
|
@ -42,6 +42,39 @@ export class TdtmapController {
|
||||
this.logger.debug(`bloomFilter inited => minio obj num: ${minioObjNamesArr.length}`)
|
||||
}
|
||||
|
||||
@Get("/search")
|
||||
async search(
|
||||
@Query('keyWord') keyWord:string,
|
||||
@Query('tk') tk:string = '6988fa4ec7ca5ed400097b9bf9dfc22e'
|
||||
) {
|
||||
const res = await axios({
|
||||
url: "https://api.tianditu.gov.cn/v2/search",
|
||||
params: {
|
||||
type: 'query',
|
||||
postStr: JSON.stringify({
|
||||
yingjiType: 1,
|
||||
sourceType: 0,
|
||||
keyWord,
|
||||
level: 18,
|
||||
mapBound: '73.66, 3.86, 135.05, 53.55',
|
||||
queryType: '4',
|
||||
start: 0,
|
||||
count: 10,
|
||||
queryTerminal: 10000
|
||||
}),
|
||||
tk
|
||||
},
|
||||
method: "GET",
|
||||
responseType: "arraybuffer"
|
||||
}).catch((err) => {
|
||||
this.logger.error(`Tile req Fail => ${err}`)
|
||||
})
|
||||
|
||||
if (!res) return;
|
||||
const { suggests } = JSON.parse(res.data);
|
||||
return Array.isArray(suggests) ? suggests : [];
|
||||
}
|
||||
|
||||
@Get("/tile")
|
||||
async getTile(
|
||||
@Res({ passthrough: true }) response:Response,
|
||||
|
@ -1,8 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TdtmapService } from './tdtmap.service';
|
||||
import { TdtmapController } from './tdtmap.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { TdtLocal } from './entities/tdtmap.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([TdtLocal])
|
||||
],
|
||||
controllers: [TdtmapController],
|
||||
providers: [TdtmapService],
|
||||
})
|
||||
|
@ -1,11 +1,17 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import * as Minio from 'minio';
|
||||
import { TdtLocal } from './entities/tdtmap.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class TdtmapService {
|
||||
private readonly minioClient: Minio.Client;
|
||||
private readonly logger: Logger = new Logger(TdtmapService.name)
|
||||
constructor() {
|
||||
constructor(
|
||||
@InjectRepository(TdtLocal)
|
||||
private readonly tdtLocalRepository: Repository<TdtLocal>
|
||||
) {
|
||||
this.minioClient = new Minio.Client({
|
||||
endPoint: '117.73.12.97',
|
||||
port: 9000,
|
||||
@ -17,6 +23,14 @@ export class TdtmapService {
|
||||
|
||||
setMinioObj() {}
|
||||
|
||||
getTdtLocalArr(keyword:string, pageSize:number, pageNum:number) {
|
||||
// return this.tdtLocalRepository.find()
|
||||
}
|
||||
|
||||
setTdtLocal(tdtLocalEntitys:TdtLocal[]) {
|
||||
return this.tdtLocalRepository.save(tdtLocalEntitys);
|
||||
}
|
||||
|
||||
async getTilesNameList():Promise<string[]> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const stream = await this.minioClient.listObjectsV2("nestfiles");
|
||||
|
Loading…
Reference in New Issue
Block a user