From f19f45723aa6e62dc9ac936e1215be6bd5e6c0e4 Mon Sep 17 00:00:00 2001 From: zhangxiangliang Date: Tue, 21 Jul 2020 16:53:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E4=BB=A3=E7=A0=81=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/base/transform.ts | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/modules/base/transform.ts diff --git a/src/modules/base/transform.ts b/src/modules/base/transform.ts new file mode 100644 index 0000000..22aa25a --- /dev/null +++ b/src/modules/base/transform.ts @@ -0,0 +1,61 @@ +import { SZ, SH, HK, US } from "../../utils/constant"; + +/** + * 基础股票代码转换 + */ +class BaseTransform { + /** + * 构造函数 + */ + constructor() {} + + /** + * 深交所股票代码转换 + * @param code 股票代码 + */ + public SZExchangeTransform(code: string): string { + if (!code.includes(SZ)) { + throw new Error("请检查股票代码是否正确"); + } + + throw new Error("未实现深交所股票代码转换"); + } + + /** + * 上交所股票代码转换 + * @param code 股票代码 + */ + public SHExchangeTransform(code: string): string { + if (!code.includes(SH)) { + throw new Error("请检查股票代码是否正确"); + } + + throw new Error("未实现上交所股票代码转换"); + } + + /** + * 港交所股票代码转换 + * @param code 股票代码 + */ + public HKExchangeTransform(code: string): string { + if (!code.includes(HK)) { + throw new Error("请检查股票代码是否正确"); + } + + throw new Error("未实现港交所股票代码转换"); + } + + /** + * 美交所股票代码转换 + * @param code 股票代码 + */ + public USExchangeTransform(code: string): string { + if (!code.includes(US)) { + throw new Error("请检查股票代码是否正确"); + } + + throw new Error("未实现美交所股票代码转换"); + } +} + +export default BaseTransform;