_geo.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import { MockRequest } from '@delon/mock';
  17. const DATA = [
  18. {
  19. name: '上海',
  20. id: '310000',
  21. },
  22. {
  23. name: '市辖区',
  24. id: '310100',
  25. },
  26. {
  27. name: '北京',
  28. id: '110000',
  29. },
  30. {
  31. name: '市辖区',
  32. id: '110100',
  33. },
  34. {
  35. name: '浙江省',
  36. id: '330000',
  37. },
  38. {
  39. name: '杭州市',
  40. id: '330100',
  41. },
  42. {
  43. name: '宁波市',
  44. id: '330200',
  45. },
  46. {
  47. name: '温州市',
  48. id: '330300',
  49. },
  50. {
  51. name: '嘉兴市',
  52. id: '330400',
  53. },
  54. {
  55. name: '湖州市',
  56. id: '330500',
  57. },
  58. {
  59. name: '绍兴市',
  60. id: '330600',
  61. },
  62. {
  63. name: '金华市',
  64. id: '330700',
  65. },
  66. {
  67. name: '衢州市',
  68. id: '330800',
  69. },
  70. {
  71. name: '舟山市',
  72. id: '330900',
  73. },
  74. {
  75. name: '台州市',
  76. id: '331000',
  77. },
  78. {
  79. name: '丽水市',
  80. id: '331100',
  81. },
  82. ];
  83. export const GEOS = {
  84. '/geo/province': () => DATA.filter(w => w.id.endsWith('0000')),
  85. '/geo/:id': (req: MockRequest) => {
  86. const pid = (req.params.id || '310000').slice(0, 2);
  87. return DATA.filter(w => w.id.slice(0, 2) === pid && !w.id.endsWith('0000'));
  88. },
  89. };