cities.js 585 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. import Cities from '../../models/v1/cities';
  3. class CityHandle {
  4. constructor(){
  5. }
  6. async cityGuess(req, res, next){
  7. const type = req.query.type;
  8. if (!type) {
  9. res.json({
  10. name: 'ERROR_QUERY_TYPE',
  11. message: '参数错误',
  12. })
  13. return
  14. }
  15. let cityInfo;
  16. switch (type){
  17. case 'guess':
  18. cityInfo = await Cities.cityGuess('shanghai');
  19. break;
  20. case 'hot':
  21. cityInfo = await Cities.cityHot();
  22. break;
  23. case 'group':
  24. cityInfo = await Cities.cityGroup();
  25. break;
  26. }
  27. res.send(cityInfo)
  28. }
  29. }
  30. export default new CityHandle()