| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | 'use strict';/** * * * @author Mai * @date * @version */module.exports = app => {    class GlobalLog extends app.BaseService {        /**         * 构造函数         *         * @param {Object} ctx - egg全局变量         * @return {void}         */        constructor(ctx) {            super(ctx);            this.tableName = 'global_log';        }        async requestLog() {            if (!this.ctx.session || !this.ctx.session.sessionProject || !this.ctx.session.sessionUser) return;            await this.db.insert(this.tableName, {                id: this.ctx.logId,                project_id: this.ctx.session.sessionProject.id,                project_code: this.ctx.session.sessionProject.code,                user_id: this.ctx.session.sessionUser.accountId,                user_name: this.ctx.session.sessionUser.name,                url: this.ctx.url,                method: this.ctx.method,            });        }        async responseLog(runTime){            if (!this.ctx.session || !this.ctx.session.sessionProject || !this.ctx.session.sessionUser) return;            await this.defaultUpdate({ id: this.ctx.logId, is_response: 1, run_time: runTime });        }    }    return GlobalLog;};
 |