statistic.js 675 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. import AddressComponent from '../prototype/addressComponent'
  3. import StatisModel from '../models/statis/statis'
  4. import dtime from 'time-formater'
  5. class Statistic extends AddressComponent {
  6. constructor(){
  7. super()
  8. this.apiRecord = this.apiRecord.bind(this)
  9. }
  10. async apiRecord(req, res, next){
  11. try{
  12. // const address = await this.guessPosition(req);
  13. const statis_id = await this.getId('statis_id')
  14. const apiInfo = {
  15. date: dtime().format('YYYY-MM-DD'),
  16. origin: req.headers.origin,
  17. id: statis_id,
  18. }
  19. StatisModel.create(apiInfo)
  20. }catch(err){
  21. console.log('API记录出错', err);
  22. }
  23. next()
  24. }
  25. }
  26. export default new Statistic()