|
@@ -16,6 +16,35 @@ class InterceptService extends CrudService {
|
|
|
this.httpUtil = this.ctx.service.util.httpUtil;
|
|
|
}
|
|
|
|
|
|
+ async freeWebCount() {
|
|
|
+ const record = {};
|
|
|
+ record.ip = _.get(this.ctx.request, 'header.x-real-ip');
|
|
|
+ record.route = 'http://free.waityou24.cn/';
|
|
|
+ const today = moment().format('YYYY-MM-DD');
|
|
|
+ const _tenant = 'freeWeb';
|
|
|
+ const todayData = await this.hits.findOne({ date: today, _tenant });
|
|
|
+ if (todayData) {
|
|
|
+ todayData.record.push(record);
|
|
|
+ await todayData.save();
|
|
|
+ } else {
|
|
|
+ const obj = { date: today, _tenant, record };
|
|
|
+ await this.hits.create(obj);
|
|
|
+ }
|
|
|
+ let res = await this.hits.aggregate([
|
|
|
+ { $match: { _tenant } },
|
|
|
+ { $unwind: '$record' },
|
|
|
+ { $group: {
|
|
|
+ _id: '$_tenant',
|
|
|
+ sum: { $sum: 1 },
|
|
|
+ } },
|
|
|
+ ]);
|
|
|
+ if (res && _.isArray(res)) {
|
|
|
+ res = _.get(_.head(res), 'sum', 0);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
async getDeal() {
|
|
|
await this.count();
|
|
|
const url = this.ctx.request.url.replace('/site', '');
|