ChannelDataSourceMapService.java 996 Bytes
Newer Older
afe's avatar
afe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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;
	}
}