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 { XUEQIU_SZ , XUEQIU_SH , XUEQIU_HK , XUEQIU_US } from "@stocks/xueqiu/utils/constant" ; /**
 * 【雪球】统一代码转换股票代码
 */ class XueqiuCommonCodeTransform extends BaseCommonCodeTransform { 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 XUEQIU_SZ + code . replace ( COMMON_SZ , "" ) ; } param code public SHTransform ( code ) { if ( ! code . includes ( COMMON_SH ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return XUEQIU_SH + code . replace ( COMMON_SH , "" ) ; } param code public HKTransform ( code ) { if ( ! code . includes ( COMMON_HK ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return XUEQIU_HK + code . replace ( COMMON_HK , "" ) ; } param code public USTransform ( code ) { if ( ! code . includes ( COMMON_US ) ) { throw new Error ( ERROR_COMMON_CODE ) ; } return XUEQIU_US + code . replace ( COMMON_US , "" ) ; } } export default XueqiuCommonCodeTransform ;