'use strict'; const Service = require('egg').Service; // redis服务 class RedisService extends Service { async hget(vin, filed) { let data; if (this.app.redis) { // data = await this.app.redis.hget('faw:iov:fsm:broker:TEST0000000076257', 'SERIES_CODE'); data = await this.app.redis.hget(`faw:iov:fsm:broker:${vin}`, filed); } return data; } async keys() { let data; if (this.app.redis) { data = await this.app.redis.keys('faw:iov:fsm:broker:*'); } return data; } async getAddress(longitude, latitude) { const { ctx } = this; const result = await ctx.curl( `${this.app.config.GDAPI}?key=${this.app.config.GDKEY}&location=${longitude},${latitude}`); let address = ''; if (result.status == 200) { const data = JSON.parse(result.data); if (data.status == '1') { address = data.regeocode.formatted_address; } } return address; } } module.exports = RedisService;