import BaseCommonCodeTransform from "@stocks/base/transforms/common-code" ; import { ERROR_COMMON_CODE } from "@utils/constant" ; import { COMMON_SH , COMMON_SZ , COMMON_HK , COMMON_US } from "@stocks/base/utils/constant" ; import { TENCENT_SZ , TENCENT_SH , TENCENT_HK , TENCENT_US } from "@stocks/tencent/utils/constant" ; /**
 * 【腾讯】统一代码转换股票代码
 */ class TencentCommonCodeTransform extends BaseCommonCodeTransform { /**
     * 构造函数
     */ constructor ( ) { super ( ) ; } param code public transform ( code ) { return super . transform ( code ) ; } param codes public transforms ( codes ) { return super . transforms ( codes ) ; } param code public SZTransform ( code ) { if ( ! code . includes ( COMMON_SZ ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return TENCENT_SZ + code . replace ( COMMON_SZ , "" ) ; } param code public SHTransform ( code ) { if ( ! code . includes ( COMMON_SH ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return TENCENT_SH + code . replace ( COMMON_SH , "" ) ; } param code public HKTransform ( code ) { if ( ! code . includes ( COMMON_HK ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return TENCENT_HK + code . replace ( COMMON_HK , "" ) . toUpperCase ( ) ; } param code public USTransform ( code ) { if ( ! code . includes ( COMMON_US ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return TENCENT_US + code . replace ( COMMON_US , "" ) . toUpperCase ( ) ; } } export default TencentCommonCodeTransform ;