async test() { this.ctx.locals.test.localsCheckAny(); this.app.config.keys.configKeysCheckAny(); this.app.appCheckAny(); }
async test() { this.ctx.logger.info(this.app.config.keys); await this.ctx.service.test(); await this.service.myserv.test(); }
test() { this.logger.info(this.ctx); this.logger.info(this.app.config.keys); this.logger.info(this.ctx.curl('http://127.0.0.1', { method: 'GET' })); }
async test() { this.ctx.locals.test.serviceLocalCheckAny(); this.app.config.keys.serviceConfigCheckAny(); this.app.serviceAppCheckAny(); }
async test() { this.ctx.logger.info(this.app.config.keys); await this.app.controller.myctrl.test(); }
// 定时执行每分钟的数据 async getWebPvUvIpByMinute() { const interval = parser.parseExpression(this.app.config.pvuvip_task_minute_time); const endTime = new Date(interval.prev().toString()); const beginTime = new Date(interval.prev().toString()); const query = { create_time: { $gte: beginTime, $lt: endTime } }; const datas = await this.ctx.model.System.distinct('app_id', { type: 'web' }).read('sp').exec(); this.groupData(datas, 1, query, endTime); }
// 获得用户列表 async getUserList() { const { ctx } = this; const query = ctx.request.body; const pageNo = query.pageNo; const pageSize = query.pageSize || this.app.config.pageSize; const userName = query.userName; const result = await ctx.service.user.getUserList(pageNo, pageSize, userName); ctx.body = this.app.result({ data: result, }); }
// 保存城市信息到文件中 saveIpDatasInFile(copyip, json) { if (this.cacheArr.includes(copyip)) return; this.cacheArr.push(copyip); const filepath = path.resolve(__dirname, `../../cache/${this.app.config.ip_city_cache_file.wx}`); const str = `"${copyip}":${JSON.stringify(json)},`; fs.appendFile(filepath, str, { encoding: 'utf8' }, () => { }); }
constructor(params) { super(params); this.cacheJson = {}; this.cacheIpJson = {}; this.cacheArr = []; // kafka 消费池限制 this.kafkalist = []; this.kafkaConfig = this.app.config.kafka; this.kafkatotal = this.kafkaConfig.total_limit_wx; // 缓存一次ip地址库信息 this.ipCityFileCache(); }
// 收集每日日报数据 async getDaliyDatas(data, type) { const config = this.app.config.email.client; if (!((config.host && config.port && typeof (config.secure) === 'boolean') || config.service) || !config.auth) return; if (!data.appId) return; if (!this.daliy[data.appId]) this.daliy[data.appId] = { pvuvip: null, toplist: null }; this.daliy[data.appId][type] = data; if (this.daliy[data.appId].pvuvip && this.daliy[data.appId].toplist) { this.sendDaliyEmail(); } }
// 通过redis 消费者模式存储数据 async saveWxReportDataForRedis(query) { try { if (this.app.config.redis_consumption.total_limit_wx) { // 限流 const length = await this.app.redis.llen('wx_repore_datas'); if (length >= this.app.config.redis_consumption.total_limit_wx) return; } this.app.redis.lpush('wx_repore_datas', JSON.stringify(query)); } catch (e) { console.log(e); } }
// 把redis消费数据经过加工之后同步到db3中 的定时任务(从redis中拉取数据) async saveWebReportDatasForRedis() { // 线程遍历 const onecount = this.app.config.redis_consumption.thread_web; for (let i = 0; i < onecount; i++) { this.getWebItemDataForRedis(); } }
// 把redis消费数据经过加工之后同步到db3中 的定时任务(从redis中拉取数据) async saveWxReportDatasForRedis() { // 线程遍历 const onecount = this.app.config.redis_consumption.thread_wx; for (let i = 0; i < onecount; i++) { this.getWebItemDataForRedis(); } }
// 定时执行每分钟的数据 async getWxPvUvIpByMinute() { const interval = parser.parseExpression(this.app.config.pvuvip_task_minute_time); const endTime = new Date(interval.prev().toString()); const beginTime = new Date(interval.prev().toString()); const query = { create_time: { $gte: beginTime, $lt: endTime } }; const datas = await this.ctx.model.System.distinct('app_id', { type: 'wx' }).read('sp').exec(); this.groupData(datas, 1, query, endTime); }