global.js 466 B

1234567891011121314151617181920212223242526
  1. /**
  2. * this file will be loaded before server started
  3. * you can define global functions used in controllers, models, templates
  4. */
  5. /**
  6. * use global.xxx to define global functions
  7. *
  8. * global.fn1 = function(){
  9. *
  10. * }
  11. */
  12. const _ = require('lodash');
  13. /**
  14. * 获取当前的时间戳(秒数)
  15. * @returns {Number}
  16. */
  17. global.getTime = function () {
  18. return _.parseInt(_.now() / 1000);
  19. };
  20. global.getLoginUserId = function () {
  21. return think.userId
  22. };