log.js 725 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/6/8
  7. * @version
  8. */
  9. module.exports = app => {
  10. class Log extends app.BaseService {
  11. /**
  12. * 构造函数
  13. *
  14. * @param {Object} ctx - egg全局context
  15. * @return {void}
  16. */
  17. constructor(ctx) {
  18. super(ctx);
  19. this.tableName = 'log';
  20. }
  21. async addLog(operation, time) {
  22. console.log(time);
  23. try {
  24. await this.db.insert(this.tableName, {
  25. operation: operation,
  26. time: time,
  27. });
  28. } catch (err) {
  29. console.log(err);
  30. }
  31. }
  32. };
  33. return Log;
  34. };