12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 'use strict';
- const Service = require('egg').Service;
- class MapService extends Service {
-
- async points( adcode )
- {
- if( adcode == undefined || adcode == "") return [];
- let mysql = this.app.mysql;
- let ret = await mysql.query("select id, name, longitude, latitude from area where parent_id in (select id from area where parent_id=?) or id in (select id from area where parent_id=?)", [adcode, adcode]);
- return {list:ret};
- }
-
- async search( query ) {
- let adcode = query.adcode;
- if( !adcode ) return { list:[] };
- let name = query.name;
- let where = name? `and name like '%${name}%'`:"";
- let mysql = this.app.mysql;
- let ret = await mysql.query(`select id, name, longitude, latitude from area where (parent_id in (select id from area where parent_id=?) or id in (select id from area where parent_id=?) ${where})`, [adcode, adcode]);
- return {list:ret};
- }
- /**
- *
- * @param {更新航线配置} data
- * data.id 任务id
- * data.config = '{
- * lines=[
- * [{lon,lat}],
- * []
- * ]
- * }'
- */
- async updateNaviConfig(data) {
- let id = data.id;
- if( !id ) throw "任务ID为空";
- let config = data.config?data.config:"";
- let mysql = this.app.mysql;
- let ret = await mysql.query(`update train_records set navi_config='${config}' where id=${id}`);
- return ret;
- }
- }
- module.exports = MapService;
|