import BaseCommonCodeTransform from "@stocks/base/transforms/common-code" ; import { ERROR_COMMON_CODE } from "@utils/constant" ; import { SINA_SZ , SINA_SH , SINA_HK , SINA_US } from "@stocks/sina/utils/constant" ; import { COMMON_SH , COMMON_SZ , COMMON_HK , COMMON_US } from "@stocks/base/utils/constant" ; /**
 * 【新浪】统一代码转换股票代码
 */ class SinaCommonCodeTransform 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 . indexOf ( COMMON_SZ ) !== 0 ) { throw new Error ( ERROR_COMMON_CODE ) ; } return SINA_SZ + code . replace ( COMMON_SZ , "" ) ; } param code public SHTransform ( code ) { if ( code . indexOf ( COMMON_SH ) !== 0 ) { throw new Error ( ERROR_COMMON_CODE ) ; } return SINA_SH + code . replace ( COMMON_SH , "" ) ; } param code public HKTransform ( code ) { if ( code . indexOf ( COMMON_HK ) !== 0 ) { throw new Error ( ERROR_COMMON_CODE ) ; } return SINA_HK + code . replace ( COMMON_HK , "" ) ; } param code public USTransform ( code ) { if ( code . indexOf ( COMMON_US ) !== 0 ) { throw new Error ( ERROR_COMMON_CODE ) ; } return SINA_US + code . replace ( COMMON_US , "" ) . toLowerCase ( ) ; } } export default SinaCommonCodeTransform ;