import { ERROR_COMMON_CODE , ERROR_UNDEFINED_SZ_COMMON_CODE , ERROR_UNDEFINED_SH_COMMON_CODE , ERROR_UNDEFINED_HK_COMMON_CODE , ERROR_UNDEFINED_US_COMMON_CODE } from "@utils/constant" ; import CommonCodeTransform from "types/stocks/transforms/common-code" ; import { COMMON_SH , COMMON_SZ , COMMON_HK , COMMON_US } from "../utils/constant" ; /**
 * 【基础】统一代码转换股票代码
 */ class BaseCommonCodeTransform implements CommonCodeTransform { param code public transform ( code ) { if ( code . indexOf ( COMMON_SH ) === 0 ) { return this . SHTransform ( code ) ; } if ( code . indexOf ( COMMON_SZ ) === 0 ) { return this . SZTransform ( code ) ; } if ( code . indexOf ( COMMON_HK ) === 0 ) { return this . HKTransform ( code ) ; } if ( code . indexOf ( COMMON_US ) === 0 ) { return this . USTransform ( code ) ; } throw new Error ( ERROR_COMMON_CODE ) ; } param codes public transforms ( codes ) { return codes . map ( ( code ) => this . transform ( code ) ) ; } param code public SZTransform ( code ) { throw new Error ( ERROR_UNDEFINED_SZ_COMMON_CODE ) ; } param code public SHTransform ( code ) { throw new Error ( ERROR_UNDEFINED_SH_COMMON_CODE ) ; } param code public HKTransform ( code ) { throw new Error ( ERROR_UNDEFINED_HK_COMMON_CODE ) ; } param code public USTransform ( code ) { throw new Error ( ERROR_UNDEFINED_US_COMMON_CODE ) ; } } export default BaseCommonCodeTransform ;