package com.hp.cmsz.service; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.hp.cmsz.entity.ChannelDataSourceMap; import com.hp.cmsz.repository.ChannelDataSourceMapDao; //Spring Bean的标识. @Component // 默认将类中的所有public函数纳入事务管理. @Transactional(readOnly = true) public class ChannelDataSourceMapService { @Autowired private ChannelDataSourceMapDao channelDataSourceMapDao; public List<Long> getChannelIdByDataSourceId(Long datasourceId) { List<ChannelDataSourceMap> channelDataSourceMap = channelDataSourceMapDao .findByDataSourceId(datasourceId); List<Long> channelIdList = new ArrayList<Long>(); for (int i = 0; i < channelDataSourceMap.size(); i++) { channelIdList.add(channelDataSourceMap.get(i).getChannelId()); } return channelIdList; } }