@etsoo/smarterp-core 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicApi = void 0;
4
4
  const shared_1 = require("@etsoo/shared");
5
+ const PlaceQueryRQ_1 = require("./rq/public/PlaceQueryRQ");
5
6
  const appscript_1 = require("@etsoo/appscript");
6
7
  const unitPrefix = "unit";
7
8
  /**
@@ -154,8 +155,32 @@ class PublicApi extends appscript_1.BaseApi {
154
155
  * @param payload Payload
155
156
  * @returns Result
156
157
  */
157
- queryPlace(rq, payload) {
158
- return this.api.post("Public/QueryPlace", rq, payload);
158
+ async queryPlace(rq, payload) {
159
+ // For simplified Chinese, or CN region, use China map
160
+ if (rq.provider === null &&
161
+ (rq.language === "zh-Hans" ||
162
+ rq.language === "zh-CN" ||
163
+ rq.region === "CN")) {
164
+ // Amap first
165
+ const amapRq = {
166
+ ...rq,
167
+ region: undefined,
168
+ provider: PlaceQueryRQ_1.ApiProvider.Amap
169
+ };
170
+ const amapResult = await this.api.post("Public/QueryPlace", amapRq, payload);
171
+ if (amapResult && amapResult.length > 0)
172
+ return amapResult;
173
+ // Baidu
174
+ const baiduRq = {
175
+ ...rq,
176
+ region: undefined,
177
+ provider: PlaceQueryRQ_1.ApiProvider.Baidu
178
+ };
179
+ const baiduResult = await this.api.post("Public/QueryPlace", baiduRq, payload);
180
+ if (baiduResult && baiduResult.length > 0)
181
+ return baiduResult;
182
+ }
183
+ return await this.api.post("Public/QueryPlace", rq, payload);
159
184
  }
160
185
  /**
161
186
  * Read member invitation
@@ -12,8 +12,21 @@ export declare enum ApiOutput {
12
12
  * 接口供应商
13
13
  */
14
14
  export declare enum ApiProvider {
15
+ /**
16
+ * Google Maps
17
+ * 谷歌地图
18
+ */
15
19
  Google = 0,
16
- Baidu = 1
20
+ /**
21
+ * Baidu Maps
22
+ * 百度地图
23
+ */
24
+ Baidu = 1,
25
+ /**
26
+ * Amap
27
+ * 高德地图
28
+ */
29
+ Amap = 2
17
30
  }
18
31
  /**
19
32
  * Place query request
@@ -16,6 +16,19 @@ var ApiOutput;
16
16
  */
17
17
  var ApiProvider;
18
18
  (function (ApiProvider) {
19
+ /**
20
+ * Google Maps
21
+ * 谷歌地图
22
+ */
19
23
  ApiProvider[ApiProvider["Google"] = 0] = "Google";
24
+ /**
25
+ * Baidu Maps
26
+ * 百度地图
27
+ */
20
28
  ApiProvider[ApiProvider["Baidu"] = 1] = "Baidu";
29
+ /**
30
+ * Amap
31
+ * 高德地图
32
+ */
33
+ ApiProvider[ApiProvider["Amap"] = 2] = "Amap";
21
34
  })(ApiProvider || (exports.ApiProvider = ApiProvider = {}));
@@ -1,4 +1,5 @@
1
1
  import { DataTypes } from "@etsoo/shared";
2
+ import { ApiProvider } from "./rq/public/PlaceQueryRQ";
2
3
  import { BaseApi, ProductUnit, RepeatOption } from "@etsoo/appscript";
3
4
  const unitPrefix = "unit";
4
5
  /**
@@ -151,8 +152,32 @@ export class PublicApi extends BaseApi {
151
152
  * @param payload Payload
152
153
  * @returns Result
153
154
  */
154
- queryPlace(rq, payload) {
155
- return this.api.post("Public/QueryPlace", rq, payload);
155
+ async queryPlace(rq, payload) {
156
+ // For simplified Chinese, or CN region, use China map
157
+ if (rq.provider === null &&
158
+ (rq.language === "zh-Hans" ||
159
+ rq.language === "zh-CN" ||
160
+ rq.region === "CN")) {
161
+ // Amap first
162
+ const amapRq = {
163
+ ...rq,
164
+ region: undefined,
165
+ provider: ApiProvider.Amap
166
+ };
167
+ const amapResult = await this.api.post("Public/QueryPlace", amapRq, payload);
168
+ if (amapResult && amapResult.length > 0)
169
+ return amapResult;
170
+ // Baidu
171
+ const baiduRq = {
172
+ ...rq,
173
+ region: undefined,
174
+ provider: ApiProvider.Baidu
175
+ };
176
+ const baiduResult = await this.api.post("Public/QueryPlace", baiduRq, payload);
177
+ if (baiduResult && baiduResult.length > 0)
178
+ return baiduResult;
179
+ }
180
+ return await this.api.post("Public/QueryPlace", rq, payload);
156
181
  }
157
182
  /**
158
183
  * Read member invitation
@@ -12,8 +12,21 @@ export declare enum ApiOutput {
12
12
  * 接口供应商
13
13
  */
14
14
  export declare enum ApiProvider {
15
+ /**
16
+ * Google Maps
17
+ * 谷歌地图
18
+ */
15
19
  Google = 0,
16
- Baidu = 1
20
+ /**
21
+ * Baidu Maps
22
+ * 百度地图
23
+ */
24
+ Baidu = 1,
25
+ /**
26
+ * Amap
27
+ * 高德地图
28
+ */
29
+ Amap = 2
17
30
  }
18
31
  /**
19
32
  * Place query request
@@ -13,6 +13,19 @@ export var ApiOutput;
13
13
  */
14
14
  export var ApiProvider;
15
15
  (function (ApiProvider) {
16
+ /**
17
+ * Google Maps
18
+ * 谷歌地图
19
+ */
16
20
  ApiProvider[ApiProvider["Google"] = 0] = "Google";
21
+ /**
22
+ * Baidu Maps
23
+ * 百度地图
24
+ */
17
25
  ApiProvider[ApiProvider["Baidu"] = 1] = "Baidu";
26
+ /**
27
+ * Amap
28
+ * 高德地图
29
+ */
30
+ ApiProvider[ApiProvider["Amap"] = 2] = "Amap";
18
31
  })(ApiProvider || (ApiProvider = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/smarterp-core",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "TypeScript APIs for SmartERP Core",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
package/src/PublicApi.ts CHANGED
@@ -4,7 +4,7 @@ import { PinyinRQ } from "./rq/public/PinyinRQ";
4
4
  import { CreateBarcodeRQ } from "./rq/public/CreateBarcodeRQ";
5
5
  import { CurrencyItem } from "./dto/public/CurrencyItem";
6
6
  import { RegionData } from "./dto/public/RegionData";
7
- import { PlaceQueryRQ } from "./rq/public/PlaceQueryRQ";
7
+ import { ApiProvider, PlaceQueryRQ } from "./rq/public/PlaceQueryRQ";
8
8
  import { PlaceCommon } from "./dto/public/PlaceCommon";
9
9
  import {
10
10
  BaseApi,
@@ -192,8 +192,46 @@ export class PublicApi extends BaseApi {
192
192
  * @param payload Payload
193
193
  * @returns Result
194
194
  */
195
- queryPlace(rq: PlaceQueryRQ, payload?: IApiPayload<PlaceCommon[]>) {
196
- return this.api.post("Public/QueryPlace", rq, payload);
195
+ async queryPlace(rq: PlaceQueryRQ, payload?: IApiPayload<PlaceCommon[]>) {
196
+ // For simplified Chinese, or CN region, use China map
197
+ if (
198
+ rq.provider === null &&
199
+ (rq.language === "zh-Hans" ||
200
+ rq.language === "zh-CN" ||
201
+ rq.region === "CN")
202
+ ) {
203
+ // Amap first
204
+ const amapRq: PlaceQueryRQ = {
205
+ ...rq,
206
+ region: undefined,
207
+ provider: ApiProvider.Amap
208
+ };
209
+
210
+ const amapResult = await this.api.post(
211
+ "Public/QueryPlace",
212
+ amapRq,
213
+ payload
214
+ );
215
+
216
+ if (amapResult && amapResult.length > 0) return amapResult;
217
+
218
+ // Baidu
219
+ const baiduRq: PlaceQueryRQ = {
220
+ ...rq,
221
+ region: undefined,
222
+ provider: ApiProvider.Baidu
223
+ };
224
+
225
+ const baiduResult = await this.api.post(
226
+ "Public/QueryPlace",
227
+ baiduRq,
228
+ payload
229
+ );
230
+
231
+ if (baiduResult && baiduResult.length > 0) return baiduResult;
232
+ }
233
+
234
+ return await this.api.post("Public/QueryPlace", rq, payload);
197
235
  }
198
236
 
199
237
  /**
@@ -14,8 +14,23 @@ export enum ApiOutput {
14
14
  * 接口供应商
15
15
  */
16
16
  export enum ApiProvider {
17
+ /**
18
+ * Google Maps
19
+ * 谷歌地图
20
+ */
17
21
  Google,
18
- Baidu
22
+
23
+ /**
24
+ * Baidu Maps
25
+ * 百度地图
26
+ */
27
+ Baidu,
28
+
29
+ /**
30
+ * Amap
31
+ * 高德地图
32
+ */
33
+ Amap
19
34
  }
20
35
 
21
36
  /**